felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1349327 [1/2] - in /felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin: ./ description/ helper/ om/
Date Tue, 12 Jun 2012 13:30:10 GMT
Author: cziegeler
Date: Tue Jun 12 13:30:10 2012
New Revision: 1349327

URL: http://svn.apache.org/viewvc?rev=1349327&view=rev
Log:
New SCR Plugin (WiP)

Added:
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassModifier.java   (with props)
Modified:
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/AbstractDescription.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/AbstractObject.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Context.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Interface.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Property.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Reference.java

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Project.java Tue Jun 12 13:30:10 2012
@@ -31,6 +31,8 @@ public class Project {
 
     private ClassLoader classLoader;
 
+    private String classesDirectory;
+
     public Collection<Source> getSources() {
         return sources;
     }
@@ -55,4 +57,11 @@ public class Project {
         this.classLoader = classLoader;
     }
 
+    public String getClassesDirectory() {
+        return this.classesDirectory;
+    }
+
+    public void setClassesDirectory(final String dir) {
+        this.classesDirectory = dir;
+    }
 }

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java Tue Jun 12 13:30:10 2012
@@ -19,29 +19,21 @@
 package org.apache.felix.scrplugin;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
 
 import org.apache.felix.scrplugin.description.ClassDescription;
 import org.apache.felix.scrplugin.description.ComponentDescription;
 import org.apache.felix.scrplugin.description.PropertyDescription;
 import org.apache.felix.scrplugin.description.PropertyType;
+import org.apache.felix.scrplugin.description.ReferenceCardinality;
 import org.apache.felix.scrplugin.description.ReferenceDescription;
 import org.apache.felix.scrplugin.description.ServiceDescription;
 import org.apache.felix.scrplugin.description.SpecVersion;
 import org.apache.felix.scrplugin.helper.AnnotationProcessorManager;
+import org.apache.felix.scrplugin.helper.ClassModifier;
 import org.apache.felix.scrplugin.helper.ClassScanner;
 import org.apache.felix.scrplugin.helper.IssueLog;
 import org.apache.felix.scrplugin.helper.StringUtils;
@@ -88,6 +80,9 @@ public class SCRDescriptorGenerator {
     /** The options. */
     private Options options = new Options();
 
+    /** The annotation scanner. */
+    private ClassScanner scanner;
+
     /**
      * Create an instance of this generator using the given {@link Log} instance
      * of logging.
@@ -157,6 +152,10 @@ public class SCRDescriptorGenerator {
         if (this.project == null) {
             throw new SCRDescriptorFailureException("Project has not been set!");
         }
+        if (this.options == null) {
+            // use default options
+            this.options = new Options();
+        }
 
         this.logger.debug("Starting SCRDescriptorMojo....");
         this.logger.debug("..generating accessors: " + this.options.isGenerateAccessors());
@@ -177,14 +176,8 @@ public class SCRDescriptorGenerator {
                         this.project.getClassLoader());
 
         // create the class scanner - and start scanning
-        final ClassScanner scanner = new ClassScanner();
-        final List<ClassDescription> scannedDescriptions = scanner.execute(logger, project, aProcessor);
-
-        // scan descriptions from dependencies and add scanned descriptions
-        final Map<String, ClassDescription> allDescriptions = this.getComponentDescriptors(iLog);
-        for(final ClassDescription cd : scannedDescriptions) {
-            allDescriptions.put(cd.getDescribedClass().getName(), cd);
-        }
+        this.scanner = new ClassScanner(logger, iLog, project, aProcessor);
+        final List<ClassDescription> scannedDescriptions = scanner.scanSources();
 
         // setup metadata
         final MetaData metaData = new MetaData();
@@ -234,6 +227,13 @@ public class SCRDescriptorGenerator {
         for (final Component comp : processedComponents) {
             final int errorCount = iLog.getNumberOfErrors();
 
+            final Context ctx = new Context();
+            ctx.setClassDescription(comp.getClassDescription());
+            ctx.setIssueLog(iLog);
+            ctx.setProject(project);
+            ctx.setSpecVersion(specVersion);
+            ctx.setOptions(options);
+
             if ( this.options.isGenerateAccessors() ) {
                 // before we can validate we should check the references for bind/unbind method
                 // in order to create them if possible
@@ -242,43 +242,38 @@ public class SCRDescriptorGenerator {
                     // if this is a field with a single cardinality,
                     // we look for the bind/unbind methods
                     // and create them if they are not availabe
-                    if (!ref.isLookupStrategy()) {
-                    /*
-                     * if (ref.getJavaTag().getField() != null
-                     * && comp.getJavaClassDescription() instanceof ModifiableJavaClassDescription) {
-                     * if (ref.getCardinality().equals("0..1") || ref.getCardinality().equals("1..1")) {
-                     * final String bindValue = ref.getBind();
-                     * final String unbindValue = ref.getUnbind();
-                     * final String name = ref.getName();
-                     * final String type = ref.getInterfacename();
-                     *
-                     * boolean createBind = false;
-                     * boolean createUnbind = false;
-                     * // Only create method if no bind name has been specified
-                     * if (bindValue == null && ref.findMethod(specVersion, "bind") == null) {
-                     * // create bind method
-                     * createBind = true;
-                     * }
-                     * if (unbindValue == null && ref.findMethod(specVersion, "unbind") == null) {
-                     * // create unbind method
-                     * createUnbind = true;
-                     * }
-                     * if (createBind || createUnbind) {
-                     * ((ModifiableJavaClassDescription) comp.getJavaClassDescription()).addMethods(name, type,
-                     * createBind, createUnbind);
-                     * }
-                     * }
-                     * }
-                     */
+                    if (!ref.isLookupStrategy() && ref.getField() != null
+                        && (ref.getCardinality() == ReferenceCardinality.OPTIONAL_UNARY || ref.getCardinality() == ReferenceCardinality.MANDATORY_UNARY)) {
+
+                            final String bindValue = ref.getBind();
+                        final String unbindValue = ref.getUnbind();
+                        final String name = ref.getName();
+                        final String type = ref.getInterfacename();
+
+                        boolean createBind = false;
+                        boolean createUnbind = false;
+
+                        // Only create method if no bind name has been specified
+                        if (bindValue == null && ref.findMethod(ctx, "bind") == null) {
+                            // create bind method
+                            createBind = true;
+                        }
+                        if (unbindValue == null && ref.findMethod(ctx, "unbind") == null) {
+                            // create unbind method
+                            createUnbind = true;
+                        }
+                        if (createBind || createUnbind) {
+                            ClassModifier.addMethods(comp.getClassDescription().getDescribedClass().getName(),
+                                            name,
+                                            ref.getField().getName(),
+                                            type,
+                                            createBind,
+                                            createUnbind,
+                                            this.project.getClassesDirectory());
+                        }
                     }
                 }
             }
-            final Context ctx = new Context();
-            ctx.setClassDescription(comp.getClassDescription());
-            ctx.setIssueLog(iLog);
-            ctx.setProject(project);
-            ctx.setSpecVersion(specVersion);
-
             comp.validate(ctx);
 
             // ignore component if it has errors
