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 [1/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/

Author: fmeschbe
Date: Fri Oct  2 12:59:27 2009
New Revision: 820997

URL: http://svn.apache.org/viewvc?rev=820997&view=rev
Log:
FELIX-1684 Refactor plugin for non-Maven reuse. Everything maven specific
is in the o.a.f.scrplugin.mojo package. Everything else has no dependency
on Maven anymore.

Added:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/JavaClassDescriptorManager.java   (contents, props changed)
      - copied, changed from r820669, felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Log.java   (with props)
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorException.java   (with props)
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorFailureException.java   (with props)
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java   (contents, props changed)
      - copied, changed from r802758, felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java   (contents, props changed)
      - copied, changed from r820669, felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/IssueLog.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/PropertyHandler.java   (contents, props changed)
      - copied, changed from r820669, felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/StringUtils.java   (with props)
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenJavaClassDescriptorManager.java   (with props)
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/MavenLog.java   (with props)
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java   (with props)
Removed:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/IssueLog.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Interface.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/ModifiableJavaClassDescription.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java?rev=820997&r1=820996&r2=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java Fri Oct  2 12:59:27 2009
@@ -21,9 +21,11 @@
 import java.io.File;
 
 /**
- * Constants
+ * The <code>Constants</code> interface provides use full constants for various
+ * values used for processing SCR annotations and JavaDoc tags into SCR
+ * descriptors.
  */
-public class Constants {
+public interface Constants {
 
     /** Version 1.0 (R4.1) */
     public static final int VERSION_1_0 = 0;
@@ -31,6 +33,11 @@
     /** Version 1.1 (R4.2) */
     public static final int VERSION_1_1 = 1;
 
+    /**
+     * The name of the Bundle manifest header providing the list of service
+     * component descriptor files.
+     */
+    public static final String SERVICE_COMPONENT = "Service-Component";
 
     public static final String COMPONENT = "scr.component";
 
@@ -144,8 +151,8 @@
 
     public static final String ABSTRACT_DESCRIPTOR_FILENAME = "scrinfo.xml";
 
-    public static final String ABSTRACT_DESCRIPTOR_RELATIVE_PATH = "OSGI-INF" + File.separator + "scr-plugin" + File.separator + ABSTRACT_DESCRIPTOR_FILENAME;
-
     public static final String ABSTRACT_DESCRIPTOR_ARCHIV_PATH = "OSGI-INF/scr-plugin/" + ABSTRACT_DESCRIPTOR_FILENAME;
 
+    public static final String ABSTRACT_DESCRIPTOR_RELATIVE_PATH = ABSTRACT_DESCRIPTOR_ARCHIV_PATH.replace( '/',
+        File.separatorChar );
 }

Copied: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/JavaClassDescriptorManager.java (from r820669, felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java)
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/JavaClassDescriptorManager.java?p2=felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/JavaClassDescriptorManager.java&p1=felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java&r1=820669&r2=820997&rev=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/JavaClassDescriptorManager.java Fri Oct  2 12:59:27 2009
@@ -16,70 +16,49 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scrplugin.tags;
+package org.apache.felix.scrplugin;
 
-import java.io.*;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.*;
-import java.util.jar.*;
-
-import org.apache.felix.scrplugin.Constants;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import org.apache.felix.scrplugin.om.Component;
 import org.apache.felix.scrplugin.om.Components;
+import org.apache.felix.scrplugin.tags.ClassUtil;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
 import org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription;
 import org.apache.felix.scrplugin.tags.annotation.AnnotationTagProviderManager;
 import org.apache.felix.scrplugin.tags.cl.ClassLoaderJavaClassDescription;
 import org.apache.felix.scrplugin.tags.qdox.QDoxJavaClassDescription;
 import org.apache.felix.scrplugin.xml.ComponentDescriptorIO;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.ArtifactUtils;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.*;
-
-import com.thoughtworks.qdox.JavaDocBuilder;
 import com.thoughtworks.qdox.model.JavaClass;
 import com.thoughtworks.qdox.model.JavaSource;
 
 /**
- * <code>JavaClassDescriptorManager.java</code>...
- *
+ * The <code>JavaClassDescriptorManager</code>
  */
-public class JavaClassDescriptorManager {
-
-    protected static final String SERVICE_COMPONENT = "Service-Component";
-
-    /** The sources read by qdox. */
-    protected final JavaSource[] sources;
+public abstract class JavaClassDescriptorManager {
 
     /** The maven log. */
     protected final Log log;
 
     /** The classloader used to compile the classes. */
-    protected final ClassLoader classloader;
+    private final ClassLoader classloader;
 
     /** A cache containing the java class descriptions hashed by classname. */
-    protected final Map<String, JavaClassDescription> javaClassDescriptions = new HashMap<String, JavaClassDescription>();
-
-    /** The component definitions from other bundles hashed by classname. */
-    protected final Map<String, Component> componentDescriptions = new HashMap<String, Component>();
-
-    /** The maven project. */
-    protected final MavenProject project;
+    private final Map<String, JavaClassDescription> javaClassDescriptions = new HashMap<String, JavaClassDescription>();
 
     /**
      * Supports mapping of built-in and custom java anntoations to {@link JavaTag} implementations.
      */
-    protected final AnnotationTagProviderManager annotationTagProviderManager;
+    private final AnnotationTagProviderManager annotationTagProviderManager;
 
     /** Parse Javadocs? */
-    protected final boolean parseJavadocs;
+    private final boolean parseJavadocs;
 
     /** Process Annotations? */
-    protected final boolean processAnnotations;
+    private final boolean processAnnotations;
 
     /**
      * Construct a new manager.
@@ -89,158 +68,21 @@
      * @param excludeString The exclude information for sources
      * @param parseJavadocs Should the javadocs be parsed?
      * @param processAnnotations Should the annotations be processed?
-     * @throws MojoFailureException
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorFailureException
+     * @throws SCRDescriptorException
      */
     public JavaClassDescriptorManager(final Log          log,
-                                      final MavenProject project,
+                                      final ClassLoader        classLoader,
                                       final String[]     annotationTagProviders,
-                                      final String       excludeString,
                                       final boolean      parseJavadocs,
                                       final boolean      processAnnotations)
-    throws MojoFailureException, MojoExecutionException {
+    throws SCRDescriptorFailureException {
         this.processAnnotations = processAnnotations;
         this.parseJavadocs = parseJavadocs;
         this.log = log;
-        this.project = project;
         this.annotationTagProviderManager = new AnnotationTagProviderManager(annotationTagProviders);
-        this.classloader = this.getCompileClassLoader();
+        this.classloader = classLoader;
         ClassUtil.classLoader = this.classloader;
-
-        // get all the class sources through qdox
-        this.log.debug("Setting up QDox");
-        JavaDocBuilder builder = new JavaDocBuilder();
-        builder.getClassLibrary().addClassLoader(this.classloader);
-        @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 MojoExecutionException("Unable to scan directory.", e);
-                        } catch (IOException e) {
-                            throw new MojoExecutionException("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();
-
-        // 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(JavaClassDescriptorManager.SERVICE_COMPONENT) != null ) {
-                                    final String serviceComponent = manifest.getMainAttributes().getValue(JavaClassDescriptorManager.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 MojoExecutionException("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.
-                        try {
-                            final File scrInfoFile = this.getFile(artifact, Constants.ABSTRACT_DESCRIPTOR_ARCHIV_PATH);
-                            if ( scrInfoFile != null ) {
-                                components.addAll(this.parseServiceComponentDescriptor(artifact, scrInfoFile).getComponents());
-                            } else {
-                                this.log.debug("Artifact has no scrinfo file (it's optional): " + artifact);
-                            }
-                        } catch (IOException ioe) {
-                            throw new MojoExecutionException("Unable to get scrinfo from artifact " + artifact, ioe);
-                        }
-                    } 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);
-        }
-    }
-
-    /**
-     * 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;
     }
 
     /**
@@ -258,136 +100,48 @@
     }
 
     /**
-     * Return the project.
+     * @return Annotation tag provider manager
      */
-    public MavenProject getProject() {
-        return this.project;
+    public AnnotationTagProviderManager getAnnotationTagProviderManager() {
+        return this.annotationTagProviderManager;
     }
 
     /**
-     * @return Annotation tag provider manager
+     * Returns <code>true</code> if this class descriptor manager is parsing
+     * JavaDoc tags.
      */
-    public AnnotationTagProviderManager getAnnotationTagProviderManager() {
-        return this.annotationTagProviderManager;
+    public boolean isParseJavadocs()
+    {
+        return parseJavadocs;
     }
 
     /**
-     * Read the service component description.
-     * @param artifact
-     * @param entry
-     * @throws IOException
-     * @throws MojoExecutionException
-     */
-    protected Components readServiceComponentDescriptor(Artifact artifact, String entry) {
-        this.log.debug("Reading " + entry + " from " + artifact);
-        try {
-            final File xml = this.getFile(artifact, entry);
-            if ( xml == null ) {
-                throw new MojoExecutionException("Artifact " + artifact + " does not contain declared service component descriptor " + entry);
-            }
-            return this.parseServiceComponentDescriptor(artifact, 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 (MojoExecutionException 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);
-        }
-        return null;
+     * Returns <code>true</code> if this class descriptor manager is parsing
+     * Java 5 annotations.
+     */
+    public boolean isProcessAnnotations()
+    {
+        return processAnnotations;
     }
 
-    protected Components parseServiceComponentDescriptor(Artifact artifact, File file)
-    throws MojoExecutionException {
-        this.log.debug("Parsing " + file);
+    protected Components parseServiceComponentDescriptor(InputStream file)
+    throws SCRDescriptorException {
         final Components list = ComponentDescriptorIO.read(file);
         return list;
     }
 
     /**
-     * Get the url for the target directory
+     * Get the absolute path to the target directory where the class files are
+     * compiled to.
      */
-    protected URL getOutputDirectory()
-    throws MojoFailureException {
-        final String targetDirectory = this.getProject().getBuild().getOutputDirectory();
-        try {
-            return new File(targetDirectory).toURI().toURL();
-        } catch (IOException ioe) {
-            throw new MojoFailureException("Unable to add target directory to classloader.");
-        }
-    }
-
-    /**
-     * Create a class loader containing all compile artifacts including
-     * the target/class directory of the current project
-     * @return The class loader
-     * @throws MojoFailureException
-     */
-    protected ClassLoader getCompileClassLoader()
-    throws MojoFailureException {
-        @SuppressWarnings("unchecked")
-        List<Artifact> artifacts = this.getProject().getCompileArtifacts();
-        URL[] path = new URL[artifacts.size() + 1];
-        int i = 0;
-        for (Iterator<Artifact> ai=artifacts.iterator(); ai.hasNext(); ) {
-            Artifact a = ai.next();
-            try {
-                path[i++] = a.getFile().toURI().toURL();
-            } catch (IOException ioe) {
-                throw new MojoFailureException("Unable to get compile class loader.");
-            }
-        }
-        path[path.length - 1] = this.getOutputDirectory();
+    public abstract String getOutputDirectory();
 
-        return new URLClassLoader(path, this.getClass().getClassLoader());
-    }
-
-    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 File getFile(Artifact artifact, String path) throws IOException {
-        final int pos = path.lastIndexOf('.');
-        final String suffix = path.substring(pos + 1);
-        JarFile file = null;
-        File tmpFile = null;
-        try {
-            file = new JarFile(artifact.getFile());
-            final JarEntry entry = file.getJarEntry(path);
-            if ( entry != null ) {
-                tmpFile = File.createTempFile("scrjcdm" + artifact.getArtifactId(), suffix);
-                tmpFile.deleteOnExit();
-                final FileOutputStream fos = new FileOutputStream(tmpFile);
-                IOUtil.copy(file.getInputStream(entry), fos);
-                IOUtil.close(fos);
-                return tmpFile;
-            }
-            return null;
-        } finally {
-            if (file != null) {
-                try {
-                    file.close();
-                } catch (IOException ignore) {
-                }
-            }
-        }
-    }
 
     /**
      * Return all source descriptions of this project.
      * @return All contained java class descriptions.
      */
-    public JavaClassDescription[] getSourceDescriptions() throws MojoExecutionException {
+    public JavaClassDescription[] getSourceDescriptions() throws SCRDescriptorException {
         final JavaClass[] javaClasses = getJavaClassesFromSources();
         final JavaClassDescription[] descs = new JavaClassDescription[javaClasses.length];
         for(int i=0; i<javaClasses.length; i++) {
@@ -400,10 +154,10 @@
      * Get a java class description for the class.
      * @param className
      * @return The java class description.
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
     public JavaClassDescription getJavaClassDescription(String className)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         JavaClassDescription result = this.javaClassDescriptions.get(className);
         if ( result == null ) {
             this.log.debug("Searching description for: " + className);
@@ -423,7 +177,7 @@
                             result = new QDoxJavaClassDescription(clazz, javaClasses[index], this);
                         }
                     } catch (ClassNotFoundException e) {
-                        throw new MojoExecutionException("Unable to load class " + className);
+                        throw new SCRDescriptorException("Unable to load class " + className);
                     }
                 } else {
                     index++;
@@ -432,25 +186,31 @@
             if ( result == null ) {
                 try {
                     this.log.debug("Generating classloader description for: " + className);
-                    result = new ClassLoaderJavaClassDescription(this.classloader.loadClass(className), this.componentDescriptions.get(className), this);
+                    result = new ClassLoaderJavaClassDescription(this.classloader.loadClass(className), this.getComponentDescriptors().get(className), this);
                 } catch (ClassNotFoundException e) {
-                    throw new MojoExecutionException("Unable to load class " + className);
+                    throw new SCRDescriptorException("Unable to load class " + className);
                 }
             }
             this.javaClassDescriptions.put(className, result);
         }
         return result;
     }
-    
+
+
+    protected abstract JavaSource[] getSources() throws SCRDescriptorException;
+    protected abstract Map<String, Component> getComponentDescriptors() throws SCRDescriptorException;
+
+
     /**
      * Get a list of all {@link JavaClass} definitions four all source files (including nested/inner classes)
      * @return List of {@link JavaClass} definitions
      */
-    private JavaClass[] getJavaClassesFromSources() {
+    private JavaClass[] getJavaClassesFromSources() throws SCRDescriptorException {
+        final JavaSource[] sources = this.getSources();
         final List<JavaClass> classes = new ArrayList<JavaClass>();
-        for(int i=0; i<this.sources.length; i++) {
-            for(int j=0; j<this.sources[i].getClasses().length; j++) {
-                final JavaClass clazz = this.sources[i].getClasses()[j];
+        for(int i=0; i<sources.length; i++) {
+            for(int j=0; j<sources[i].getClasses().length; j++) {
+                final JavaClass clazz = sources[i].getClasses()[j];
                 classes.add(clazz);
                 for (int k=0; k<clazz.getNestedClasses().length; k++) {
                     final JavaClass nestedClass = clazz.getNestedClasses()[k];
@@ -460,5 +220,5 @@
         }
         return classes.toArray(new JavaClass[classes.size()]);
     }
-    
+
 }

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

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/JavaClassDescriptorManager.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/JavaClassDescriptorManager.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Log.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Log.java?rev=820997&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Log.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Log.java Fri Oct  2 12:59:27 2009
@@ -0,0 +1,167 @@
+/*
+ * 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;
+
+
+/**
+ * This interface supplies the API for providing feedback to the user from
+ * SCR descriptor generation process using whatever means is implemented. There
+ * should be no big surprises here.
+ */
+public interface Log
+{
+    /**
+     * @return true if the <b>debug</b> error level is enabled
+     */
+    boolean isDebugEnabled();
+
+
+    /**
+     * Send a message to the user in the <b>debug</b> error level.
+     *
+     * @param content
+     */
+    void debug( String content );
+
+
+    /**
+     * Send a message (and accompanying exception) to the user in the <b>debug</b> error level.
+     * <br/>
+     * The error's stacktrace will be output when this error level is enabled.
+     *
+     * @param content
+     * @param error
+     */
+    void debug( String content, Throwable error );
+
+
+    /**
+     * Send an exception to the user in the <b>debug</b> error level.
+     * <br/>
+     * The stack trace for this exception will be output when this error level is enabled.
+     *
+     * @param error
+     */
+    void debug( Throwable error );
+
+
+    /**
+     * @return true if the <b>info</b> error level is enabled
+     */
+    boolean isInfoEnabled();
+
+
+    /**
+     * Send a message to the user in the <b>info</b> error level.
+     *
+     * @param content
+     */
+    void info( String content );
+
+
+    /**
+     * Send a message (and accompanying exception) to the user in the <b>info</b> error level.
+     * <br/>
+     * The error's stacktrace will be output when this error level is enabled.
+     *
+     * @param content
+     * @param error
+     */
+    void info( String content, Throwable error );
+
+
+    /**
+     * Send an exception to the user in the <b>info</b> error level.
+     * <br/>
+     * The stack trace for this exception will be output when this error level is enabled.
+     *
+     * @param error
+     */
+    void info( Throwable error );
+
+
+    /**
+     * @return true if the <b>warn</b> error level is enabled
+     */
+    boolean isWarnEnabled();
+
+
+    /**
+     * Send a message to the user in the <b>warn</b> error level.
+     *
+     * @param content
+     */
+    void warn( String content );
+
+
+    /**
+     * Send a message (and accompanying exception) to the user in the <b>warn</b> error level.
+     * <br/>
+     * The error's stacktrace will be output when this error level is enabled.
+     *
+     * @param content
+     * @param error
+     */
+    void warn( String content, Throwable error );
+
+
+    /**
+     * Send an exception to the user in the <b>warn</b> error level.
+     * <br/>
+     * The stack trace for this exception will be output when this error level is enabled.
+     *
+     * @param error
+     */
+    void warn( Throwable error );
+
+
+    /**
+     * @return true if the <b>error</b> error level is enabled
+     */
+    boolean isErrorEnabled();
+
+
+    /**
+     * Send a message to the user in the <b>error</b> error level.
+     *
+     * @param content
+     */
+    void error( String content );
+
+
+    /**
+     * Send a message (and accompanying exception) to the user in the <b>error</b> error level.
+     * <br/>
+     * The error's stacktrace will be output when this error level is enabled.
+     *
+     * @param content
+     * @param error
+     */
+    void error( String content, Throwable error );
+
+
+    /**
+     * Send an exception to the user in the <b>error</b> error level.
+     * <br/>
+     * The stack trace for this exception will be output when this error level is enabled.
+     *
+     * @param error
+     */
+    void error( Throwable error );
+}
\ No newline at end of file

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

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

Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorException.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorException.java?rev=820997&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorException.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorException.java Fri Oct  2 12:59:27 2009
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+public class SCRDescriptorException extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+
+    public SCRDescriptorException(String message) {
+        super(message);
+    }
+
+    public SCRDescriptorException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

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

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

Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorFailureException.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorFailureException.java?rev=820997&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorFailureException.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorFailureException.java Fri Oct  2 12:59:27 2009
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+
+public class SCRDescriptorFailureException extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+
+
+    public SCRDescriptorFailureException( String message )
+    {
+        super( message );
+    }
+
+
+    public SCRDescriptorFailureException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

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

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