You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2009/10/02 14:59:29 UTC

svn commit: r820997 [3/3] - in /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin: ./ helper/ mojo/ om/ tags/ tags/annotation/ tags/annotation/defaulttag/ tags/annotation/sling/ tags/cl/ tags/qdox/ xml/

Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenJavaClassDescriptorManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenJavaClassDescriptorManager.java?rev=820997&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenJavaClassDescriptorManager.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenJavaClassDescriptorManager.java Fri Oct  2 12:59:27 2009
@@ -0,0 +1,423 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.mojo;
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.JavaClassDescriptorManager;
+import org.apache.felix.scrplugin.Log;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.SCRDescriptorFailureException;
+import org.apache.felix.scrplugin.helper.StringUtils;
+import org.apache.felix.scrplugin.om.Component;
+import org.apache.felix.scrplugin.om.Components;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.DirectoryScanner;
+import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.model.JavaSource;
+
+
+public class MavenJavaClassDescriptorManager extends JavaClassDescriptorManager
+{
+
+    private final MavenProject project;
+
+    private final String excludeString;
+
+    private JavaSource[] sources;
+
+    /** The component definitions from other bundles hashed by classname. */
+    private Map<String, Component> componentDescriptions;
+
+
+    public MavenJavaClassDescriptorManager( MavenProject project, Log log, ClassLoader classLoader,
+        String[] annotationTagProviders, String excludeString, boolean parseJavadocs, boolean processAnnotations )
+        throws SCRDescriptorFailureException
+    {
+        super( log, classLoader, annotationTagProviders, parseJavadocs, processAnnotations );
+
+        this.project = project;
+        this.excludeString = excludeString;
+    }
+
+
+    public String getOutputDirectory()
+    {
+        return this.project.getBuild().getOutputDirectory();
+    }
+
+
+    protected JavaSource[] getSources() throws SCRDescriptorException
+    {
+        if ( this.sources == null )
+        {
+
+            this.log.debug( "Setting up QDox" );
+
+            JavaDocBuilder builder = new JavaDocBuilder();
+            builder.getClassLibrary().addClassLoader( this.getClassLoader() );
+
+            @SuppressWarnings("unchecked")
+            final Iterator<String> i = project.getCompileSourceRoots().iterator();
+            // FELIX-509: check for excludes
+            if ( excludeString != null )
+            {
+                final String[] excludes = StringUtils.split( excludeString, "," );
+                final String[] includes = new String[]
+                    { "**/*.java" };
+
+                while ( i.hasNext() )
+                {
+                    final String tree = i.next();
+                    this.log.debug( "Scanning source tree " + tree );
+                    final File directory = new File( tree );
+                    final DirectoryScanner scanner = new DirectoryScanner();
+                    scanner.setBasedir( directory );
+
+                    if ( excludes != null && excludes.length > 0 )
+                    {
+                        scanner.setExcludes( excludes );
+                    }
+                    scanner.addDefaultExcludes();
+                    scanner.setIncludes( includes );
+
+                    scanner.scan();
+
+                    final String[] files = scanner.getIncludedFiles();
+                    if ( files != null )
+                    {
+                        for ( int m = 0; m < files.length; m++ )
+                        {
+                            this.log.debug( "Adding source file " + files[m] );
+                            try
+                            {
+                                builder.addSource( new File( directory, files[m] ) );
+                            }
+                            catch ( FileNotFoundException e )
+                            {
+                                throw new SCRDescriptorException( "Unable to scan directory.", e );
+                            }
+                            catch ( IOException e )
+                            {
+                                throw new SCRDescriptorException( "Unable to scan directory.", e );
+                            }
+                        }
+                    }
+                }
+            }
+            else
+            {
+                while ( i.hasNext() )
+                {
+                    final String tree = i.next();
+                    this.log.debug( "Adding source tree " + tree );
+                    final File directory = new File( tree );
+                    builder.addSourceTree( directory );
+                }
+            }
+            this.sources = builder.getSources();
+        }
+
+        return this.sources;
+    }
+
+
+    protected Map<String, Component> getComponentDescriptors() throws SCRDescriptorException
+    {
+        if ( this.componentDescriptions == null )
+        {
+            this.componentDescriptions = new HashMap<String, Component>();
+
+            // and now scan artifacts
+            final List<Component> components = new ArrayList<Component>();
+            @SuppressWarnings("unchecked")
+            final Map<String, Artifact> resolved = project.getArtifactMap();
+            @SuppressWarnings("unchecked")
+            final Set<Artifact> artifacts = project.getDependencyArtifacts();
+            final Iterator<Artifact> it = artifacts.iterator();
+            while ( it.hasNext() )
+            {
+                final Artifact declared = it.next();
+                this.log.debug( "Checking artifact " + declared );
+                if ( this.isJavaArtifact( declared ) )
+                {
+                    if ( Artifact.SCOPE_COMPILE.equals( declared.getScope() )
+                        || Artifact.SCOPE_RUNTIME.equals( declared.getScope() )
+                        || Artifact.SCOPE_PROVIDED.equals( declared.getScope() ) )
+                    {
+                        this.log.debug( "Resolving artifact " + declared );
+                        final Artifact artifact = resolved.get( ArtifactUtils.versionlessKey( declared ) );
+                        if ( artifact != null )
+                        {
+                            this.log.debug( "Trying to get manifest from artifact " + artifact );
+                            try
+                            {
+                                final Manifest manifest = this.getManifest( artifact );
+                                if ( manifest != null )
+                                {
+                                    // read Service-Component entry
+                                    if ( manifest.getMainAttributes().getValue( Constants.SERVICE_COMPONENT ) != null )
+                                    {
+                                        final String serviceComponent = manifest.getMainAttributes().getValue(
+                                            Constants.SERVICE_COMPONENT );
+                                        this.log.debug( "Found Service-Component: " + serviceComponent
+                                            + " in artifact " + artifact );
+                                        final StringTokenizer st = new StringTokenizer( serviceComponent, "," );
+                                        while ( st.hasMoreTokens() )
+                                        {
+                                            final String entry = st.nextToken().trim();
+                                            if ( entry.length() > 0 )
+                                            {
+                                                final Components c = this.readServiceComponentDescriptor( artifact,
+                                                    entry );
+                                                if ( c != null )
+                                                {
+                                                    components.addAll( c.getComponents() );
+                                                }
+                                            }
+                                        }
+                                    }
+                                    else
+                                    {
+                                        this.log.debug( "Artifact has no service component entry in manifest "
+                                            + artifact );
+                                    }
+                                }
+                                else
+                                {
+                                    this.log.debug( "Unable to get manifest from artifact " + artifact );
+                                }
+                            }
+                            catch ( IOException ioe )
+                            {
+                                throw new SCRDescriptorException( "Unable to get manifest from artifact " + artifact,
+                                    ioe );
+                            }
+                            this.log.debug( "Trying to get scrinfo from artifact " + artifact );
+                            // now read the scr private file - components stored there overwrite components already
+                            // read from the service component section.
+                            InputStream scrInfoFile = null;
+                            try
+                            {
+                                scrInfoFile = this.getFile( artifact, Constants.ABSTRACT_DESCRIPTOR_ARCHIV_PATH );
+                                if ( scrInfoFile != null )
+                                {
+                                    components.addAll( this.parseServiceComponentDescriptor( scrInfoFile )
+                                        .getComponents() );
+                                }
+                                else
+                                {
+                                    this.log.debug( "Artifact has no scrinfo file (it's optional): " + artifact );
+                                }
+                            }
+                            catch ( IOException ioe )
+                            {
+                                throw new SCRDescriptorException( "Unable to get scrinfo from artifact " + artifact,
+                                    ioe );
+                            }
+                            finally
+                            {
+                                if ( scrInfoFile != null )
+                                {
+                                    try
+                                    {
+                                        scrInfoFile.close();
+                                    }
+                                    catch ( IOException ignore )
+                                    {
+                                    }
+                                }
+                            }
+                        }
+                        else
+                        {
+                            this.log.debug( "Unable to resolve artifact " + declared );
+                        }
+                    }
+                    else
+                    {
+                        this.log.debug( "Artifact " + declared + " has not scope compile or runtime, but "
+                            + declared.getScope() );
+                    }
+                }
+                else
+                {
+                    this.log.debug( "Artifact " + declared + " is not a java artifact, type is " + declared.getType() );
+                }
+            }
+            // now create map with component descriptions
+            for ( final Component component : components )
+            {
+                this.componentDescriptions.put( component.getImplementation().getClassame(), component );
+            }
+        }
+
+        return this.componentDescriptions;
+    }
+
+
+    /**
+     * Check if the artifact is a java artifact (jar or bundle)
+     */
+    private boolean isJavaArtifact( Artifact artifact )
+    {
+        if ( "jar".equals( artifact.getType() ) )
+        {
+            return true;
+        }
+        if ( "bundle".equals( artifact.getType() ) )
+        {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Read the service component description.
+     * @param artifact
+     * @param entry
+     * @throws IOException
+     * @throws SCRDescriptorException
+     */
+    protected Components readServiceComponentDescriptor(Artifact artifact, String entry) {
+        this.log.debug("Reading " + entry + " from " + artifact);
+        InputStream xml = null;
+        try {
+            xml = this.getFile(artifact, entry);
+            if ( xml == null ) {
+                throw new SCRDescriptorException("Artifact " + artifact + " does not contain declared service component descriptor " + entry);
+            }
+            return this.parseServiceComponentDescriptor(xml);
+        } catch (IOException mee) {
+            this.log.warn("Unable to read SCR descriptor file from artifact " + artifact + " at " + entry);
+            this.log.debug("Exception occurred during reading: " + mee.getMessage(), mee);
+        } catch (SCRDescriptorException mee) {
+            this.log.warn("Unable to read SCR descriptor file from artifact " + artifact + " at " + entry);
+            this.log.debug("Exception occurred during reading: " + mee.getMessage(), mee);
+        }
+        finally
+        {
+            if ( xml != null )
+            {
+                try
+                {
+                    xml.close();
+                }
+                catch ( IOException ignore )
+                {
+                }
+            }
+        }
+       return null;
+    }
+
+    protected Manifest getManifest(Artifact artifact) throws IOException {
+        JarFile file = null;
+        try {
+            file = new JarFile(artifact.getFile());
+            return file.getManifest();
+        } finally {
+            if (file != null) {
+                try {
+                    file.close();
+                } catch (IOException ignore) {
+                }
+            }
+        }
+    }
+
+    protected InputStream getFile(Artifact artifact, String path) throws IOException {
+        JarFile file = null;
+        try {
+            file = new JarFile(artifact.getFile());
+            final JarEntry entry = file.getJarEntry(path);
+            if ( entry != null ) {
+                final InputStream stream = new ArtifactFileInputStream( file, entry);
+                file = null; // prevent file from being closed now
+                return stream;
+            }
+            return null;
+        } finally {
+            if (file != null) {
+                try {
+                    file.close();
+                } catch (IOException ignore) {
+                }
+            }
+        }
+    }
+
+    private static class ArtifactFileInputStream extends FilterInputStream
+    {
+        final JarFile jarFile;
+
+
+        ArtifactFileInputStream( JarFile jarFile, JarEntry jarEntry ) throws IOException
+        {
+            super( jarFile.getInputStream( jarEntry ) );
+            this.jarFile = jarFile;
+        }
+
+
+        @Override
+        public void close() throws IOException
+        {
+            try
+            {
+                super.close();
+            }
+            catch ( IOException ioe )
+            {
+            }
+            jarFile.close();
+        }
+
+
+        @Override
+        protected void finalize() throws Throwable
+        {
+            try
+            {
+                close();
+            }
+            finally
+            {
+                super.finalize();
+            }
+        }
+    }
+}

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenJavaClassDescriptorManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenJavaClassDescriptorManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenLog.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenLog.java?rev=820997&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenLog.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenLog.java Fri Oct  2 12:59:27 2009
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.mojo;
+
+
+import org.apache.felix.scrplugin.Log;
+
+
+/**
+ * The <code>MavenLog</code> class implements the {@link Log} interface using
+ * the Maven logger created on instantiation.
+ */
+public class MavenLog implements Log
+{
+
+    private final org.apache.maven.plugin.logging.Log mavenLog;
+
+
+    MavenLog( org.apache.maven.plugin.logging.Log mavenLog )
+    {
+        this.mavenLog = mavenLog;
+    }
+
+
+    public void debug( String content, Throwable error )
+    {
+        mavenLog.debug( content, error );
+    }
+
+
+    public void debug( String content )
+    {
+        mavenLog.debug( content );
+    }
+
+
+    public void debug( Throwable error )
+    {
+        mavenLog.debug( error );
+    }
+
+
+    public void error( String content, Throwable error )
+    {
+        mavenLog.error( content, error );
+    }
+
+
+    public void error( String content )
+    {
+        mavenLog.error( content );
+    }
+
+
+    public void error( Throwable error )
+    {
+        mavenLog.error( error );
+    }
+
+
+    public void info( String content, Throwable error )
+    {
+        mavenLog.info( content, error );
+    }
+
+
+    public void info( String content )
+    {
+        mavenLog.info( content );
+    }
+
+
+    public void info( Throwable error )
+    {
+        mavenLog.info( error );
+    }
+
+
+    public boolean isDebugEnabled()
+    {
+        return mavenLog.isDebugEnabled();
+    }
+
+
+    public boolean isErrorEnabled()
+    {
+        return mavenLog.isErrorEnabled();
+    }
+
+
+    public boolean isInfoEnabled()
+    {
+        return mavenLog.isInfoEnabled();
+    }
+
+
+    public boolean isWarnEnabled()
+    {
+        return mavenLog.isWarnEnabled();
+    }
+
+
+    public void warn( String content, Throwable error )
+    {
+        mavenLog.warn( content, error );
+    }
+
+
+    public void warn( String content )
+    {
+        mavenLog.warn( content );
+    }
+
+
+    public void warn( Throwable error )
+    {
+        mavenLog.warn( error );
+    }
+}

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenLog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenLog.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java?rev=820997&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java Fri Oct  2 12:59:27 2009
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.mojo;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.JavaClassDescriptorManager;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.SCRDescriptorFailureException;
+import org.apache.felix.scrplugin.SCRDescriptorGenerator;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * The <code>SCRDescriptorMojo</code>
+ * generates a service descriptor file based on annotations found in the sources.
+ *
+ * @goal scr
+ * @phase process-classes
+ * @description Build Service Descriptors from Java Source
+ * @requiresDependencyResolution compile
+ */
+public class SCRDescriptorMojo extends AbstractMojo {
+
+    /**
+     * @parameter expression="${project.build.directory}/scr-plugin-generated"
+     * @required
+     * @readonly
+     */
+    private File outputDirectory;
+
+    /**
+     * The Maven project.
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    /**
+     * Name of the generated descriptor.
+     *
+     * @parameter expression="${scr.descriptor.name}" default-value="serviceComponents.xml"
+     */
+    private String finalName;
+
+    /**
+     * Name of the generated meta type file.
+     *
+     * @parameter default-value="metatype.xml"
+     */
+    private String metaTypeName;
+
+    /**
+     * This flag controls the generation of the bind/unbind methods.
+     * @parameter default-value="true"
+     */
+    private boolean generateAccessors;
+
+    /**
+     * This flag controls whether the javadoc source code will be scanned for
+     * tags.
+     * @parameter default-value="true"
+     */
+    protected boolean parseJavadoc;
+
+    /**
+     * This flag controls whether the annotations in the sources will be
+     * processed.
+     * @parameter default-value="true"
+     */
+    protected boolean processAnnotations;
+
+    /**
+     * In strict mode the plugin even fails on warnings.
+     * @parameter default-value="false"
+     */
+    protected boolean strictMode;
+
+    /**
+     * The comma separated list of tokens to exclude when processing sources.
+     *
+     * @parameter alias="excludes"
+     */
+    private String sourceExcludes;
+
+    /**
+     * Predefined properties.
+     *
+     * @parameter
+     */
+    private Map<String, String> properties = new HashMap<String, String>();
+
+    /**
+     * Allows to define additional implementations of the interface
+     * {@link org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider}
+     * that provide mappings from custom annotations to
+     * {@link org.apache.felix.scrplugin.tags.JavaTag} implementations.
+     * List of full qualified class file names.
+     *
+     * @parameter
+     */
+    private String[] annotationTagProviders = {};
+
+    /**
+     * The version of the DS spec this plugin generates a descriptor for.
+     * By default the version is detected by the used tags.
+     * @parameter
+     */
+    private String specVersion;
+
+
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        try
+        {
+            final org.apache.felix.scrplugin.Log scrLog = new MavenLog( getLog() );
+
+            final ClassLoader classLoader = new URLClassLoader( getClassPath(), this.getClass().getClassLoader() );
+            final JavaClassDescriptorManager jManager = new MavenJavaClassDescriptorManager( project, scrLog,
+                classLoader, this.annotationTagProviders, this.sourceExcludes, this.parseJavadoc,
+                this.processAnnotations );
+
+            final SCRDescriptorGenerator generator = new SCRDescriptorGenerator( scrLog );
+
+            // setup from plugin configuration
+            generator.setOutputDirectory( outputDirectory );
+            generator.setDescriptorManager( jManager );
+            generator.setFinalName( finalName );
+            generator.setMetaTypeName( metaTypeName );
+            generator.setGenerateAccessors( generateAccessors );
+            generator.setStrictMode( strictMode );
+            generator.setProperties( properties );
+            generator.setSpecVersion( specVersion );
+
+            if ( generator.execute() )
+            {
+                setServiceComponentHeader();
+                addResources();
+            }
+        }
+        catch ( SCRDescriptorException sde )
+        {
+            throw new MojoExecutionException( sde.getMessage(), sde.getCause() );
+        }
+        catch ( SCRDescriptorFailureException sdfe )
+        {
+            throw ( MojoFailureException ) new MojoFailureException( sdfe.getMessage() ).initCause( sdfe );
+        }
+    }
+
+    private URL[] getClassPath() throws MojoFailureException{
+        @SuppressWarnings("unchecked")
+        List<Artifact> artifacts = this.project.getCompileArtifacts();
+        ArrayList<URL> path = new ArrayList<URL>();
+
+        try
+        {
+            path.add(new File( this.project.getBuild().getOutputDirectory() ).toURI().toURL());
+        }
+        catch ( IOException ioe )
+        {
+            throw new MojoFailureException( "Unable to add target directory to classloader.");
+        }
+
+        int i = 1;
+        for (Iterator<Artifact> ai=artifacts.iterator(); ai.hasNext(); ) {
+            Artifact a = ai.next();
+            try {
+                path.add(a.getFile().toURI().toURL());
+            } catch (IOException ioe) {
+                throw new MojoFailureException("Unable to get compile class loader.");
+            }
+        }
+
+        return path.toArray( new URL[path.size()] );
+    }
+
+
+    private void setServiceComponentHeader()
+    {
+        final File descriptorFile = StringUtils.isEmpty( this.finalName ) ? null : new File( new File(
+            this.outputDirectory, "OSGI-INF" ), this.finalName );
+        if ( descriptorFile.exists() )
+        {
+            String svcComp = project.getProperties().getProperty( "Service-Component" );
+            svcComp = ( svcComp == null ) ? "OSGI-INF/" + finalName : svcComp + ", " + "OSGI-INF/" + finalName;
+            project.getProperties().setProperty( "Service-Component", svcComp );
+        }
+    }
+
+
+    private void addResources()
+    {
+        // now add the descriptor directory to the maven resources
+        final String ourRsrcPath = this.outputDirectory.getAbsolutePath();
+        boolean found = false;
+        @SuppressWarnings("unchecked")
+        final Iterator<Resource> rsrcIterator = this.project.getResources().iterator();
+        while ( !found && rsrcIterator.hasNext() )
+        {
+            final Resource rsrc = rsrcIterator.next();
+            found = rsrc.getDirectory().equals( ourRsrcPath );
+        }
+        if ( !found )
+        {
+            final Resource resource = new Resource();
+            resource.setDirectory( this.outputDirectory.getAbsolutePath() );
+            this.project.addResource( resource );
+        }
+    }
+}

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java Fri Oct  2 12:59:27 2009
@@ -22,9 +22,11 @@
 import java.util.List;
 
 import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.IssueLog;
-import org.apache.felix.scrplugin.tags.*;
-import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.helper.IssueLog;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.JavaMethod;
+import org.apache.felix.scrplugin.tags.JavaTag;
 
 /**
  * <code>Component</code>
@@ -255,7 +257,7 @@
      * warnings can be added to the warnings list.
      */
     public void validate(final int specVersion, final IssueLog iLog)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final int currentIssueCount = iLog.getNumberOfErrors();
 
         // nothing to check if this is ignored
@@ -374,7 +376,7 @@
                                         final String methodName,
                                         final boolean isActivate,
                                         final IssueLog iLog)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         // first candidate is (de)activate(ComponentContext)
         JavaMethod method = javaClass.getMethodBySignature(methodName, new String[] {TYPE_COMPONENT_CONTEXT});
         if ( method == null ) {

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Interface.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Interface.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Interface.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Interface.java Fri Oct  2 12:59:27 2009
@@ -18,10 +18,10 @@
  */
 package org.apache.felix.scrplugin.om;
 
-import org.apache.felix.scrplugin.IssueLog;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.helper.IssueLog;
 import org.apache.felix.scrplugin.tags.JavaClassDescription;
 import org.apache.felix.scrplugin.tags.JavaTag;
-import org.apache.maven.plugin.MojoExecutionException;
 
 /**
  * <code>Interface.java</code>...
@@ -59,7 +59,7 @@
      * warnings can be added to the warnings list.
      */
     public void validate(final int specVersion, final IssueLog iLog)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final JavaClassDescription javaClass = this.tag.getJavaClassDescription();
         if (javaClass == null) {
             iLog.addError(this.getMessage("Must be declared in a Java class"));

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java Fri Oct  2 12:59:27 2009
@@ -19,7 +19,7 @@
 package org.apache.felix.scrplugin.om;
 
 import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.IssueLog;
+import org.apache.felix.scrplugin.helper.IssueLog;
 import org.apache.felix.scrplugin.tags.JavaTag;
 
 /**

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java Fri Oct  2 12:59:27 2009
@@ -19,10 +19,12 @@
 package org.apache.felix.scrplugin.om;
 
 import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.IssueLog;
-import org.apache.felix.scrplugin.tags.*;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.codehaus.plexus.util.StringUtils;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.helper.IssueLog;
+import org.apache.felix.scrplugin.helper.StringUtils;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.JavaMethod;
+import org.apache.felix.scrplugin.tags.JavaTag;
 
 /**
  * <code>Reference.java</code>...
@@ -149,7 +151,7 @@
     public void validate(final int specVersion,
                          final boolean componentIsAbstract,
                          final IssueLog iLog)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         // if this reference is already checked, return immediately
         if ( this.checked ) {
             return;
@@ -225,7 +227,7 @@
                                     final String   methodName,
                                     final boolean  componentIsAbstract,
                                     final IssueLog iLog)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final JavaMethod method = this.findMethod(specVersion, methodName);
         if (method == null) {
             if ( !componentIsAbstract ) {
@@ -251,7 +253,7 @@
 
     public JavaMethod findMethod(final int    specVersion,
                                  final String methodName)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final String[] sig = new String[]{ TYPE_SERVICE_REFERENCE };
         final String[] sig2 = new String[]{ this.getInterfacename() };
         final String[] sig3 = new String[]{ this.getInterfacename(), TYPE_MAP};

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java Fri Oct  2 12:59:27 2009
@@ -18,10 +18,12 @@
  */
 package org.apache.felix.scrplugin.om;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
-import org.apache.felix.scrplugin.IssueLog;
-import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.helper.IssueLog;
 
 /**
  * <code>Service</code>...
@@ -92,7 +94,7 @@
      * warnings can be added to the warnings list.
      */
     public void validate(final int specVersion, final IssueLog iLog)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         for(final Interface interf : this.getInterfaces()) {
             interf.validate(specVersion, iLog);
         }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java Fri Oct  2 12:59:27 2009
@@ -18,7 +18,7 @@
  */
 package org.apache.felix.scrplugin.tags;
 
-import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.felix.scrplugin.SCRDescriptorException;
 
 /**
  * <code>JavaClassDescription.java</code>...
@@ -41,18 +41,18 @@
      * @param name
      * @param inherited If true, parent classes are searched as well.
      * @return An array of tags or the empty array.
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
     JavaTag[] getTagsByName(String name, boolean inherited)
-    throws MojoExecutionException;
+    throws SCRDescriptorException;
 
     /**
      * Get the description for the parent class.
      * @return The description or <code>null</code> if this class is the
      *         Object class.
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
-    JavaClassDescription getSuperClass() throws MojoExecutionException;
+    JavaClassDescription getSuperClass() throws SCRDescriptorException;
 
     /**
      * Get the name of the described class.
@@ -70,29 +70,29 @@
      * Get the field with the name.
      * @param name The name of the field
      * @return The field with the name or null.
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
-    JavaField getFieldByName(String name) throws MojoExecutionException;
+    JavaField getFieldByName(String name) throws SCRDescriptorException;
 
-    JavaField getExternalFieldByName(String name) throws MojoExecutionException;
+    JavaField getExternalFieldByName(String name) throws SCRDescriptorException;
 
     /**
      * Returns an array of the implemented interfaces of this class.
      * @return An array containing the interfaces or an empty array
      *         if this class does not implement any interface.
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
-    JavaClassDescription[] getImplementedInterfaces() throws MojoExecutionException;
+    JavaClassDescription[] getImplementedInterfaces() throws SCRDescriptorException;
 
     /**
      * Search for a method with the given signature.
      * @param name
      * @param parameters
      * @return A descriptor for the method or <code>null</code>
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
     JavaMethod getMethodBySignature(String name, String[] parameters)
-    throws MojoExecutionException;
+    throws SCRDescriptorException;
 
     /**
      * Is this class public?
@@ -122,9 +122,9 @@
      * Is this class of the type?
      * @param type
      * @return True if this class is of the type.
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
-    boolean isA(String type) throws MojoExecutionException;
+    boolean isA(String type) throws SCRDescriptorException;
 
     /**
      * Search for the class.
@@ -132,8 +132,8 @@
      * of the class are searched.
      * @param referencedName
      * @return The java class description or null
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
     JavaClassDescription getReferencedClass(String referencedName)
-    throws MojoExecutionException;
+    throws SCRDescriptorException;
 }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java Fri Oct  2 12:59:27 2009
@@ -21,7 +21,7 @@
 
 import java.util.Comparator;
 
-import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.felix.scrplugin.SCRDescriptorException;
 
 
 /**
@@ -88,7 +88,7 @@
                 return 1;
             }
         }
-        catch ( MojoExecutionException mee )
+        catch ( SCRDescriptorException mee )
         {
             // what shall we do ??
         }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/ModifiableJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/ModifiableJavaClassDescription.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/ModifiableJavaClassDescription.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/ModifiableJavaClassDescription.java Fri Oct  2 12:59:27 2009
@@ -18,11 +18,11 @@
  */
 package org.apache.felix.scrplugin.tags;
 
-import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.felix.scrplugin.SCRDescriptorException;
 
 
 public interface ModifiableJavaClassDescription {
 
     void addMethods(String propertyName, String className, boolean createBind, boolean createUnbind)
-    throws MojoExecutionException;
+    throws SCRDescriptorException;
 }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java Fri Oct  2 12:59:27 2009
@@ -18,11 +18,15 @@
  */
 package org.apache.felix.scrplugin.tags.annotation;
 
-import java.util.*;
-
-import org.apache.felix.scrplugin.tags.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.felix.scrplugin.JavaClassDescriptorManager;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
 import org.apache.felix.scrplugin.tags.qdox.QDoxJavaClassDescription;
-import org.apache.maven.plugin.MojoExecutionException;
 
 import com.thoughtworks.qdox.model.JavaClass;
 
@@ -62,7 +66,7 @@
      * @see JavaClassDescription#getTagsByName(String, boolean)
      */
     @Override
-    public JavaTag[] getTagsByName(String name, boolean inherited) throws MojoExecutionException {
+    public JavaTag[] getTagsByName(String name, boolean inherited) throws SCRDescriptorException {
 
         List<JavaTag> tags = new ArrayList<JavaTag>();
         for(com.thoughtworks.qdox.model.Annotation annotation : this.javaClass.getAnnotations()) {
@@ -104,7 +108,7 @@
      * @see JavaClassDescription#getFieldByName(String)
      */
     @Override
-    public JavaField getFieldByName(String name) throws MojoExecutionException {
+    public JavaField getFieldByName(String name) throws SCRDescriptorException {
         final com.thoughtworks.qdox.model.JavaField field = this.javaClass.getFieldByName(name);
         if (field != null) {
             return new AnnotationJavaField(field, this);

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java Fri Oct  2 12:59:27 2009
@@ -21,11 +21,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.felix.scrplugin.SCRDescriptorFailureException;
 import org.apache.felix.scrplugin.tags.JavaField;
 import org.apache.felix.scrplugin.tags.JavaTag;
 import org.apache.felix.scrplugin.tags.annotation.defaulttag.DefaultAnnotationTagProvider;
 import org.apache.felix.scrplugin.tags.annotation.sling.SlingAnnotationTagProvider;
-import org.apache.maven.plugin.MojoFailureException;
 
 import com.thoughtworks.qdox.model.Annotation;
 import com.thoughtworks.qdox.model.JavaClass;
@@ -49,7 +49,7 @@
      *            {@link AnnotationTagProvider} interface.
      * @throws MojoFailureException
      */
-    public AnnotationTagProviderManager(String[] annotationTagProviderClasses) throws MojoFailureException {
+    public AnnotationTagProviderManager(String[] annotationTagProviderClasses) throws SCRDescriptorFailureException {
 
         // always add provider supporting built-in SCR default properties
         annotationTagProviders.add(new DefaultAnnotationTagProvider());
@@ -62,17 +62,17 @@
                 try {
                     annotationTagProviders.add((AnnotationTagProvider) clazz.newInstance());
                 } catch (ClassCastException e) {
-                    throw new MojoFailureException("Class '" + clazz.getName() + "' "
+                    throw new SCRDescriptorFailureException("Class '" + clazz.getName() + "' "
                             + "does not implement interface '" + AnnotationTagProvider.class.getName() + "'.");
                 } catch (InstantiationException e) {
-                    throw new MojoFailureException("Unable to instantiate class '" + clazz.getName() + "': "
+                    throw new SCRDescriptorFailureException("Unable to instantiate class '" + clazz.getName() + "': "
                             + e.getMessage());
                 } catch (IllegalAccessException e) {
-                    throw new MojoFailureException("Illegal access to class '" + clazz.getName() + "': "
+                    throw new SCRDescriptorFailureException("Illegal access to class '" + clazz.getName() + "': "
                             + e.getMessage());
                 }
             } catch (ClassNotFoundException ex) {
-                throw new MojoFailureException("Annotation provider class '" + annotationTagProviderClasses[i]
+                throw new SCRDescriptorFailureException("Annotation provider class '" + annotationTagProviderClasses[i]
                         + "' not found.");
             }
         }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java Fri Oct  2 12:59:27 2009
@@ -20,11 +20,16 @@
 
 import java.util.List;
 
-import org.apache.felix.scrplugin.tags.*;
-import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.tags.ClassUtil;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.JavaField;
 
 import com.thoughtworks.qdox.model.Annotation;
-import com.thoughtworks.qdox.model.annotation.*;
+import com.thoughtworks.qdox.model.annotation.AnnotationConstant;
+import com.thoughtworks.qdox.model.annotation.AnnotationFieldRef;
+import com.thoughtworks.qdox.model.annotation.AnnotationValue;
+import com.thoughtworks.qdox.model.annotation.AnnotationValueList;
 
 /**
  * Helper class for getting values from annotations.
@@ -378,7 +383,7 @@
                 }
                 throw new IllegalArgumentException("Something is wrong.");
             }
-            catch (MojoExecutionException mee)
+            catch (SCRDescriptorException mee)
             {
                 throw new IllegalArgumentException(mee);
             }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java Fri Oct  2 12:59:27 2009
@@ -18,12 +18,14 @@
  */
 package org.apache.felix.scrplugin.tags.annotation.sling;
 
-import java.util.*;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
 
 import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.helper.StringUtils;
 import org.apache.felix.scrplugin.tags.JavaClassDescription;
 import org.apache.felix.scrplugin.tags.annotation.defaulttag.AbstractTag;
-import org.codehaus.plexus.util.StringUtils;
 
 /**
  * Description of a java tag for components.

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java Fri Oct  2 12:59:27 2009
@@ -18,13 +18,21 @@
  */
 package org.apache.felix.scrplugin.tags.cl;
 
-import java.lang.reflect.*;
-import java.util.*;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.JavaClassDescriptorManager;
+import org.apache.felix.scrplugin.SCRDescriptorException;
 import org.apache.felix.scrplugin.om.Component;
-import org.apache.felix.scrplugin.tags.*;
-import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaMethod;
+import org.apache.felix.scrplugin.tags.JavaTag;
 
 /**
  * <code>ClassLoaderJavaClassDescription.java</code>...
@@ -61,7 +69,7 @@
     /**
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getFieldByName(java.lang.String)
      */
-    public JavaField getFieldByName(String name) throws MojoExecutionException {
+    public JavaField getFieldByName(String name) throws SCRDescriptorException {
         Field field = null;
         try {
             field = this.clazz.getField(name);
@@ -83,22 +91,22 @@
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getExternalFieldByName(java.lang.String)
      */
     public JavaField getExternalFieldByName(String name)
-    throws MojoExecutionException {
-        throw new MojoExecutionException("getExternalFieldByName not supported for this class.");
+    throws SCRDescriptorException {
+        throw new SCRDescriptorException("getExternalFieldByName not supported for this class.");
     }
 
     /**
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getReferencedClass(java.lang.String)
      */
     public JavaClassDescription getReferencedClass(String referencedName)
-    throws MojoExecutionException {
-        throw new MojoExecutionException("getReferencedClass not supported for this class.");
+    throws SCRDescriptorException {
+        throw new SCRDescriptorException("getReferencedClass not supported for this class.");
     }
 
     /**
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getImplementedInterfaces()
      */
-    public JavaClassDescription[] getImplementedInterfaces() throws MojoExecutionException {
+    public JavaClassDescription[] getImplementedInterfaces() throws SCRDescriptorException {
         Class<?>[] implemented = clazz.getInterfaces();
         if (implemented.length == 0) {
             return JavaClassDescription.EMPTY_RESULT;
@@ -115,7 +123,7 @@
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getMethodBySignature(java.lang.String, java.lang.String[])
      */
     public JavaMethod getMethodBySignature(String name, String[] parameters)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         Class<?>[] classParameters = null;
         if ( parameters != null ) {
             classParameters = new Class[parameters.length];
@@ -133,7 +141,7 @@
         } catch (NoClassDefFoundError ncdfe) {
             // if this occurs it usually means that a problem with the maven
             // scopes exists.
-            throw new MojoExecutionException("Class loading error. This error usually occurs if you have a " +
+            throw new SCRDescriptorException("Class loading error. This error usually occurs if you have a " +
                     "service inheriting from a class coming from another bundle and that class using a " +
                     "third library and all dependencies are specified with scope 'provided'.", ncdfe);
         } catch (NoSuchMethodException e) {
@@ -166,7 +174,7 @@
     /**
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getSuperClass()
      */
-    public JavaClassDescription getSuperClass() throws MojoExecutionException {
+    public JavaClassDescription getSuperClass() throws SCRDescriptorException {
         if ( this.clazz.getSuperclass() != null ) {
             return this.manager.getJavaClassDescription(this.clazz.getSuperclass().getName());
         }
@@ -186,7 +194,7 @@
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getTagsByName(java.lang.String, boolean)
      */
     public JavaTag[] getTagsByName(String name, boolean inherited)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         JavaTag[] javaTags = EMPTY_TAGS;
         if ( this.component != null ) {
             if ( Constants.SERVICE.equals(name) ) {

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java Fri Oct  2 12:59:27 2009
@@ -18,18 +18,32 @@
  */
 package org.apache.felix.scrplugin.tags.qdox;
 
-import java.io.*;
-import java.util.*;
-
-import org.apache.felix.scrplugin.tags.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.felix.scrplugin.JavaClassDescriptorManager;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
 import org.apache.felix.scrplugin.tags.JavaField;
 import org.apache.felix.scrplugin.tags.JavaMethod;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.objectweb.asm.*;
+import org.apache.felix.scrplugin.tags.JavaTag;
+import org.apache.felix.scrplugin.tags.ModifiableJavaClassDescription;
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.tree.ClassNode;
 
-import com.thoughtworks.qdox.model.*;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaClass;
 import com.thoughtworks.qdox.model.JavaParameter;
+import com.thoughtworks.qdox.model.JavaSource;
 import com.thoughtworks.qdox.model.Type;
 
 /**
@@ -55,7 +69,7 @@
     /**
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getSuperClass()
      */
-    public JavaClassDescription getSuperClass() throws MojoExecutionException {
+    public JavaClassDescription getSuperClass() throws SCRDescriptorException {
         final JavaClass parent = this.javaClass.getSuperJavaClass();
         if ( parent != null ) {
             return this.manager.getJavaClassDescription(parent.getFullyQualifiedName());
@@ -85,7 +99,7 @@
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getTagsByName(java.lang.String, boolean)
      */
     public JavaTag[] getTagsByName(String name, boolean inherited)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final DocletTag[] tags = this.javaClass.getTagsByName(name, false);
         JavaTag[] javaTags;
         if ( tags == null || tags.length == 0 ) {
@@ -126,7 +140,7 @@
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getFieldByName(java.lang.String)
      */
     public JavaField getFieldByName(String name)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final com.thoughtworks.qdox.model.JavaField field = this.javaClass.getFieldByName(name);
         if ( field != null ) {
             return new QDoxJavaField(field, this);
@@ -141,7 +155,7 @@
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getExternalFieldByName(java.lang.String)
      */
     public JavaField getExternalFieldByName(String name)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         int lastDot = name.lastIndexOf('.');
         // if there is no dot, this should be a static import
         if ( lastDot == -1 ) {
@@ -216,7 +230,7 @@
         }
         try {
             return this.manager.getJavaClassDescription(className);
-        } catch (MojoExecutionException mee) {
+        } catch (SCRDescriptorException mee) {
             return null;
         }
     }
@@ -225,7 +239,7 @@
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getImplementedInterfaces()
      */
     public JavaClassDescription[] getImplementedInterfaces()
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final JavaClass[] interfaces = this.javaClass.getImplementedInterfaces();
         if ( interfaces == null || interfaces.length == 0 ) {
             return JavaClassDescription.EMPTY_RESULT;
@@ -241,7 +255,7 @@
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getMethodBySignature(java.lang.String, java.lang.String[])
      */
     public JavaMethod getMethodBySignature(String name, String[] parameters)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         Type[] types = null;
         if ( parameters == null || parameters.length == 0 ) {
             types = new Type[0];
@@ -279,7 +293,7 @@
     /**
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#isA(java.lang.String)
      */
-    public boolean isA(String type) throws MojoExecutionException {
+    public boolean isA(String type) throws SCRDescriptorException {
         final Type qType = new Type(type);
         if ( this.javaClass.isA(type) ) {
             return true;
@@ -326,9 +340,9 @@
                            final String className,
                            final boolean createBind,
                            final boolean createUnbind)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         // now do byte code manipulation
-        final String targetDirectory = this.manager.getProject().getBuild().getOutputDirectory();
+        final String targetDirectory = this.manager.getOutputDirectory();
         final String fileName = targetDirectory + File.separatorChar +  this.getName().replace('.', File.separatorChar) + ".class";
         final ClassNode cn = new ClassNode();
         try {
@@ -375,7 +389,7 @@
             fos.write(writer.toByteArray());
             fos.close();
         } catch (Exception e) {
-            throw new MojoExecutionException("Unable to add methods to " + this.getName(), e);
+            throw new SCRDescriptorException("Unable to add methods to " + this.getName(), e);
         }
     }
 

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java Fri Oct  2 12:59:27 2009
@@ -20,14 +20,23 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.StringTokenizer;
 
 import javax.xml.transform.TransformerException;
 
 import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.om.*;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.xml.sax.*;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.om.Component;
+import org.apache.felix.scrplugin.om.Components;
+import org.apache.felix.scrplugin.om.Implementation;
+import org.apache.felix.scrplugin.om.Interface;
+import org.apache.felix.scrplugin.om.Property;
+import org.apache.felix.scrplugin.om.Reference;
+import org.apache.felix.scrplugin.om.Service;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
 import org.xml.sax.helpers.DefaultHandler;
 
@@ -104,16 +113,14 @@
 
     private static final String INTERFACE_QNAME = INTERFACE;
 
-    public static Components read(File file)
-    throws MojoExecutionException {
+    public static Components read(InputStream file)
+    throws SCRDescriptorException {
         try {
             final XmlHandler xmlHandler = new XmlHandler();
             IOUtils.parse(file, xmlHandler);
             return xmlHandler.components;
         } catch (TransformerException e) {
-            throw new MojoExecutionException("Unable to read xml from " + file, e);
-        } catch (IOException e) {
-            throw new MojoExecutionException("Unable to read xml from " + file, e);
+            throw new SCRDescriptorException("Unable to read xml from " + file, e);
         }
     }
 
@@ -121,18 +128,18 @@
      * Write the component descriptors to the file.
      * @param components
      * @param file
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
     public static void write(Components components, File file, boolean isScrPrivateFile)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         try {
             generateXML(components, IOUtils.getSerializer(file), isScrPrivateFile);
         } catch (TransformerException e) {
-            throw new MojoExecutionException("Unable to write xml to " + file, e);
+            throw new SCRDescriptorException("Unable to write xml to " + file, e);
         } catch (SAXException e) {
-            throw new MojoExecutionException("Unable to generate xml for " + file, e);
+            throw new SCRDescriptorException("Unable to generate xml for " + file, e);
         } catch (IOException e) {
-            throw new MojoExecutionException("Unable to write xml to " + file, e);
+            throw new SCRDescriptorException("Unable to write xml to " + file, e);
         }
     }
 
@@ -428,25 +435,36 @@
                     impl.setClassname(attributes.getValue("class"));
 
                 } else if (localName.equals(PROPERTY)) {
-                    final Property prop = new Property();
-
-                    prop.setName(attributes.getValue("name"));
-                    prop.setType(attributes.getValue("type"));
 
-                    if ( attributes.getValue("value") != null) {
-                        prop.setValue(attributes.getValue("value"));
-                        this.currentComponent.addProperty(prop);
-                    } else {
-                        // hold the property pending as we have a multi value
-                        this.pendingProperty = prop;
-                    }
-                    // check for abstract properties
-                    prop.setLabel(attributes.getValue("label"));
-                    prop.setDescription(attributes.getValue("description"));
-                    prop.setCardinality(attributes.getValue("cardinality"));
-                    final String pValue = attributes.getValue("private");
-                    if ( pValue != null ) {
-                        prop.setPrivate(Boolean.valueOf(pValue).booleanValue());
+                    // read the property, unless it is the service.pid
+                    // property which must not be inherited
+                    final String propName = attributes.getValue( "name" );
+                    if ( !org.osgi.framework.Constants.SERVICE_PID.equals( propName ) )
+                    {
+                        final Property prop = new Property();
+
+                        prop.setName( propName );
+                        prop.setType( attributes.getValue( "type" ) );
+
+                        if ( attributes.getValue( "value" ) != null )
+                        {
+                            prop.setValue( attributes.getValue( "value" ) );
+                            this.currentComponent.addProperty( prop );
+                        }
+                        else
+                        {
+                            // hold the property pending as we have a multi value
+                            this.pendingProperty = prop;
+                        }
+                        // check for abstract properties
+                        prop.setLabel( attributes.getValue( "label" ) );
+                        prop.setDescription( attributes.getValue( "description" ) );
+                        prop.setCardinality( attributes.getValue( "cardinality" ) );
+                        final String pValue = attributes.getValue( "private" );
+                        if ( pValue != null )
+                        {
+                            prop.setPrivate( Boolean.valueOf( pValue ).booleanValue() );
+                        }
                     }
 
                 } else if (localName.equals("properties")) {

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java Fri Oct  2 12:59:27 2009
@@ -49,11 +49,10 @@
      * @throws IOException
      * @throws TransformerException
      */
-    public static final void parse(File file, ContentHandler handler)
-    throws IOException, TransformerException {
+    public static final void parse(InputStream file, ContentHandler handler)
+    throws TransformerException {
         final Transformer transformer = FACTORY.newTransformer();
-        transformer.transform(new StreamSource(new FileReader(file)),
-                new SAXResult(handler));
+        transformer.transform( new StreamSource( file ), new SAXResult( handler ) );
     }
 
     public static ContentHandler getSerializer(File file)

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java Fri Oct  2 12:59:27 2009
@@ -25,8 +25,12 @@
 
 import javax.xml.transform.TransformerException;
 
-import org.apache.felix.scrplugin.om.metatype.*;
-import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.om.metatype.AttributeDefinition;
+import org.apache.felix.scrplugin.om.metatype.Designate;
+import org.apache.felix.scrplugin.om.metatype.MTObject;
+import org.apache.felix.scrplugin.om.metatype.MetaData;
+import org.apache.felix.scrplugin.om.metatype.OCD;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
@@ -65,15 +69,15 @@
     protected static final String OPTION_ELEMENT_QNAME = OPTION_ELEMENT;
 
     public static void write(MetaData metaData, File file)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         try {
             generateXML(metaData, IOUtils.getSerializer(file));
         } catch (TransformerException e) {
-            throw new MojoExecutionException("Unable to write xml to " + file, e);
+            throw new SCRDescriptorException("Unable to write xml to " + file, e);
         } catch (SAXException e) {
-            throw new MojoExecutionException("Unable to generate xml for " + file, e);
+            throw new SCRDescriptorException("Unable to generate xml for " + file, e);
         } catch (IOException e) {
-            throw new MojoExecutionException("Unable to write xml to " + file, e);
+            throw new SCRDescriptorException("Unable to write xml to " + file, e);
         }
     }