@@ -357,9 +352,9 @@ public class SCRDescriptorGenerator {
     private Component createComponent(final ClassDescription desc,
                     final MetaData metaData,
                     final IssueLog iLog)
-    throws SCRDescriptorException {
+    throws SCRDescriptorException, SCRDescriptorFailureException {
         final ComponentDescription componentDesc = desc.getDescription(ComponentDescription.class);
-        final Component comp = new Component(desc, componentDesc.getAnnotation().getName(), desc.getSource());
+        final Component comp = new Component(desc, componentDesc.getAnnotation(), desc.getSource());
 
         comp.setName(componentDesc.getName());
         comp.setConfigurationPolicy(componentDesc.getConfigurationPolicy());
@@ -425,21 +420,42 @@ public class SCRDescriptorGenerator {
     /**
      * Process service directives
      */
-    private void processServices(final ClassDescription desc, final Component component) {
-        // TODO : inherit
-        final ServiceDescription serviceDesc = desc.getDescription(ServiceDescription.class);
-        if ( serviceDesc != null ) {
-            final Service service = new Service();
-            service.setServiceFactory(serviceDesc.isServiceFactory());
-            for(final String className : serviceDesc.getInterfaces()) {
-                final Interface interf = new Interface();
-                interf.setInterfaceName(className);
-                service.addInterface(interf);
+    private void processServices(final ClassDescription desc, final Component component)
+    throws SCRDescriptorException, SCRDescriptorFailureException {
+        Service service = null;
+        ClassDescription current = desc;
+        boolean inherit;
+        do {
+            final ComponentDescription cd = current.getDescription(ComponentDescription.class);
+            inherit = (cd == null ? true : cd.isInherit());
+
+            final ServiceDescription serviceDesc = current.getDescription(ServiceDescription.class);
+            if ( serviceDesc != null ) {
+                if ( service == null ) {
+                    service = new Service();
+                    service.setServiceFactory(false);
+                    component.setService(service);
+                }
+                if ( serviceDesc.isServiceFactory() ) {
+                    service.setServiceFactory(true);
+                }
+                for(final String className : serviceDesc.getInterfaces()) {
+                    final Interface interf = new Interface(serviceDesc.getAnnotation(), desc.getSource());
+                    interf.setInterfaceName(className);
+                    service.addInterface(interf);
+                }
             }
-            component.setService(service);
-        }
+            if ( !inherit || current.getDescribedClass().getSuperclass() == null ) {
+                current = null;
+            } else {
+                current = this.scanner.getDescription(current.getDescribedClass().getSuperclass());
+            }
+        } while ( inherit && current != null);
     }
 
+    /***
+     * Check if the component has a property with the name
+     */
     private boolean hasProperty(final Component component, final String name) {
         boolean found = false;
         final Iterator<Property> iter = component.getProperties().iterator();
@@ -456,22 +472,34 @@ public class SCRDescriptorGenerator {
     private void processProperties(final ClassDescription desc,
                     final ComponentDescription componentDesc,
                     final Component component,
-                    final OCD ocd) {
-        // TODO : inherit
-        for(final PropertyDescription pd : desc.getDescriptions(PropertyDescription.class)) {
-            final Property prop = new Property(pd.getAnnotation().getName(), desc.getSource());
-            component.addProperty(prop);
-            prop.setName(pd.getName());
-            prop.setType(pd.getType());
-            if ( pd.getValue() != null ) {
-                prop.setValue(pd.getValue());
+                    final OCD ocd) throws SCRDescriptorException, SCRDescriptorFailureException {
+        ClassDescription current = desc;
+        boolean inherit;
+        do {
+            final ComponentDescription cd = current.getDescription(ComponentDescription.class);
+            inherit = (cd == null ? true : cd.isInherit());
+
+            for(final PropertyDescription pd : current.getDescriptions(PropertyDescription.class)) {
+                final Property prop = new Property(pd.getAnnotation(), current.getSource());
+                component.addProperty(prop);
+                prop.setName(pd.getName());
+                prop.setType(pd.getType());
+                if ( pd.getValue() != null ) {
+                    prop.setValue(pd.getValue());
+                } else {
+                    prop.setMultiValue(pd.getMultiValue());
+                }
+            }
+            if ( !inherit || current.getDescribedClass().getSuperclass() == null ) {
+                current = null;
             } else {
-                prop.setMultiValue(pd.getMultiValue());
+                current = this.scanner.getDescription(current.getDescribedClass().getSuperclass());
             }
-        }
+        } while ( inherit && current != null);
+
         // PID handling
         if ( componentDesc.isCreatePid() && !hasProperty(component, org.osgi.framework.Constants.SERVICE_PID)) {
-            final Property pid = new Property();
+            final Property pid = new Property(null, "scr-generator");
             component.addProperty( pid );
             pid.setName( org.osgi.framework.Constants.SERVICE_PID );
             pid.setValue( component.getName() );
@@ -494,7 +522,7 @@ public class SCRDescriptorGenerator {
                 // check if the service already provides this property
                 if ( value != null && !hasProperty(component, propName) ) {
 
-                    final Property p = new Property();
+                    final Property p = new Property(null, "scr-generator");
                     p.setName(propName);
                     p.setValue(value);
                     p.setType(PropertyType.String);
@@ -507,253 +535,38 @@ public class SCRDescriptorGenerator {
     /**
      * Process reference directives
      */
-    private void processReferences(final ClassDescription desc, final Component component) {
-        // TODO : inherit
-        for(final ReferenceDescription rd : desc.getDescriptions(ReferenceDescription.class)) {
-            final Reference ref = new Reference(rd.getAnnotation().getName(), desc.getSource());
-            component.addReference(ref);
-            ref.setName(rd.getName());
-            ref.setInterfacename(rd.getInterfaceName());
-            ref.setCardinality(rd.getCardinality());
-            ref.setPolicy(rd.getPolicy());
-            ref.setStrategy(rd.getStrategy());
-            ref.setTarget(rd.getTarget());
-            if ( rd.getBind() != null ) {
-                ref.setBind(rd.getBind().getName());
-            }
-            if ( rd.getUnbind() != null ) {
-                ref.setUnbind(rd.getUnbind().getName());
-            }
-            if ( rd.getUpdated() != null ) {
-                ref.setUpdated(rd.getUpdated().getName());
-            }
-        }
-    }
-
-    /**
-     * The name of the Bundle manifest header providing the list of service
-     * component descriptor files.
-     */
-    private static final String SERVICE_COMPONENT = "Service-Component";
-
-    private static final String ABSTRACT_DESCRIPTOR_FILENAME = "scrinfo.xml";
-
-    private static final String ABSTRACT_DESCRIPTOR_ARCHIV_PATH = "OSGI-INF/scr-plugin/" + ABSTRACT_DESCRIPTOR_FILENAME;
-
-    /**
-     * Returns a map of component descriptors which may be extended by the java
-     * sources.
-     * <p>
-     * This method calls the {@link #getDependencies()} method and checks for
-     * any Service-Component descriptors in the returned files.
-     * <p>
-     * This method may be overwritten by extensions of this class.
-     *
-     * @throws SCRDescriptorException May be thrown if an error occurrs
-     *             gethering the component descriptors.
-     */
-    private Map<String, ClassDescription> getComponentDescriptors(final IssueLog iLog)
-    throws SCRDescriptorException {
-        final Map<String, ClassDescription> descriptions = new HashMap<String, ClassDescription>();
-
-        final Collection<File> dependencies = this.project.getDependencies();
-        for ( final File artifact : dependencies ) {
-            this.logger.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( SERVICE_COMPONENT ) != null ) {
-                        final String serviceComponent = manifest.getMainAttributes().getValue(SERVICE_COMPONENT );
-                        this.logger.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 List<ClassDescription> c = this.readServiceComponentDescriptor( iLog, artifact, entry );
-                                if ( c != null ) {
-                                    for(final ClassDescription cd : c) {
-                                        descriptions.put(cd.getDescribedClass().getName(), cd);
-                                    }
-                                }
-                            }
-                        }
-                    } else {
-                        this.logger.debug( "Artifact has no service component entry in manifest " + artifact );
-                    }
-                } else {
-                    this.logger.debug( "Unable to get manifest from artifact " + artifact );
+    private void processReferences(final ClassDescription desc, final Component component) throws SCRDescriptorException, SCRDescriptorFailureException {
+        ClassDescription current = desc;
+        boolean inherit;
+        do {
+            final ComponentDescription cd = current.getDescription(ComponentDescription.class);
+            inherit = (cd == null ? true : cd.isInherit());
+
+            for(final ReferenceDescription rd : current.getDescriptions(ReferenceDescription.class)) {
+                final Reference ref = new Reference(rd.getAnnotation(), current.getSource());
+                component.addReference(ref);
+                ref.setName(rd.getName());
+                ref.setInterfacename(rd.getInterfaceName());
+                ref.setCardinality(rd.getCardinality());
+                ref.setPolicy(rd.getPolicy());
+                ref.setStrategy(rd.getStrategy());
+                ref.setTarget(rd.getTarget());
+                ref.setField(rd.getField());
+                if ( rd.getBind() != null ) {
+                    ref.setBind(rd.getBind().getName());
                 }
-            } catch ( IOException ioe ) {
-                throw new SCRDescriptorException( "Unable to get manifest from artifact", artifact.toString(), 0,
-                    ioe );
-            }
-            this.logger.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, ABSTRACT_DESCRIPTOR_ARCHIV_PATH );
-                if ( scrInfoFile != null ) {
-                    final List<ClassDescription> c =  this.parseServiceComponentDescriptor( iLog, scrInfoFile, artifact.toString() + ':' + ABSTRACT_DESCRIPTOR_ARCHIV_PATH);
-                    if ( c != null ) {
-                        for(final ClassDescription cd : c) {
-                            descriptions.put(cd.getDescribedClass().getName(), cd);
-                        }
-                    }
-                } else {
-                    this.logger.debug( "Artifact has no scrinfo file (it's optional): " + artifact );
+                if ( rd.getUnbind() != null ) {
+                    ref.setUnbind(rd.getUnbind().getName());
                 }
-            } catch ( final IOException ioe ) {
-                throw new SCRDescriptorException( "Unable to get scrinfo from artifact", artifact.toString(), 0,
-                    ioe );
-            } finally {
-                if ( scrInfoFile != null ) {
-                    try { scrInfoFile.close(); } catch ( final IOException ignore ) {}
+                if ( rd.getUpdated() != null ) {
+                    ref.setUpdated(rd.getUpdated().getName());
                 }
             }
-
-        }
-
-        return descriptions;
-    }
-
-    /**
-     * Parses the descriptors read from the given input stream. This method may
-     * be called by the {@link #getComponentDescriptors()} method to parse the
-     * descriptors gathered in an implementation dependent way.
-     *
-     * @throws SCRDescriptorException If an error occurrs reading the
-     *             descriptors from the stream.
-     */
-    private List<ClassDescription> parseServiceComponentDescriptor(final IssueLog iLog,
-                    final InputStream file, final String location )
-    throws SCRDescriptorException {
-        return ComponentDescriptorIO.read( file, this.project.getClassLoader(), iLog, location );
-    }
-
-    /**
-     * Read the service component description.
-     *
-     * @param artifact
-     * @param entry
-     * @throws IOException
-     * @throws SCRDescriptorException
-     */
-    private List<ClassDescription> readServiceComponentDescriptor( final IssueLog iLog, final File artifactFile, String entry ) {
-        this.logger.debug( "Reading " + entry + " from " + artifactFile );
-        InputStream xml = null;
-        try {
-            xml = this.getFile( artifactFile, entry );
-            if ( xml == null ) {
-                throw new SCRDescriptorException( "Entry " + entry + " not contained in JAR File ", artifactFile.toString(),
-                    0 );
-            }
-            return this.parseServiceComponentDescriptor( iLog, xml, artifactFile.toString() + ':' + entry );
-        } catch ( final IOException mee ) {
-            this.logger.warn( "Unable to read SCR descriptor file from JAR File " + artifactFile + " at " + entry );
-            this.logger.debug( "Exception occurred during reading: " + mee.getMessage(), mee );
-        } catch ( final SCRDescriptorException mee ) {
-            this.logger.warn( "Unable to read SCR descriptor file from JAR File " + artifactFile + " at " + entry );
-            this.logger.debug( "Exception occurred during reading: " + mee.getMessage(), mee );
-        } finally {
-            if ( xml != null ) {
-                try { xml.close(); } catch (final IOException ignore) {}
-            }
-        }
-
-        return null;
-    }
-
-
-    /**
-     * Get the manifest from the artifact.
-     * The artifact can either be a jar or a directory.
-     */
-    private Manifest getManifest( final File artifact ) throws IOException {
-        if ( artifact.isDirectory() ) {
-            // this is maybe a classes directory, try to read manifest file directly
-            final File dir = new File(artifact, "META-INF");
-            if ( !dir.exists() || !dir.isDirectory() ) {
-                return null;
-            }
-            final File mf = new File(dir, "MANIFEST.MF");
-            if ( !mf.exists() || !mf.isFile() ) {
-                return null;
-            }
-            final InputStream is = new FileInputStream(mf);
-            try {
-                return new Manifest(is);
-            } finally {
-                try { is.close(); } catch (final IOException ignore) { }
-            }
-        }
-        JarFile file = null;
-        try {
-            file = new JarFile( artifact );
-            return file.getManifest();
-        } finally {
-            if ( file != null ) {
-                try { file.close(); } catch ( final IOException ignore ) {}
-            }
-        }
-    }
-
-    private InputStream getFile( final File artifactFile, final String path ) throws IOException {
-        if ( artifactFile.isDirectory() ) {
-            final String filePath = path.replace('/', File.separatorChar).replace('\\', File.separatorChar);
-            final File file = new File(artifactFile, filePath);
-            if ( file.exists() && file.isFile() ) {
-                return new FileInputStream(file);
-            }
-            return null;
-        }
-        JarFile file = null;
-        try {
-            file = new JarFile( artifactFile );
-            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 ( final 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 ( final IOException ioe ) {
-                // ignore
-            }
-            jarFile.close();
-        }
-
-
-        @Override
-        protected void finalize() throws Throwable {
-            try {
-                close();
-            } finally {
-                super.finalize();
+            if ( !inherit || current.getDescribedClass().getSuperclass() == null ) {
+                current = null;
+            } else {
+                current = this.scanner.getDescription(current.getDescribedClass().getSuperclass());
             }
-        }
+        } while ( inherit && current != null);
     }
 }

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/AbstractDescription.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/AbstractDescription.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/AbstractDescription.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/AbstractDescription.java Tue Jun 12 13:30:10 2012
@@ -23,15 +23,29 @@ import org.apache.felix.scrplugin.scanne
 
 /**
  * <code>AbstractDescription</code> is the base class for all descriptions.
+ *
+ * @see ComponentDescription
+ * @see ServiceDescription
+ * @see ReferenceDescription
+ * @see PropertyDescription
  */
 public abstract class AbstractDescription {
 
+    /** The corresponding annotation from the class file. */
     protected final ScannedAnnotation annotation;
 
+    /**
+     * Create a new abstract description
+     * @param annotation The corresponding annotation.
+     */
     public AbstractDescription(final ScannedAnnotation annotation) {
         this.annotation = annotation;
     }
 
+    /**
+     * Get the annotation.
+     * @return The annotation or <code>null</code>
+     */
     public ScannedAnnotation getAnnotation() {
         return this.annotation;
     }

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java Tue Jun 12 13:30:10 2012
@@ -22,33 +22,64 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * <code>ClassDescription</code> is a described class.
+ * A <code>ClassDescription</code> is describing the found annotations
+ * of a class.
+ * Its basically used as a wrapper to hold all the various annotations
+ * found in a class. This description only contains the annotations
+ * found in the current class, but not in any superclass.
+ * The annotations are available as descriptions.
+ * @see ComponentDescription
+ * @see ServiceDescription
+ * @see ReferenceDescription
+ * @see PropertyDescription
  */
 public class ClassDescription {
 
+    /** All descriptions. */
     final List<AbstractDescription> descriptions = new ArrayList<AbstractDescription>();
 
+    /** The corresponding class. */
     private final Class<?> describedClass;
 
+    /** The source (file) of the class or any other location information. */
     private final String source;
 
+    /**
+     * Create a new class description
+     */
     public ClassDescription(final Class<?> describedClass, final String source) {
         this.describedClass = describedClass;
         this.source = source;
     }
 
+    /**
+     * Get the associated class.
+     * @return The associated class.
+     */
     public Class<?> getDescribedClass() {
         return this.describedClass;
     }
 
+    /**
+     * Get the location information like the source file etc.
+     * @return The location information.
+     */
     public String getSource() {
         return this.source;
     }
 
+    /**
+     * Add a new description
+     */
     public void add(final AbstractDescription desc) {
         this.descriptions.add(desc);
     }
 
+    /**
+     * Get all descriptions of that type.
+     * @param descType The description class.
+     * @return A list of found descriptions or the empty array.
+     */
     @SuppressWarnings("unchecked")
     public <T extends AbstractDescription> List<T> getDescriptions(final Class<T> descType) {
         final List<T> result = new ArrayList<T>();
@@ -60,6 +91,11 @@ public class ClassDescription {
         return result;
     }
 
+    /**
+     * Get the first description of that type
+     * @param descType The description class
+     * @return THe first description or <code>null</code>
+     */
     public <T extends AbstractDescription> T getDescription(final Class<T> descType) {
         final List<T> result = this.getDescriptions(descType);
         if ( result.size() > 0 ) {

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java Tue Jun 12 13:30:10 2012
@@ -23,8 +23,27 @@ import java.lang.reflect.Field;
 import org.apache.felix.scrplugin.scanner.ScannedAnnotation;
 
 /**
- * <code>Reference.java</code>...
+ * A <code>ReferenceDescription</code> describes a reference
+ * from a component to another service.
  *
+ * In general all fields should be set by an annocation scanner,
+ * no default values should be assumed for these fields:
+ * <ul>
+ * <li>name</li>
+ * <li>interfaceName</li>
+ * <li>target</li>
+ * <li>cardinality</li>
+ * <li>policy</li>
+ * <li>strategy</li>
+ * <li>field</li>
+ * </ul>
+ *
+ * These values have the following default values:
+ * <ul>
+ * <li>bind : null</li>
+ * <li>unbind : null</li>
+ * <li>updated : null</li>
+ * </ul>
  */
 public class ReferenceDescription extends AbstractDescription {
 
@@ -33,14 +52,14 @@ public class ReferenceDescription extend
     private String target;
     private ReferenceCardinality cardinality;
     private ReferencePolicy policy;
-    private MethodDescription bind;
-    private MethodDescription unbind;
-    private MethodDescription updated;
-
     private ReferenceStrategy strategy;
 
     private Field field;
 
+    private MethodDescription bind;
+    private MethodDescription unbind;
+    private MethodDescription updated;
+
     public ReferenceDescription(final ScannedAnnotation annotation) {
         super(annotation);
     }

Added: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassModifier.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassModifier.java?rev=1349327&view=auto
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassModifier.java (added)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassModifier.java Tue Jun 12 13:30:10 2012
@@ -0,0 +1,98 @@
+package org.apache.felix.scrplugin.helper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+import org.apache.felix.scrplugin.SCRDescriptorException;
+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;
+
+public class ClassModifier {
+
+    public static void addMethods(final String className,
+                           final String referenceName,
+                           final String fieldName,
+                           final String typeName,
+                           final boolean createBind,
+                           final boolean createUnbind,
+                           final String outputDirectory)
+    throws SCRDescriptorException {
+        // now do byte code manipulation
+        final String fileName = outputDirectory + File.separatorChar +  className.replace('.', File.separatorChar) + ".class";
+        final ClassNode cn = new ClassNode();
+        try {
+            final ClassReader reader = new ClassReader(new FileInputStream(fileName));
+            reader.accept(cn, 0);
+
+            final ClassWriter writer = new ClassWriter(0);
+
+            // remove existing implementation von previous builds
+            final ClassAdapter adapter = new ClassAdapter(writer) {
+
+                protected final String bindMethodName = "bind" + referenceName.substring(0, 1).toUpperCase() + referenceName.substring(1);
+                protected final String unbindMethodName = "unbind" + referenceName.substring(0, 1).toUpperCase() + referenceName.substring(1);
+                protected final String description = "(L" + typeName.replace('.', '/') + ";)V";
+
+                /**
+                 * @see org.objectweb.asm.ClassAdapter#visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
+                 */
+                public MethodVisitor visitMethod(final int access,
+                                final String name,
+                                final String desc,
+                                final String signature,
+                                final String[] exceptions) {
+                    if ( createBind && name.equals(bindMethodName) && description.equals(desc) ) {
+                        return null;
+                    }
+                    if ( createUnbind && name.equals(unbindMethodName)  && description.equals(desc) ) {
+                        return null;
+                    }
+                    return super.visitMethod(access, name, desc, signature, exceptions);
+                }
+
+            };
+
+            cn.accept(adapter);
+            if ( createBind ) {
+                createMethod(writer, className, referenceName, fieldName, typeName, true);
+            }
+            if ( createUnbind ) {
+                createMethod(writer, className, referenceName, fieldName, typeName, false);
+            }
+
+            final FileOutputStream fos = new FileOutputStream(fileName);
+            fos.write(writer.toByteArray());
+            fos.close();
+        } catch (final Exception e) {
+            throw new SCRDescriptorException("Unable to add methods to " + className, typeName, 0, e);
+        }
+    }
+
+    private static void createMethod(final ClassWriter cw, final String className, final String referenceName, final String fieldName, final String typeName, boolean bind) {
+        final org.objectweb.asm.Type type = org.objectweb.asm.Type.getType("L" + typeName.replace('.', '/') + ";");
+        final String methodName = (bind ? "" : "un") + "bind" + referenceName.substring(0, 1).toUpperCase() + referenceName.substring(1);
+        MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, methodName, "(" + type.toString() + ")V", null, null);
+        mv.visitVarInsn(Opcodes.ALOAD, 0);
+        if ( bind ) {
+            mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), 1);
+            mv.visitFieldInsn(Opcodes.PUTFIELD, className.replace('.', '/'), fieldName, type.toString());
+        } else {
+            mv.visitFieldInsn(Opcodes.GETFIELD, className.replace('.', '/'), fieldName, type.toString());
+            mv.visitVarInsn(Opcodes.ALOAD, 1);
+            final Label jmpLabel = new Label();
+            mv.visitJumpInsn(Opcodes.IF_ACMPNE, jmpLabel);
+            mv.visitVarInsn(Opcodes.ALOAD, 0);
+            mv.visitInsn(Opcodes.ACONST_NULL);
+            mv.visitFieldInsn(Opcodes.PUTFIELD, className.replace('.', '/'), fieldName, type.toString());
+            mv.visitLabel(jmpLabel);
+        }
+        mv.visitInsn(Opcodes.RETURN);
+        mv.visitMaxs(2, 2);
+    }
+}

Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassModifier.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassModifier.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassModifier.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java Tue Jun 12 13:30:10 2012
@@ -22,16 +22,24 @@ import static org.objectweb.asm.ClassRea
 import static org.objectweb.asm.ClassReader.SKIP_DEBUG;
 import static org.objectweb.asm.ClassReader.SKIP_FRAMES;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Array;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
 
 import org.apache.felix.scrplugin.AnnotationProcessor;
 import org.apache.felix.scrplugin.Log;
@@ -46,6 +54,7 @@ import org.apache.felix.scrplugin.scanne
 import org.apache.felix.scrplugin.scanner.ScannedAnnotation;
 import org.apache.felix.scrplugin.scanner.ScannedClass;
 import org.apache.felix.scrplugin.scanner.Source;
+import org.apache.felix.scrplugin.xml.ComponentDescriptorIO;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.Type;
 import org.objectweb.asm.tree.AnnotationNode;
@@ -60,17 +69,59 @@ import org.objectweb.asm.tree.MethodNode
 public class ClassScanner {
 
     /**
-     * Scan all class files for annotations and process them.
-     * 
-     * @param log
-     *            The log to use
-     * @param project
-     *            The project environment
-     * @param aProcessor
-     *            The annotation processor
+     * The name of the Bundle manifest header providing the list of service
+     * component descriptor files.
      */
-    public List<ClassDescription> execute(final Log log, final Project project, final AnnotationProcessor aProcessor)
-                    throws SCRDescriptorException, SCRDescriptorFailureException {
+    private static final String SERVICE_COMPONENT = "Service-Component";
+
+    /**
+     * The name of the file containing the scanned information from older
+     * SCR generator versions.
+     */
+    private static final String ABSTRACT_DESCRIPTOR_ARCHIV_PATH = "OSGI-INF/scr-plugin/scrinfo.xml";
+
+    /** Source for all generated descriptions. */
+    private static final String GENERATED = "<generated>";
+
+    /** Component descriptions loaded from dependencies*/
+    private Map<String, ClassDescription> loadedDependencies;
+
+    /** All used component descriptions. */
+    private final Map<String, ClassDescription> allDescriptions;
+
+    /** The log. */
+    private final Log log;
+
+    /** The issue log. */
+    private final IssueLog iLog;
+
+    /** The project. */
+    private final Project project;
+
+    /** The annotation processor. */
+    private final AnnotationProcessor aProcessor;
+
+    /**
+     * Create a new scanner.
+     */
+    public ClassScanner(final Log log,
+                    final IssueLog iLog,
+                    final Project project,
+                    final AnnotationProcessor aProcessor) {
+        // create map for all descriptions and dummy entry for Object
+        this.allDescriptions = new HashMap<String, ClassDescription>();
+        allDescriptions.put(Object.class.getName(), new ClassDescription(Object.class, GENERATED));
+        this.log = log;
+        this.iLog = iLog;
+        this.project = project;
+        this.aProcessor = aProcessor;
+    }
+
+    /**
+     * Scan all source class files for annotations and process them.
+     */
+    public List<ClassDescription> scanSources()
+    throws SCRDescriptorException, SCRDescriptorFailureException {
         final List<ClassDescription> result = new ArrayList<ClassDescription>();
 
         for (final Source src : project.getSources()) {
@@ -79,40 +130,58 @@ public class ClassScanner {
             try {
                 // load the class
                 final Class<?> annotatedClass = project.getClassLoader().loadClass(src.getClassName());
-                // get the class file for ASM
-                final String pathToClassFile = src.getClassName().replace('.', '/') + ".class";
-                final InputStream input = project.getClassLoader().getResourceAsStream(pathToClassFile);
-                final ClassReader classReader;
-                try {
-                    classReader = new ClassReader(input);
-                } finally {
-                    input.close();
-                }
-                final ClassNode classNode = new ClassNode();
-                classReader.accept(classNode, SKIP_CODE | SKIP_DEBUG | SKIP_FRAMES);
 
-                // create descriptions
-                final List<ScannedAnnotation> descriptions = extractAnnotation(classNode, annotatedClass);
-                if (descriptions.size() > 0) {
-                    // process descriptions
-                    final ClassDescription desc = new ClassDescription(annotatedClass, src.getFile().toString());
-                    aProcessor.process(new ScannedClass(descriptions, annotatedClass), desc);
-
-                    if (desc.getDescriptions(ComponentDescription.class).size() > 0) {
-                        log.debug("Found component description " + desc + " in " + src.getClassName());
-                        result.add(desc);
-                    }
+                final ClassDescription desc = this.processClass(annotatedClass, src.getFile().toString());
+                if (desc != null) {
+                    result.add(desc);
+                    this.allDescriptions.put(annotatedClass.getName(), desc);
+                } else {
+                    this.allDescriptions.put(annotatedClass.getName(), new ClassDescription(annotatedClass, GENERATED));
                 }
             } catch (final ClassNotFoundException cnfe) {
                 throw new SCRDescriptorFailureException("Unable to load compiled class: " + src.getClassName(), cnfe);
-            } catch (final IOException ioe) {
-                throw new SCRDescriptorFailureException("Unable to scan class files: " + src.getClassName(), ioe);
             }
         }
         return result;
     }
 
     /**
+     * Scan a single class.
+     */
+    private ClassDescription processClass(final Class<?> annotatedClass, final String location)
+    throws SCRDescriptorFailureException, SCRDescriptorException {
+        try {
+            // get the class file for ASM
+            final String pathToClassFile = annotatedClass.getName().replace('.', '/') + ".class";
+            final InputStream input = project.getClassLoader().getResourceAsStream(pathToClassFile);
+            final ClassReader classReader;
+            try {
+                classReader = new ClassReader(input);
+            } finally {
+                input.close();
+            }
+            final ClassNode classNode = new ClassNode();
+            classReader.accept(classNode, SKIP_CODE | SKIP_DEBUG | SKIP_FRAMES);
+
+            // create descriptions
+            final List<ScannedAnnotation> descriptions = extractAnnotation(classNode, annotatedClass);
+            if (descriptions.size() > 0) {
+                // process descriptions
+                final ClassDescription desc = new ClassDescription(annotatedClass, location);
+                aProcessor.process(new ScannedClass(descriptions, annotatedClass), desc);
+
+                if (desc.getDescriptions(ComponentDescription.class).size() > 0) {
+                    log.debug("Found component description " + desc + " in " + annotatedClass.getName());
+                    return desc;
+                }
+            }
+        } catch (final IOException ioe) {
+            throw new SCRDescriptorFailureException("Unable to scan class files: " + annotatedClass.getName(), ioe);
+        }
+        return null;
+    }
+
+    /**
      * Extract annotations
      */
     private final List<ScannedAnnotation> extractAnnotation(final ClassNode classNode, final Class<?> annotatedClass)
@@ -188,7 +257,6 @@ public class ClassScanner {
                     @SuppressWarnings("unchecked")
                     final List<AnnotationNode> annos = field.invisibleAnnotations;
                     if (annos != null) {
-                        // TODO - throw if not found
                         final String name = field.name;
                         final Field[] allFields = annotatedClass.getDeclaredFields();
                         Field found = null;
@@ -197,6 +265,10 @@ public class ClassScanner {
                                 found = f;
                             }
                         }
+                        if (found == null) {
+                            throw new SCRDescriptorException("Annotated field " + name + " not found.",
+                                            annotatedClass.getName(), -1);
+                        }
                         for (final AnnotationNode annotation : annos) {
                             parseAnnotation(descriptions, annotation, found);
                         }
@@ -278,4 +350,248 @@ public class ClassScanner {
         }
         descriptions.add(a);
     }
+
+    /**
+     * Get a description for the class
+     */
+    public ClassDescription getDescription(final Class<?> clazz)
+    throws SCRDescriptorException, SCRDescriptorFailureException {
+        final String name = clazz.getName();
+        ClassDescription result = this.allDescriptions.get(name);
+        if ( result == null ) {
+            // use scanner first
+            result = this.processClass(clazz, GENERATED);
+
+            if ( result == null ) {
+                // now check loaded dependencies
+                result = this.getComponentDescriptors().get(name);
+            }
+
+            // not found, create dummy
+            if ( result == null ) {
+                result = new ClassDescription(clazz, GENERATED);
+            }
+
+            // and cache
+            allDescriptions.put(name, result);
+        }
+        return result;
+    }
+
+    /**
+     * Returns a map of component descriptors which may be extended by the java
+     * sources.
+     * <p>
+     * This method calls the {@link #getDependencies()} method and checks for
+     * any Service-Component descriptors in the returned files.
+     * <p>
+     * This method may be overwritten by extensions of this class.
+     *
+     * @throws SCRDescriptorException May be thrown if an error occurrs
+     *             gethering the component descriptors.
+     */
+    private Map<String, ClassDescription> getComponentDescriptors()
+    throws SCRDescriptorException {
+        if ( loadedDependencies == null ) {
+            loadedDependencies = new HashMap<String, ClassDescription>();
+
+            final Collection<File> dependencies = this.project.getDependencies();
+            for ( final File artifact : dependencies ) {
+                try {
+                    this.log.debug( "Trying to get scrinfo from artifact " + artifact );
+                    // First try to read the private scr info file from previous scr generator versions
+                    InputStream scrInfoFile = null;
+                    try {
+                        scrInfoFile = this.getFile( artifact, ABSTRACT_DESCRIPTOR_ARCHIV_PATH );
+                        if ( scrInfoFile != null ) {
+                            final List<ClassDescription> c =  this.parseServiceComponentDescriptor( scrInfoFile, artifact.toString() + ':' + ABSTRACT_DESCRIPTOR_ARCHIV_PATH);
+                            if ( c != null ) {
+                                for(final ClassDescription cd : c) {
+                                    loadedDependencies.put(cd.getDescribedClass().getName(), cd);
+                                }
+                            }
+                            continue;
+                        }
+                        this.log.debug( "Artifact has no scrinfo file (it's optional): " + artifact );
+                    } catch ( final IOException ioe ) {
+                        throw new SCRDescriptorException( "Unable to get scrinfo from artifact", artifact.toString(), 0,
+                            ioe );
+                    } finally {
+                        if ( scrInfoFile != null ) {
+                            try { scrInfoFile.close(); } catch ( final IOException ignore ) {}
+                        }
+                    }
+
+                    this.log.debug( "Trying to get manifest from artifact " + artifact );
+                    final Manifest manifest = this.getManifest( artifact );
+                    if ( manifest != null ) {
+                        // read Service-Component entry
+                        if ( manifest.getMainAttributes().getValue( SERVICE_COMPONENT ) != null ) {
+                            final String serviceComponent = manifest.getMainAttributes().getValue(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 List<ClassDescription> c = this.readServiceComponentDescriptor( artifact, entry );
+                                    if ( c != null ) {
+                                        for(final ClassDescription cd : c) {
+                                            loadedDependencies.put(cd.getDescribedClass().getName(), cd);
+                                        }
+                                    }
+                                }
+                            }
+                        } 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.toString(), 0,
+                        ioe );
+                }
+
+            }
+        }
+        return this.loadedDependencies;
+    }
+
+    /**
+     * Parses the descriptors read from the given input stream. This method may
+     * be called by the {@link #getComponentDescriptors()} method to parse the
+     * descriptors gathered in an implementation dependent way.
+     *
+     * @throws SCRDescriptorException If an error occurrs reading the
+     *             descriptors from the stream.
+     */
+    private List<ClassDescription> parseServiceComponentDescriptor(
+                    final InputStream file, final String location )
+    throws SCRDescriptorException {
+        return ComponentDescriptorIO.read( file, this.project.getClassLoader(), iLog, location );
+    }
+
+    /**
+     * Read the service component description.
+     *
+     * @param artifact
+     * @param entry
+     * @throws IOException
+     * @throws SCRDescriptorException
+     */
+    private List<ClassDescription> readServiceComponentDescriptor( final File artifactFile, String entry ) {
+        this.log.debug( "Reading " + entry + " from " + artifactFile );
+        InputStream xml = null;
+        try {
+            xml = this.getFile( artifactFile, entry );
+            if ( xml == null ) {
+                throw new SCRDescriptorException( "Entry " + entry + " not contained in JAR File ", artifactFile.toString(),
+                    0 );
+            }
+            return this.parseServiceComponentDescriptor( xml, artifactFile.toString() + ':' + entry );
+        } catch ( final IOException mee ) {
+            this.log.warn( "Unable to read SCR descriptor file from JAR File " + artifactFile + " at " + entry );
+            this.log.debug( "Exception occurred during reading: " + mee.getMessage(), mee );
+        } catch ( final SCRDescriptorException mee ) {
+            this.log.warn( "Unable to read SCR descriptor file from JAR File " + artifactFile + " at " + entry );
+            this.log.debug( "Exception occurred during reading: " + mee.getMessage(), mee );
+        } finally {
+            if ( xml != null ) {
+                try { xml.close(); } catch (final IOException ignore) {}
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Get the manifest from the artifact.
+     * The artifact can either be a jar or a directory.
+     */
+    private Manifest getManifest( final File artifact ) throws IOException {
+        if ( artifact.isDirectory() ) {
+            // this is maybe a classes directory, try to read manifest file directly
+            final File dir = new File(artifact, "META-INF");
+            if ( !dir.exists() || !dir.isDirectory() ) {
+                return null;
+            }
+            final File mf = new File(dir, "MANIFEST.MF");
+            if ( !mf.exists() || !mf.isFile() ) {
+                return null;
+            }
+            final InputStream is = new FileInputStream(mf);
+            try {
+                return new Manifest(is);
+            } finally {
+                try { is.close(); } catch (final IOException ignore) { }
+            }
+        }
+        JarFile file = null;
+        try {
+            file = new JarFile( artifact );
+            return file.getManifest();
+        } finally {
+            if ( file != null ) {
+                try { file.close(); } catch ( final IOException ignore ) {}
+            }
+        }
+    }
+
+    private InputStream getFile( final File artifactFile, final String path ) throws IOException {
+        if ( artifactFile.isDirectory() ) {
+            final String filePath = path.replace('/', File.separatorChar).replace('\\', File.separatorChar);
+            final File file = new File(artifactFile, filePath);
+            if ( file.exists() && file.isFile() ) {
+                return new FileInputStream(file);
+            }
+            return null;
+        }
+        JarFile file = null;
+        try {
+            file = new JarFile( artifactFile );
+            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 ( final 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 ( final IOException ioe ) {
+                // ignore
+            }
+            jarFile.close();
+        }
+
+
+        @Override
+        protected void finalize() throws Throwable {
+            try {
+                close();
+            } finally {
+                super.finalize();
+            }
+        }
+    }
 }

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/AbstractObject.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/AbstractObject.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/AbstractObject.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/AbstractObject.java Tue Jun 12 13:30:10 2012
@@ -19,6 +19,7 @@
 package org.apache.felix.scrplugin.om;
 
 import org.apache.felix.scrplugin.helper.IssueLog;
+import org.apache.felix.scrplugin.scanner.ScannedAnnotation;
 
 /**
  * The <code>AbstractObject</code> is the base class for the all classes of the scr om.
@@ -29,8 +30,8 @@ public abstract class AbstractObject {
 
     private final String sourceLocation;
 
-    protected AbstractObject(final String annotationName, final String sourceLocation) {
-        this.annotationName = annotationName;
+    protected AbstractObject(final ScannedAnnotation annotation, final String sourceLocation) {
+        this.annotationName = (annotation != null ? annotation.getName() : "<unknown>");
         this.sourceLocation = sourceLocation;
     }
 

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java Tue Jun 12 13:30:10 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.scrplugin.om;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.List;
@@ -26,6 +28,7 @@ import org.apache.felix.scrplugin.SCRDes
 import org.apache.felix.scrplugin.description.ClassDescription;
 import org.apache.felix.scrplugin.description.ComponentConfigurationPolicy;
 import org.apache.felix.scrplugin.description.SpecVersion;
+import org.apache.felix.scrplugin.scanner.ScannedAnnotation;
 
 /**
  * <code>Component</code> is a described component.
@@ -78,20 +81,14 @@ public class Component extends AbstractO
     /** The spec version. */
     protected SpecVersion specVersion;
 
+    /** The class description. */
     private final ClassDescription classDescription;
 
     /**
-     * Default constructor.
-     */
-    public Component() {
-        this(null, null, null);
-    }
-
-    /**
      * Constructor from java source.
      */
-    public Component(final ClassDescription cDesc, final String annotationName, final String sourceLocation) {
-        super(annotationName, sourceLocation);
+    public Component(final ClassDescription cDesc, final ScannedAnnotation annotation, final String sourceLocation) {
+        super(annotation, sourceLocation);
         this.classDescription = cDesc;
     }
 
@@ -277,37 +274,42 @@ public class Component extends AbstractO
             // no errors so far, let's continue
             if (context.getIssueLog().getNumberOfErrors() == currentIssueCount) {
 
-            /* final String activateName = this.activate == null ? "activate" : this.activate;
-             * final String deactivateName = this.deactivate == null ? "deactivate" : this.deactivate;
-             *
-             * // check activate and deactivate methods
-             * this.checkLifecycleMethod(specVersion, javaClass, activateName, true, iLog);
-             * this.checkLifecycleMethod(specVersion, javaClass, deactivateName, false, iLog);
-             *
-             * if (this.modified != null && specVersion >= Constants.VERSION_1_1) {
-             * this.checkLifecycleMethod(specVersion, javaClass, this.modified, true, iLog);
-             * }
-             * // ensure public default constructor
-             * boolean constructorFound = true;
-             * JavaMethod[] methods = javaClass.getMethods();
-             * for (int i = 0; methods != null && i < methods.length; i++) {
-             * if (methods[i].isConstructor()) {
-             * // if public default, succeed
-             * if (methods[i].isPublic()
-             * && (methods[i].getParameters() == null || methods[i].getParameters().length == 0)) {
-             * constructorFound = true;
-             * break;
-             * }
-             *
-             * // non-public/non-default constructor found, must have
-             * // explicit
-             * constructorFound = false;
-             * }
-             * }
-             * if (!constructorFound) {
-             * this.logError(context.getIssueLog(), "Class must have public default constructor: " + javaClass.getName());
-             * }
-             */
+                final String activateName = this.activate == null ? "activate" : this.activate;
+                final String deactivateName = this.deactivate == null ? "deactivate" : this.deactivate;
+
+                // check activate and deactivate methods
+                this.checkLifecycleMethod(context, activateName, true);
+                this.checkLifecycleMethod(context, deactivateName, false);
+
+                if (this.modified != null) {
+                    if ( context.getSpecVersion().ordinal() >= SpecVersion.VERSION_1_1.ordinal() ) {
+                        this.checkLifecycleMethod(context, this.modified, true);
+                    } else {
+                        this.logError(context.getIssueLog(), "If modified version is specified, spec version must be " +
+                            SpecVersion.VERSION_1_1.name() + " or higher : " + this.modified);
+                    }
+                }
+
+                // ensure public default constructor
+                boolean constructorFound = true;
+                Constructor<?>[] constructors = this.classDescription.getDescribedClass().getDeclaredConstructors();
+                for (int i = 0; constructors != null && i < constructors.length; i++) {
+                    // if public default, succeed
+                    if (Modifier.isPublic(constructors[i].getModifiers())
+                        && (constructors[i].getParameterTypes() == null || constructors[i].getParameterTypes().length == 0)) {
+                        constructorFound = true;
+                        break;
+                    }
+
+                    // non-public/non-default constructor found, must have
+                    // explicit
+                    constructorFound = false;
+                }
+
+                if (!constructorFound) {
+                    this.logError(context.getIssueLog(), "Class must have public default constructor: " + this.classDescription.getDescribedClass().getName());
+                }
+
                 // verify properties
                 for (final Property prop : this.getProperties()) {
                     prop.validate(context);
@@ -352,6 +354,32 @@ public class Component extends AbstractO
     private static final String TYPE_INT = "int";
     private static final String TYPE_INTEGER = "java.lang.Integer";
 
+    private Method getMethod(final Context ctx, final String name, final String[] sig)
+    throws SCRDescriptorException {
+        Class<?>[] classSig = (sig == null ? null : new Class<?>[sig.length]);
+        if ( sig != null ) {
+            for(int i = 0; i<sig.length; i++) {
+                try {
+                    if ( sig[i].equals("int") ) {
+                        classSig[i] = int.class;
+                    } else {
+                        classSig[i] = ctx.getProject().getClassLoader().loadClass(sig[i]);
+                    }
+                } catch (final ClassNotFoundException e) {
+                    throw new SCRDescriptorException("Unable to load class.", e);
+                }
+            }
+        }
+        try {
+            return ctx.getClassDescription().getDescribedClass().getDeclaredMethod(name, classSig);
+        } catch (final SecurityException e) {
+            // ignore
+        } catch (final NoSuchMethodException e) {
+            // ignore
+        }
+        return null;
+    }
+
     /**
      * Check for existence of lifecycle methods.
      *
@@ -363,109 +391,112 @@ public class Component extends AbstractO
      *            The method name.
      * @param warnings
      *            The list of warnings used to add new warnings.
-     *            protected void checkLifecycleMethod(final int specVersion, final JavaClassDescription javaClass, final String
-     *            methodName,
-     *            final boolean isActivate, final IssueLog iLog) throws SCRDescriptorException {
-     *            // first candidate is (de)activate(ComponentContext)
-     *            JavaMethod method = javaClass.getMethodBySignature(methodName, new String[] { TYPE_COMPONENT_CONTEXT });
-     *            if (method == null) {
-     *            if (specVersion >= Constants.VERSION_1_1) {
-     *            // second candidate is (de)activate(BundleContext)
-     *            method = javaClass.getMethodBySignature(methodName, new String[] { TYPE_BUNDLE_CONTEXT });
-     *            if (method == null) {
-     *            // third candidate is (de)activate(Map)
-     *            method = javaClass.getMethodBySignature(methodName, new String[] { TYPE_MAP });
-     *
-     *            if (method == null) {
-     *            // if this is a deactivate method, we have two
-     *            // additional possibilities
-     *            // a method with parameter of type int and one of type
-     *            // Integer
-     *            if (!isActivate) {
-     *            method = javaClass.getMethodBySignature(methodName, new String[] { TYPE_INT });
-     *            if (method == null) {
-     *            method = javaClass.getMethodBySignature(methodName, new String[] { TYPE_INTEGER });
-     *            }
-     *            }
-     *
-     *            // fourth candidate is (de)activate with two or three
-     *            // arguments (type must be BundleContext, ComponentCtx
-     *            // and Map)
-     *            // as we have to iterate now and the fifth candidate is
-     *            // zero arguments
-     *            // we already store this option
-     *            JavaMethod zeroArgMethod = null;
-     *            JavaMethod found = method;
-     *            final JavaMethod[] methods = javaClass.getMethods();
-     *            int i = 0;
-     *            while (i < methods.length) {
-     *            if (methodName.equals(methods[i].getName())) {
-     *
-     *            if (methods[i].getParameters().length == 0) {
-     *            zeroArgMethod = methods[i];
-     *            } else if (methods[i].getParameters().length >= 2) {
-     *            boolean valid = true;
-     *            for (int m = 0; m < methods[i].getParameters().length; m++) {
-     *            final String type = methods[i].getParameters()[m].getType();
-     *            if (!type.equals(TYPE_BUNDLE_CONTEXT) && !type.equals(TYPE_COMPONENT_CONTEXT)
-     *            && !type.equals(TYPE_MAP)) {
-     *            // if this is deactivate, int and
-     *            // integer are possible as well
-     *            if (isActivate || (!type.equals(TYPE_INT) && !type.equals(TYPE_INTEGER))) {
-     *            valid = false;
-     *            }
-     *            }
-     *            }
-     *            if (valid) {
-     *            if (found == null) {
-     *            found = methods[i];
-     *            } else {
-     *            // print warning
-     *            this.logWarn(iLog, "Lifecycle method " + methods[i].getName()
-     *            + " occurs several times with different matching signature.");
-     *            }
-     *            }
-     *            }
-     *            }
-     *            i++;
-     *            }
-     *            if (found != null) {
-     *            method = found;
-     *            } else {
-     *            method = zeroArgMethod;
-     *            }
-     *            }
-     *            }
-     *            }
-     *            // if no method is found, we check for any method with that name to
-     *            // print some warnings!
-     *            if (method == null) {
-     *            final JavaMethod[] methods = javaClass.getMethods();
-     *            for (int i = 0; i < methods.length; i++) {
-     *            if (methodName.equals(methods[i].getName())) {
-     *            if (methods[i].getParameters().length != 1) {
-     *            this.logWarn(iLog, "Lifecycle method " + methods[i].getName() + " has wrong number of arguments");
-     *            } else {
-     *            this.logWarn(iLog,
-     *            "Lifecycle method " + methods[i].getName() + " has wrong argument "
-     *            + methods[i].getParameters()[0].getType());
-     *            }
-     *            }
-     *            }
-     *            }
-     *            }
-     *            // method must be protected for version 1.0
-     *            if (method != null && specVersion == Constants.VERSION_1_0) {
-     *            // check protected
-     *            if (method.isPublic()) {
-     *            this.logWarn(iLog, "Lifecycle method " + method.getName() + " should be declared protected");
-     *            } else if (!method.isProtected()) {
-     *            this.logWarn(iLog, "Lifecycle method " + method.getName() +
-     *            " has wrong qualifier, public or protected required");
-     *            }
-     *            }
-     *            }
      */
+    private void checkLifecycleMethod(final Context ctx,
+                                      final String methodName,
+                                      final boolean isActivate)
+    throws SCRDescriptorException {
+        // first candidate is (de)activate(ComponentContext)
+        Method method = this.getMethod(ctx, methodName, new String[] { TYPE_COMPONENT_CONTEXT });
+        if (method == null) {
+            if (ctx.getSpecVersion().ordinal() >= SpecVersion.VERSION_1_1.ordinal() ) {
+                // second candidate is (de)activate(BundleContext)
+                method = this.getMethod(ctx, methodName, new String[] { TYPE_BUNDLE_CONTEXT });
+                if (method == null) {
+                    // third candidate is (de)activate(Map)
+                    method = this.getMethod(ctx, methodName, new String[] { TYPE_MAP });
+
+                    if (method == null) {
+                        // if this is a deactivate method, we have two
+                        // additional possibilities
+                        // a method with parameter of type int and one of type
+                        // Integer
+                        if (!isActivate) {
+                            method = this.getMethod(ctx, methodName, new String[] { TYPE_INT });
+                            if (method == null) {
+                                method = this.getMethod(ctx, methodName, new String[] { TYPE_INTEGER });
+                            }
+                        }
+                    }
+
+                    if (method == null) {
+                        // fourth candidate is (de)activate with two or three
+                        // arguments (type must be BundleContext, ComponentCtx
+                        // and Map)
+                        // as we have to iterate now and the fifth candidate is
+                        // zero arguments
+                        // we already store this option
+                        Method zeroArgMethod = null;
+                        Method found = method;
+                        final Method[] methods = ctx.getClassDescription().getDescribedClass().getDeclaredMethods();
+                        int i = 0;
+                        while (i < methods.length) {
+                            if (methodName.equals(methods[i].getName())) {
+
+                                if (methods[i].getParameterTypes() == null || methods[i].getParameterTypes().length == 0) {
+                                    zeroArgMethod = methods[i];
+                                } else if (methods[i].getParameterTypes().length >= 2) {
+                                    boolean valid = true;
+                                    for (int m = 0; m < methods[i].getParameterTypes().length; m++) {
+                                        final String type = methods[i].getParameterTypes()[m].getName();
+                                        if (!type.equals(TYPE_BUNDLE_CONTEXT) && !type.equals(TYPE_COMPONENT_CONTEXT)
+                                            && !type.equals(TYPE_MAP)) {
+                                            // if this is deactivate, int and
+                                            // integer are possible as well
+                                            if (isActivate || (!type.equals(TYPE_INT) && !type.equals(TYPE_INTEGER))) {
+                                                valid = false;
+                                            }
+                                        }
+                                    }
+                                    if (valid) {
+                                        if (found == null) {
+                                            found = methods[i];
+                                        } else {
+                                            // print warning
+                                            this.logWarn(ctx.getIssueLog(), "Lifecycle method " + methods[i].getName()
+                                                      + " occurs several times with different matching signature.");
+                                        }
+                                    }
+                                }
+                            }
+                            i++;
+                        }
+                        if (found != null) {
+                            method = found;
+                        } else {
+                            method = zeroArgMethod;
+                        }
+                    }
+                }
+            }
+        }
+        // if no method is found, we check for any method with that name to print some warnings!
+        if (method == null) {
+           final Method[] methods = ctx.getClassDescription().getDescribedClass().getDeclaredMethods();
+            for (int i = 0; i < methods.length; i++) {
+                if (methodName.equals(methods[i].getName())) {
+                    if (methods[i].getParameterTypes() == null || methods[i].getParameterTypes().length != 1) {
+                        this.logWarn(ctx.getIssueLog(), "Lifecycle method " + methods[i].getName() + " has wrong number of arguments");
+                    } else {
+                        this.logWarn(ctx.getIssueLog(),
+                            "Lifecycle method " + methods[i].getName() + " has wrong argument "
+                            + methods[i].getParameterTypes()[0].getName());
+                    }
+                }
+            }
+        }
+
+        // method must be protected for version 1.0
+        if (method != null && specVersion == SpecVersion.VERSION_1_0) {
+            // check protected
+            if (Modifier.isPublic(method.getModifiers())) {
+                this.logWarn(ctx.getIssueLog(), "Lifecycle method " + method.getName() + " should be declared protected");
+            } else if (!Modifier.isProtected(method.getModifiers())) {
+                this.logWarn(ctx.getIssueLog(), "Lifecycle method " + method.getName() +
+                            " has wrong qualifier, public or protected required");
+            }
+        }
+    }
 
     /**
      * Return the configuration policy.

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Context.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Context.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Context.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Context.java Tue Jun 12 13:30:10 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.scrplugin.om;
 
+import org.apache.felix.scrplugin.Options;
 import org.apache.felix.scrplugin.Project;
 import org.apache.felix.scrplugin.description.ClassDescription;
 import org.apache.felix.scrplugin.description.SpecVersion;
@@ -33,6 +34,8 @@ public class Context {
 
     private ClassDescription classDescription;
 
+    private Options options;
+
     public Project getProject() {
         return project;
     }
@@ -64,4 +67,12 @@ public class Context {
     public void setClassDescription(ClassDescription classDescription) {
         this.classDescription = classDescription;
     }
+
+    public Options getOptions() {
+        return options;
+    }
+
+    public void setOptions(Options options) {
+        this.options = options;
+    }
 }

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Interface.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Interface.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Interface.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Interface.java Tue Jun 12 13:30:10 2012
@@ -19,10 +19,11 @@
 package org.apache.felix.scrplugin.om;
 
 import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.scanner.ScannedAnnotation;
 
 /**
  * <code>Interface</code>
- * 
+ *
  * contains an interface name the component is implementing
  * (the interface name can also be a class name)
  */
@@ -32,17 +33,10 @@ public class Interface extends AbstractO
     private String interfaceName;
 
     /**
-     * Default constructor.
-     */
-    public Interface() {
-        this(null, null);
-    }
-
-    /**
      * Constructor from java source.
      */
-    public Interface(final String annotationName, final String sourceLocation) {
-        super(annotationName, sourceLocation);
+    public Interface(final ScannedAnnotation annotation, final String sourceLocation) {
+        super(annotation, sourceLocation);
     }
 
     /**

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Property.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Property.java?rev=1349327&r1=1349326&r2=1349327&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Property.java (original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Property.java Tue Jun 12 13:30:10 2012
@@ -20,6 +20,7 @@ package org.apache.felix.scrplugin.om;
 
 import org.apache.felix.scrplugin.description.PropertyType;
 import org.apache.felix.scrplugin.description.SpecVersion;
+import org.apache.felix.scrplugin.scanner.ScannedAnnotation;
 
 /**
  * <code>Property.java</code>...
@@ -33,17 +34,10 @@ public class Property extends AbstractOb
     protected String[] multiValue;
 
     /**
-     * Default constructor.
-     */
-    public Property() {
-        this(null, null);
-    }
-
-    /**
      * Constructor from java source.
      */
-    public Property(final String annotationName, final String sourceLocation) {
-        super(annotationName, sourceLocation);
+    public Property(final ScannedAnnotation annotation, final String sourceLocation) {
+        super(annotation, sourceLocation);
     }
 
     public String getName() {



Mime
View raw message