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

Copied: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java (from r802758, felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java)
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java?p2=felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java&p1=felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java&r1=802758&r2=820997&rev=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java Fri Oct  2 12:59:27 2009
@@ -18,203 +18,223 @@
  */
 package org.apache.felix.scrplugin;
 
-import java.io.File;
-import java.util.*;
 
-import org.apache.felix.scrplugin.om.*;
-import org.apache.felix.scrplugin.om.metatype.*;
-import org.apache.felix.scrplugin.tags.*;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.helper.IssueLog;
+import org.apache.felix.scrplugin.helper.PropertyHandler;
+import org.apache.felix.scrplugin.helper.StringUtils;
+import org.apache.felix.scrplugin.om.Component;
+import org.apache.felix.scrplugin.om.Components;
+import org.apache.felix.scrplugin.om.Implementation;
+import org.apache.felix.scrplugin.om.Interface;
+import org.apache.felix.scrplugin.om.Property;
+import org.apache.felix.scrplugin.om.Reference;
+import org.apache.felix.scrplugin.om.Service;
+import org.apache.felix.scrplugin.om.metatype.Designate;
+import org.apache.felix.scrplugin.om.metatype.MTObject;
+import org.apache.felix.scrplugin.om.metatype.MetaData;
+import org.apache.felix.scrplugin.om.metatype.OCD;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.JavaClassDescriptionInheritanceComparator;
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+import org.apache.felix.scrplugin.tags.ModifiableJavaClassDescription;
 import org.apache.felix.scrplugin.tags.qdox.QDoxJavaClassDescription;
 import org.apache.felix.scrplugin.xml.ComponentDescriptorIO;
 import org.apache.felix.scrplugin.xml.MetaTypeIO;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.*;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.StringUtils;
 import org.osgi.service.metatype.MetaTypeService;
 
 /**
- * The <code>SCRDescriptorMojo</code>
- * generates a service descriptor file based on annotations found in the sources.
- *
- * @goal scr
- * @phase process-classes
- * @description Build Service Descriptors from Java Source
- * @requiresDependencyResolution compile
+ * The <code>SCRDescriptorGenerator</code> class does the hard work of
+ * generating the SCR descriptors. This class is being instantiated and
+ * configured by clients and the {@link #execute()} method called to generate
+ * the descriptor files.
  */
-public class SCRDescriptorMojo extends AbstractMojo {
+public class SCRDescriptorGenerator
+{
 
-    /**
-     * @parameter expression="${project.build.directory}/scr-plugin-generated"
-     * @required
-     * @readonly
-     */
-    private File outputDirectory;
+    private final Log logger;
 
-    /**
-     * The Maven project.
-     *
-     * @parameter expression="${project}"
-     * @required
-     * @readonly
-     */
-    private MavenProject project;
+    private File outputDirectory = null;
 
-    /**
-     * Name of the generated descriptor.
-     *
-     * @parameter expression="${scr.descriptor.name}" default-value="serviceComponents.xml"
-     */
-    private String finalName;
+    private JavaClassDescriptorManager descriptorManager;
 
-    /**
-     * Name of the generated meta type file.
-     *
-     * @parameter default-value="metatype.xml"
-     */
-    private String metaTypeName;
+    private String finalName = "serviceComponents.xml";
 
-    /**
-     * This flag controls the generation of the bind/unbind methods.
-     * @parameter default-value="true"
-     */
-    private boolean generateAccessors;
+    private String metaTypeName = "metatype.xml";
 
-    /**
-     * This flag controls whether the javadoc source code will be scanned for
-     * tags.
-     * @parameter default-value="true"
-     */
-    protected boolean parseJavadoc;
+    private boolean generateAccessors = true;
 
-    /**
-     * This flag controls whether the annotations in the sources will be
-     * processed.
-     * @parameter default-value="true"
-     */
-    protected boolean processAnnotations;
+    protected boolean strictMode = false;
 
-    /**
-     * In strict mode the plugin even fails on warnings.
-     * @parameter default-value="false"
-     */
-    protected boolean strictMode;
+    private Map<String, String> properties = new HashMap<String, String>();
 
-    /**
-     * The comma separated list of tokens to exclude when processing sources.
-     *
-     * @parameter alias="excludes"
-     */
-    private String sourceExcludes;
+    private String specVersion = null;
 
-    /**
-     * Predefined properties.
-     *
-     * @parameter
-     */
-    private Map<String, String> properties = new HashMap<String, String>();
 
-    /**
-     * Allows to define additional implementations of the interface
-     * {@link org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider}
-     * that provide mappings from custom annotations to
-     * {@link org.apache.felix.scrplugin.tags.JavaTag} implementations.
-     * List of full qualified class file names.
-     *
-     * @parameter
-     */
-    private String[] annotationTagProviders = {};
+    public SCRDescriptorGenerator( Log logger )
+    {
+        this.logger = logger;
+    }
+
+
+    //---------- property setup (write-only for now)
+
+    public void setOutputDirectory( File outputDirectory )
+    {
+        this.outputDirectory = outputDirectory;
+    }
 
-    /**
-     * The version of the DS spec this plugin generates a descriptor for.
-     * By default the version is detected by the used tags.
-     * @parameter
-     */
-    private String specVersion;
 
     /**
-     * @see org.apache.maven.plugin.AbstractMojo#execute()
+     * Sets the class path used for resolving tags and annotations. The first
+     * entry in the class path is assumed to be the build target location.
      */
-    public void execute() throws MojoExecutionException, MojoFailureException {
-        this.getLog().debug("Starting SCRDescriptorMojo....");
-        this.getLog().debug("..generating accessors: " + this.generateAccessors);
-        this.getLog().debug("..parsing javadocs: " + this.parseJavadoc);
-        this.getLog().debug("..processing annotations: " + this.processAnnotations);
+    public void setDescriptorManager( JavaClassDescriptorManager descriptorManager )
+    {
+        this.descriptorManager = descriptorManager;
+    }
+
+    public void setFinalName( String finalName )
+    {
+        this.finalName = finalName;
+    }
+
+
+    public void setMetaTypeName( String metaTypeName )
+    {
+        this.metaTypeName = metaTypeName;
+    }
+
+
+    public void setGenerateAccessors( boolean generateAccessors )
+    {
+        this.generateAccessors = generateAccessors;
+    }
+
+
+    public void setStrictMode( boolean strictMode )
+    {
+        this.strictMode = strictMode;
+    }
+
+
+    public void setProperties( Map<String, String> properties )
+    {
+        this.properties = new HashMap<String, String>( properties );
+    }
+
+
+    public void setSpecVersion( String specVersion )
+    {
+        this.specVersion = specVersion;
+    }
+
+    //---------- descriptor generation
+
+    public boolean execute() throws SCRDescriptorException, SCRDescriptorFailureException
+    {
+        this.logger.debug( "Starting SCRDescriptorMojo...." );
+        this.logger.debug( "..generating accessors: " + this.generateAccessors );
+        this.logger.debug( "..parsing javadocs: " + this.descriptorManager.isParseJavadocs() );
+        this.logger.debug( "..processing annotations: " + this.descriptorManager.isProcessAnnotations() );
 
         // check speck version configuration
         int specVersion = Constants.VERSION_1_0;
-        if ( this.specVersion != null ) {
-            if ( this.specVersion.equals("1.1") ) {
+        if ( this.specVersion != null )
+        {
+            if ( this.specVersion.equals( "1.1" ) )
+            {
                 specVersion = Constants.VERSION_1_1;
-            } else if ( !this.specVersion.equals("1.0") ) {
-                throw new MojoExecutionException("Unknown configuration for spec version: " + this.specVersion);
             }
-        } else {
-            this.getLog().debug("..auto detecting spec version");
+            else if ( !this.specVersion.equals( "1.0" ) )
+            {
+                throw new SCRDescriptorException( "Unknown configuration for spec version: " + this.specVersion );
+            }
+        }
+        else
+        {
+            this.logger.debug( "..auto detecting spec version" );
         }
-        JavaClassDescriptorManager jManager = new JavaClassDescriptorManager(this.getLog(),
-                                                                             this.project,
-                                                                             this.annotationTagProviders,
-                                                                             this.sourceExcludes,
-                                                                             this.parseJavadoc,
-                                                                             this.processAnnotations);
-        final IssueLog iLog = new IssueLog(this.strictMode);
+        final IssueLog iLog = new IssueLog( this.strictMode );
 
         final MetaData metaData = new MetaData();
-        metaData.setLocalization(MetaTypeService.METATYPE_DOCUMENTS_LOCATION + "/metatype");
+        metaData.setLocalization( MetaTypeService.METATYPE_DOCUMENTS_LOCATION + "/metatype" );
 
         // iterate through all source classes and check for component tag
-        final JavaClassDescription[] javaSources = jManager.getSourceDescriptions();
-        Arrays.sort(javaSources, new JavaClassDescriptionInheritanceComparator());
+        final JavaClassDescription[] javaSources = descriptorManager.getSourceDescriptions();
+        Arrays.sort( javaSources, new JavaClassDescriptionInheritanceComparator() );
 
         final List<Component> scannedComponents = new ArrayList<Component>();
-        for (int i = 0; i < javaSources.length; i++) {
-            this.getLog().debug("Testing source " + javaSources[i].getName());
-            final JavaTag tag = javaSources[i].getTagByName(Constants.COMPONENT);
-            if (tag != null) {
-                this.getLog().debug("Processing service class " + javaSources[i].getName());
+        for ( int i = 0; i < javaSources.length; i++ )
+        {
+            this.logger.debug( "Testing source " + javaSources[i].getName() );
+            final JavaTag tag = javaSources[i].getTagByName( Constants.COMPONENT );
+            if ( tag != null )
+            {
+                this.logger.debug( "Processing service class " + javaSources[i].getName() );
                 // check if there is more than one component tag!
-                if ( javaSources[i].getTagsByName(Constants.COMPONENT, false).length > 1 ) {
-                    iLog.addError("Class " + javaSources[i].getName() + " has more than one " + Constants.COMPONENT + " tag." +
-                            " Merge the tags to a single tag.");
-                } else {
-                    final Component comp = this.createComponent(javaSources[i], tag, metaData, iLog);
-                    if ( comp.getSpecVersion() > specVersion ) {
+                if ( javaSources[i].getTagsByName( Constants.COMPONENT, false ).length > 1 )
+                {
+                    iLog.addError( "Class " + javaSources[i].getName() + " has more than one " + Constants.COMPONENT
+                        + " tag." + " Merge the tags to a single tag." );
+                }
+                else
+                {
+                    final Component comp = this.createComponent( javaSources[i], tag, metaData, iLog );
+                    if ( comp.getSpecVersion() > specVersion )
+                    {
                         // if a spec version has been configured and a component requires a higher
                         // version, this is considered an error!
-                        if ( this.specVersion != null ) {
+                        if ( this.specVersion != null )
+                        {
                             String v = "1.0";
-                            if ( comp.getSpecVersion() == Constants.VERSION_1_1 ) {
+                            if ( comp.getSpecVersion() == Constants.VERSION_1_1 )
+                            {
                                 v = "1.1";
                             }
-                            iLog.addError("Component " + comp + " requires spec version " + v + " but plugin is configured to use version " + this.specVersion);
+                            iLog.addError( "Component " + comp + " requires spec version " + v
+                                + " but plugin is configured to use version " + this.specVersion );
                         }
                         specVersion = comp.getSpecVersion();
                     }
-                    scannedComponents.add(comp);
+                    scannedComponents.add( comp );
                 }
             }
         }
-        this.getLog().debug("..generating descriptor for spec version: " + this.specVersion);
+        this.logger.debug( "..generating descriptor for spec version: " + this.specVersion );
 
         // now check for abstract components and fill components objects
         final Components components = new Components();
         final Components abstractComponents = new Components();
-        components.setSpecVersion(specVersion);
-        abstractComponents.setSpecVersion(specVersion);
+        components.setSpecVersion( specVersion );
+        abstractComponents.setSpecVersion( specVersion );
 
-        for(final Component comp : scannedComponents ) {
+        for ( final Component comp : scannedComponents )
+        {
             final int errorCount = iLog.getNumberOfErrors();
             // before we can validate we should check the references for bind/unbind method
             // in order to create them if possible
 
-            for(final Reference ref : comp.getReferences() ) {
+            for ( final Reference ref : comp.getReferences() )
+            {
                 // 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 ( this.generateAccessors && !ref.isLookupStrategy() ) {
-                    if ( ref.getJavaTag().getField() != null && comp.getJavaClassDescription() instanceof ModifiableJavaClassDescription ) {
-                        if ( ref.getCardinality().equals("0..1") || ref.getCardinality().equals("1..1") ) {
+                if ( this.generateAccessors && !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();
@@ -223,440 +243,513 @@
                             boolean createBind = false;
                             boolean createUnbind = false;
                             // Only create method if no bind name has been specified
-                            if ( bindValue == null && ref.findMethod(specVersion, "bind") == null ) {
+                            if ( bindValue == null && ref.findMethod( specVersion, "bind" ) == null )
+                            {
                                 // create bind method
                                 createBind = true;
                             }
-                            if ( unbindValue == null && ref.findMethod(specVersion, "unbind") == null ) {
+                            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 ( createBind || createUnbind )
+                            {
+                                ( ( ModifiableJavaClassDescription ) comp.getJavaClassDescription() ).addMethods( name,
+                                    type, createBind, createUnbind );
                             }
                         }
                     }
                 }
             }
-            comp.validate(specVersion, iLog);
+            comp.validate( specVersion, iLog );
             // ignore component if it has errors
-            if ( iLog.getNumberOfErrors() == errorCount ) {
-                if ( !comp.isDs() ) {
-                    getLog().debug("Ignoring descriptor " + comp);
-                } else if ( comp.isAbstract() ) {
-                    this.getLog().debug("Adding abstract descriptor " + comp);
-                    abstractComponents.addComponent(comp);
-                } else {
-                    this.getLog().debug("Adding descriptor " + comp);
-                    components.addComponent(comp);
-                    abstractComponents.addComponent(comp);
+            if ( iLog.getNumberOfErrors() == errorCount )
+            {
+                if ( !comp.isDs() )
+                {
+                    logger.debug( "Ignoring descriptor " + comp );
+                }
+                else if ( comp.isAbstract() )
+                {
+                    this.logger.debug( "Adding abstract descriptor " + comp );
+                    abstractComponents.addComponent( comp );
+                }
+                else
+                {
+                    this.logger.debug( "Adding descriptor " + comp );
+                    components.addComponent( comp );
+                    abstractComponents.addComponent( comp );
                 }
             }
         }
 
         // log issues
-        iLog.log(this.getLog());
+        logMessages( iLog );
 
         // after checking all classes, throw if there were any failures
-        if ( iLog.hasErrors() ) {
-            throw new MojoFailureException("SCR Descriptor parsing had failures (see log)");
+        if ( iLog.hasErrors() )
+        {
+            throw new SCRDescriptorFailureException( "SCR Descriptor parsing had failures (see log)" );
         }
 
         boolean addResources = false;
         // write meta type info if there is a file name
-        if (!StringUtils.isEmpty(this.metaTypeName)) {
-            File mtFile = new File(this.outputDirectory, "OSGI-INF" + File.separator + "metatype" + File.separator + this.metaTypeName);
+        if ( !StringUtils.isEmpty( this.metaTypeName ) )
+        {
+            File mtFile = new File( this.outputDirectory, "OSGI-INF" + File.separator + "metatype" + File.separator
+                + this.metaTypeName );
             final int size = metaData.getOCDs().size() + metaData.getDesignates().size();
-            if (size > 0 ) {
-                this.getLog().info("Generating "
-                    + size
-                    + " MetaType Descriptors to " + mtFile);
+            if ( size > 0 )
+            {
+                this.logger.info( "Generating " + size + " MetaType Descriptors to " + mtFile );
                 mtFile.getParentFile().mkdirs();
-                MetaTypeIO.write(metaData, mtFile);
+                MetaTypeIO.write( metaData, mtFile );
                 addResources = true;
-            } else {
-                if ( mtFile.exists() ) {
+            }
+            else
+            {
+                if ( mtFile.exists() )
+                {
                     mtFile.delete();
                 }
             }
 
-        } else {
-            this.getLog().info("Meta type file name is not set: meta type info is not written.");
+        }
+        else
+        {
+            this.logger.info( "Meta type file name is not set: meta type info is not written." );
         }
 
         // if we have descriptors, write them in our scr private file (for component inheritance)
-        final File adFile = new File(this.outputDirectory, Constants.ABSTRACT_DESCRIPTOR_RELATIVE_PATH);
-        if ( !abstractComponents.getComponents().isEmpty() ) {
-            this.getLog().info("Writing abstract service descriptor " + adFile + " with " + abstractComponents.getComponents().size() + " entries.");
+        final File adFile = new File( this.outputDirectory, Constants.ABSTRACT_DESCRIPTOR_RELATIVE_PATH );
+        if ( !abstractComponents.getComponents().isEmpty() )
+        {
+            this.logger.info( "Writing abstract service descriptor " + adFile + " with "
+                + abstractComponents.getComponents().size() + " entries." );
             adFile.getParentFile().mkdirs();
-            ComponentDescriptorIO.write(abstractComponents, adFile, true);
+            ComponentDescriptorIO.write( abstractComponents, adFile, true );
             addResources = true;
-        } else {
-            this.getLog().debug("No abstract SCR Descriptors found in project.");
+        }
+        else
+        {
+            this.logger.debug( "No abstract SCR Descriptors found in project." );
             // remove file
-            if ( adFile.exists() ) {
-                this.getLog().debug("Removing obsolete abstract service descriptor " + adFile);
+            if ( adFile.exists() )
+            {
+                this.logger.debug( "Removing obsolete abstract service descriptor " + adFile );
                 adFile.delete();
             }
         }
 
         // check descriptor file
-        final File descriptorFile = StringUtils.isEmpty(this.finalName) ? null : new File(new File(this.outputDirectory, "OSGI-INF"), this.finalName);
+        final File descriptorFile = StringUtils.isEmpty( this.finalName ) ? null : new File( new File(
+            this.outputDirectory, "OSGI-INF" ), this.finalName );
 
         // terminate if there is nothing else to write
-        if (components.getComponents().isEmpty()) {
-            this.getLog().debug("No SCR Descriptors found in project.");
+        if ( components.getComponents().isEmpty() )
+        {
+            this.logger.debug( "No SCR Descriptors found in project." );
             // remove file if it exists
-            if ( descriptorFile != null && descriptorFile.exists() ) {
-                this.getLog().debug("Removing obsolete service descriptor " + descriptorFile);
+            if ( descriptorFile != null && descriptorFile.exists() )
+            {
+                this.logger.debug( "Removing obsolete service descriptor " + descriptorFile );
                 descriptorFile.delete();
             }
-        } else {
-
-            if (descriptorFile == null) {
-                throw new MojoFailureException("Descriptor file name must not be empty.");
+        }
+        else
+        {
+            if ( descriptorFile == null )
+            {
+                throw new SCRDescriptorFailureException( "Descriptor file name must not be empty." );
             }
 
             // finally the descriptors have to be written ....
             descriptorFile.getParentFile().mkdirs(); // ensure parent dir
 
-            this.getLog().info("Generating " + components.getComponents().size()
-                    + " Service Component Descriptors to " + descriptorFile);
+            this.logger.info( "Generating " + components.getComponents().size() + " Service Component Descriptors to "
+                + descriptorFile );
 
-            ComponentDescriptorIO.write(components, descriptorFile, false);
+            ComponentDescriptorIO.write( components, descriptorFile, false );
             addResources = true;
-
-            // and set include accordingly
-            String svcComp = project.getProperties().getProperty("Service-Component");
-            svcComp= (svcComp == null) ? "OSGI-INF/" + finalName : svcComp + ", " + "OSGI-INF/" + finalName;
-            project.getProperties().setProperty("Service-Component", svcComp);
         }
 
-        // now add the descriptor directory to the maven resources
-        if (addResources) {
-            final String ourRsrcPath = this.outputDirectory.getAbsolutePath();
-            boolean found = false;
-            @SuppressWarnings("unchecked")
-            final Iterator<Resource> rsrcIterator = this.project.getResources().iterator();
-            while ( !found && rsrcIterator.hasNext() ) {
-                final Resource rsrc = rsrcIterator.next();
-                found = rsrc.getDirectory().equals(ourRsrcPath);
-            }
-            if ( !found ) {
-                final Resource resource = new Resource();
-                resource.setDirectory(this.outputDirectory.getAbsolutePath());
-                this.project.addResource(resource);
-            }
-        }
+        return addResources;
     }
 
+
     /**
      * Create a component for the java class description.
      * @param description
      * @return The generated component descriptor or null if any error occurs.
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
-    protected Component createComponent(JavaClassDescription description,
-                                        JavaTag componentTag,
-                                        MetaData metaData,
-                                        final IssueLog iLog)
-    throws MojoExecutionException {
+    protected Component createComponent( JavaClassDescription description, JavaTag componentTag, MetaData metaData,
+        final IssueLog iLog ) throws SCRDescriptorException
+    {
         // create a new component
-        final Component component = new Component(componentTag);
+        final Component component = new Component( componentTag );
 
         // set implementation
-        component.setImplementation(new Implementation(description.getName()));
+        component.setImplementation( new Implementation( description.getName() ) );
 
-        final OCD ocd = this.doComponent(componentTag, component, metaData, iLog);
+        final OCD ocd = this.doComponent( componentTag, component, metaData, iLog );
 
-        boolean inherited = getBoolean(componentTag, Constants.COMPONENT_INHERIT, true);
-        this.doServices(description.getTagsByName(Constants.SERVICE, inherited), component, description);
+        boolean inherited = getBoolean( componentTag, Constants.COMPONENT_INHERIT, true );
+        this.doServices( description.getTagsByName( Constants.SERVICE, inherited ), component, description );
 
         // collect references from class tags and fields
         final Map<String, Object[]> references = new HashMap<String, Object[]>();
         // Utility handler for propertie
-        final PropertyHandler propertyHandler = new PropertyHandler(component, ocd);
+        final PropertyHandler propertyHandler = new PropertyHandler( component, ocd );
 
         JavaClassDescription currentDescription = description;
-        do {
+        do
+        {
             // properties
-            final JavaTag[] props = currentDescription.getTagsByName(Constants.PROPERTY, false);
-            for (int i=0; i < props.length; i++) {
-                propertyHandler.testProperty(props[i], null, description == currentDescription);
+            final JavaTag[] props = currentDescription.getTagsByName( Constants.PROPERTY, false );
+            for ( int i = 0; i < props.length; i++ )
+            {
+                propertyHandler.testProperty( props[i], null, description == currentDescription );
             }
 
             // references
-            final JavaTag[] refs = currentDescription.getTagsByName(Constants.REFERENCE, false);
-            for (int i=0; i < refs.length; i++) {
-                this.testReference(references, refs[i], null, description == currentDescription);
+            final JavaTag[] refs = currentDescription.getTagsByName( Constants.REFERENCE, false );
+            for ( int i = 0; i < refs.length; i++ )
+            {
+                this.testReference( references, refs[i], null, description == currentDescription );
             }
 
             // fields
             final JavaField[] fields = currentDescription.getFields();
-            for (int i=0; i < fields.length; i++) {
-                JavaTag tag = fields[i].getTagByName(Constants.REFERENCE);
-                if (tag != null) {
-                    this.testReference(references, tag, fields[i].getName(), description == currentDescription);
+            for ( int i = 0; i < fields.length; i++ )
+            {
+                JavaTag tag = fields[i].getTagByName( Constants.REFERENCE );
+                if ( tag != null )
+                {
+                    this.testReference( references, tag, fields[i].getName(), description == currentDescription );
                 }
 
-                propertyHandler.handleField(fields[i], description == currentDescription);
+                propertyHandler.handleField( fields[i], description == currentDescription );
             }
 
             currentDescription = currentDescription.getSuperClass();
-        } while (inherited && currentDescription != null);
+        }
+        while ( inherited && currentDescription != null );
 
         // process properties
-        propertyHandler.processProperties(this.properties, iLog);
+        propertyHandler.processProperties( this.properties, iLog );
 
         // process references
         final Iterator<Map.Entry<String, Object[]>> refIter = references.entrySet().iterator();
-        while ( refIter.hasNext() ) {
+        while ( refIter.hasNext() )
+        {
             final Map.Entry<String, Object[]> entry = refIter.next();
             final String refName = entry.getKey();
             final Object[] values = entry.getValue();
-            final JavaTag tag = (JavaTag)values[0];
-            this.doReference(tag, refName, component, values[1].toString());
+            final JavaTag tag = ( JavaTag ) values[0];
+            this.doReference( tag, refName, component, values[1].toString() );
         }
 
         // pid handling
-        final boolean createPid = getBoolean(componentTag, Constants.COMPONENT_CREATE_PID, true);
-        if ( createPid ) {
+        final boolean createPid = getBoolean( componentTag, Constants.COMPONENT_CREATE_PID, true );
+        if ( createPid )
+        {
             // check for an existing pid first
             boolean found = false;
             final Iterator<Property> iter = component.getProperties().iterator();
-            while ( !found && iter.hasNext() ) {
+            while ( !found && iter.hasNext() )
+            {
                 final Property prop = iter.next();
                 found = org.osgi.framework.Constants.SERVICE_PID.equals( prop.getName() );
             }
-            if ( !found ) {
+            if ( !found )
+            {
                 final Property pid = new Property();
-                component.addProperty(pid);
-                pid.setName(org.osgi.framework.Constants.SERVICE_PID);
-                pid.setValue(component.getName());
+                component.addProperty( pid );
+                pid.setName( org.osgi.framework.Constants.SERVICE_PID );
+                pid.setValue( component.getName() );
             }
         }
         return component;
     }
 
+
     /**
      * Fill the component object with the information from the tag.
      * @param tag
      * @param component
      */
-    protected OCD doComponent(JavaTag tag, Component component, MetaData metaData,
-            final IssueLog iLog) {
+    protected OCD doComponent( JavaTag tag, Component component, MetaData metaData, final IssueLog iLog )
+    {
 
         // check if this is an abstract definition
-        final String abstractType = tag.getNamedParameter(Constants.COMPONENT_ABSTRACT);
-        if (abstractType != null) {
-            component.setAbstract("yes".equalsIgnoreCase(abstractType) || "true".equalsIgnoreCase(abstractType));
-        } else {
+        final String abstractType = tag.getNamedParameter( Constants.COMPONENT_ABSTRACT );
+        if ( abstractType != null )
+        {
+            component.setAbstract( "yes".equalsIgnoreCase( abstractType ) || "true".equalsIgnoreCase( abstractType ) );
+        }
+        else
+        {
             // default true for abstract classes, false otherwise
-            component.setAbstract(tag.getJavaClassDescription().isAbstract());
+            component.setAbstract( tag.getJavaClassDescription().isAbstract() );
         }
 
         // check if this is a definition to ignore
-        final String ds = tag.getNamedParameter(Constants.COMPONENT_DS);
-        component.setDs((ds == null) ? true : ("yes".equalsIgnoreCase(ds) || "true".equalsIgnoreCase(ds)));
+        final String ds = tag.getNamedParameter( Constants.COMPONENT_DS );
+        component.setDs( ( ds == null ) ? true : ( "yes".equalsIgnoreCase( ds ) || "true".equalsIgnoreCase( ds ) ) );
 
-        String name = tag.getNamedParameter(Constants.COMPONENT_NAME);
-        component.setName(StringUtils.isEmpty(name) ? component.getImplementation().getClassame() : name);
+        String name = tag.getNamedParameter( Constants.COMPONENT_NAME );
+        component.setName( StringUtils.isEmpty( name ) ? component.getImplementation().getClassame() : name );
 
-        component.setEnabled(Boolean.valueOf(getBoolean(tag, Constants.COMPONENT_ENABLED, true)));
-        component.setFactory(tag.getNamedParameter(Constants.COMPONENT_FACTORY));
+        component.setEnabled( Boolean.valueOf( getBoolean( tag, Constants.COMPONENT_ENABLED, true ) ) );
+        component.setFactory( tag.getNamedParameter( Constants.COMPONENT_FACTORY ) );
 
         // FELIX-593: immediate attribute does not default to true all the
         // times hence we only set it if declared in the tag
-        if (tag.getNamedParameter(Constants.COMPONENT_IMMEDIATE) != null) {
-            component.setImmediate(Boolean.valueOf(getBoolean(tag,
-                Constants.COMPONENT_IMMEDIATE, true)));
+        if ( tag.getNamedParameter( Constants.COMPONENT_IMMEDIATE ) != null )
+        {
+            component.setImmediate( Boolean.valueOf( getBoolean( tag, Constants.COMPONENT_IMMEDIATE, true ) ) );
         }
 
         // check for V1.1 attributes: configuration policy
-        if ( tag.getNamedParameter(Constants.COMPONENT_CONFIG_POLICY) != null ) {
-            component.setSpecVersion(Constants.VERSION_1_1);
-            component.setConfigurationPolicy(tag.getNamedParameter(Constants.COMPONENT_CONFIG_POLICY));
+        if ( tag.getNamedParameter( Constants.COMPONENT_CONFIG_POLICY ) != null )
+        {
+            component.setSpecVersion( Constants.VERSION_1_1 );
+            component.setConfigurationPolicy( tag.getNamedParameter( Constants.COMPONENT_CONFIG_POLICY ) );
         }
         // check for V1.1 attributes: activate, deactivate
-        if ( tag.getNamedParameter(Constants.COMPONENT_ACTIVATE) != null ) {
-            component.setSpecVersion(Constants.VERSION_1_1);
-            component.setActivate(tag.getNamedParameter(Constants.COMPONENT_ACTIVATE));
-        }
-        if ( tag.getNamedParameter(Constants.COMPONENT_DEACTIVATE) != null ) {
-            component.setSpecVersion(Constants.VERSION_1_1);
-            component.setDeactivate(tag.getNamedParameter(Constants.COMPONENT_DEACTIVATE));
-        }
-        if ( tag.getNamedParameter(Constants.COMPONENT_MODIFIED) != null ) {
-            component.setSpecVersion(Constants.VERSION_1_1);
-            component.setModified(tag.getNamedParameter(Constants.COMPONENT_MODIFIED));
+        if ( tag.getNamedParameter( Constants.COMPONENT_ACTIVATE ) != null )
+        {
+            component.setSpecVersion( Constants.VERSION_1_1 );
+            component.setActivate( tag.getNamedParameter( Constants.COMPONENT_ACTIVATE ) );
+        }
+        if ( tag.getNamedParameter( Constants.COMPONENT_DEACTIVATE ) != null )
+        {
+            component.setSpecVersion( Constants.VERSION_1_1 );
+            component.setDeactivate( tag.getNamedParameter( Constants.COMPONENT_DEACTIVATE ) );
+        }
+        if ( tag.getNamedParameter( Constants.COMPONENT_MODIFIED ) != null )
+        {
+            component.setSpecVersion( Constants.VERSION_1_1 );
+            component.setModified( tag.getNamedParameter( Constants.COMPONENT_MODIFIED ) );
         }
 
         // whether metatype information is to generated for the component
-        final String metaType = tag.getNamedParameter(Constants.COMPONENT_METATYPE);
-        final boolean hasMetaType = metaType == null || "yes".equalsIgnoreCase(metaType)
-            || "true".equalsIgnoreCase(metaType);
-        if ( hasMetaType ) {
+        final String metaType = tag.getNamedParameter( Constants.COMPONENT_METATYPE );
+        final boolean hasMetaType = metaType == null || "yes".equalsIgnoreCase( metaType )
+            || "true".equalsIgnoreCase( metaType );
+        if ( hasMetaType )
+        {
             // ocd
             final OCD ocd = new OCD();
-            metaData.addOCD(ocd);
-            ocd.setId(component.getName());
-            String ocdName = tag.getNamedParameter(Constants.COMPONENT_LABEL);
-            if ( ocdName == null ) {
+            metaData.addOCD( ocd );
+            ocd.setId( component.getName() );
+            String ocdName = tag.getNamedParameter( Constants.COMPONENT_LABEL );
+            if ( ocdName == null )
+            {
                 ocdName = "%" + component.getName() + ".name";
             }
-            ocd.setName(ocdName);
-            String ocdDescription = tag.getNamedParameter(Constants.COMPONENT_DESCRIPTION);
-            if ( ocdDescription == null ) {
+            ocd.setName( ocdName );
+            String ocdDescription = tag.getNamedParameter( Constants.COMPONENT_DESCRIPTION );
+            if ( ocdDescription == null )
+            {
                 ocdDescription = "%" + component.getName() + ".description";
             }
-            ocd.setDescription(ocdDescription);
+            ocd.setDescription( ocdDescription );
             // designate
             final Designate designate = new Designate();
-            metaData.addDesignate(designate);
-            designate.setPid(component.getName());
+            metaData.addDesignate( designate );
+            designate.setPid( component.getName() );
 
             // factory pid
-            final String setFactoryPidValue = tag.getNamedParameter(Constants.COMPONENT_SET_METATYPE_FACTORY_PID);
-            final boolean setFactoryPid = setFactoryPidValue != null &&
-                ("yes".equalsIgnoreCase(setFactoryPidValue) || "true".equalsIgnoreCase(setFactoryPidValue));
-            if ( setFactoryPid ) {
-                if ( component.getFactory() == null ) {
+            final String setFactoryPidValue = tag.getNamedParameter( Constants.COMPONENT_SET_METATYPE_FACTORY_PID );
+            final boolean setFactoryPid = setFactoryPidValue != null
+                && ( "yes".equalsIgnoreCase( setFactoryPidValue ) || "true".equalsIgnoreCase( setFactoryPidValue ) );
+            if ( setFactoryPid )
+            {
+                if ( component.getFactory() == null )
+                {
                     designate.setFactoryPid( component.getName() );
-                } else {
-                    iLog.addWarning("Component factory " + component.getName() + " should not set metatype factory pid.");
+                }
+                else
+                {
+                    iLog.addWarning( "Component factory " + component.getName()
+                        + " should not set metatype factory pid." );
                 }
             }
             // designate.object
             final MTObject mtobject = new MTObject();
-            designate.setObject(mtobject);
-            mtobject.setOcdref(component.getName());
+            designate.setObject( mtobject );
+            mtobject.setOcdref( component.getName() );
             return ocd;
         }
         return null;
     }
 
+
     /**
      * Process the service annotations
      * @param services
      * @param component
      * @param description
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
-    protected void doServices(JavaTag[] services, Component component, JavaClassDescription description)
-    throws MojoExecutionException {
+    protected void doServices( JavaTag[] services, Component component, JavaClassDescription description )
+        throws SCRDescriptorException
+    {
         // no services, hence certainly no service factory
-        if (services == null || services.length == 0) {
+        if ( services == null || services.length == 0 )
+        {
             return;
         }
 
         final Service service = new Service();
-        component.setService(service);
+        component.setService( service );
         boolean serviceFactory = false;
-        for (int i=0; i < services.length; i++) {
-            final String name = services[i].getNamedParameter(Constants.SERVICE_INTERFACE);
-            if (StringUtils.isEmpty(name)) {
+        for ( int i = 0; i < services.length; i++ )
+        {
+            final String name = services[i].getNamedParameter( Constants.SERVICE_INTERFACE );
+            if ( StringUtils.isEmpty( name ) )
+            {
 
-                this.addInterfaces(service, services[i], description);
-            } else {
+                this.addInterfaces( service, services[i], description );
+            }
+            else
+            {
                 String interfaceName = name;
                 // check if the value points to a class/interface
                 // and search through the imports
                 // but only for local services
-                if ( description instanceof QDoxJavaClassDescription ) {
-                    final JavaClassDescription serviceClass = description.getReferencedClass(name);
-                    if ( serviceClass == null ) {
-                        throw new MojoExecutionException("Interface '"+ name + "' in class " + description.getName() + " does not point to a valid class/interface.");
+                if ( description instanceof QDoxJavaClassDescription )
+                {
+                    final JavaClassDescription serviceClass = description.getReferencedClass( name );
+                    if ( serviceClass == null )
+                    {
+                        throw new SCRDescriptorException( "Interface '" + name + "' in class " + description.getName()
+                            + " does not point to a valid class/interface." );
                     }
                     interfaceName = serviceClass.getName();
                 }
-                final Interface interf = new Interface(services[i]);
-                interf.setInterfacename(interfaceName);
-                service.addInterface(interf);
+                final Interface interf = new Interface( services[i] );
+                interf.setInterfacename( interfaceName );
+                service.addInterface( interf );
             }
 
-            serviceFactory |= getBoolean(services[i], Constants.SERVICE_FACTORY, false);
+            serviceFactory |= getBoolean( services[i], Constants.SERVICE_FACTORY, false );
         }
 
-        service.setServicefactory(serviceFactory);
+        service.setServicefactory( serviceFactory );
     }
 
+
     /**
      * Recursively add interfaces to the service.
      */
-    protected void addInterfaces(final Service service, final JavaTag serviceTag, final JavaClassDescription description)
-    throws MojoExecutionException {
-        if ( description != null ) {
+    protected void addInterfaces( final Service service, final JavaTag serviceTag,
+        final JavaClassDescription description ) throws SCRDescriptorException
+    {
+        if ( description != null )
+        {
             JavaClassDescription[] interfaces = description.getImplementedInterfaces();
-            for (int j=0; j < interfaces.length; j++) {
-                final Interface interf = new Interface(serviceTag);
-                interf.setInterfacename(interfaces[j].getName());
-                service.addInterface(interf);
+            for ( int j = 0; j < interfaces.length; j++ )
+            {
+                final Interface interf = new Interface( serviceTag );
+                interf.setInterfacename( interfaces[j].getName() );
+                service.addInterface( interf );
                 // recursivly add interfaces implemented by this interface
-                this.addInterfaces(service, serviceTag, interfaces[j]);
+                this.addInterfaces( service, serviceTag, interfaces[j] );
             }
 
             // try super class
-            this.addInterfaces(service, serviceTag, description.getSuperClass());
+            this.addInterfaces( service, serviceTag, description.getSuperClass() );
         }
     }
 
+
     /**
      * Test a newly found reference
      * @param references
      * @param reference
      * @param defaultName
      * @param isInspectedClass
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
-    protected void testReference(Map<String, Object[]> references, JavaTag reference, String defaultName, boolean isInspectedClass)
-    throws MojoExecutionException {
-        final String refName = this.getReferenceName(reference, defaultName);
-
-        if ( refName != null ) {
-            if ( references.containsKey(refName) ) {
+    protected void testReference( Map<String, Object[]> references, JavaTag reference, String defaultName,
+        boolean isInspectedClass ) throws SCRDescriptorException
+    {
+        final String refName = this.getReferenceName( reference, defaultName );
+
+        if ( refName != null )
+        {
+            if ( references.containsKey( refName ) )
+            {
                 // if the current class is the class we are currently inspecting, we
                 // have found a duplicate definition
-                if ( isInspectedClass ) {
-                    throw new MojoExecutionException("Duplicate definition for reference " + refName + " in class " + reference.getJavaClassDescription().getName());
+                if ( isInspectedClass )
+                {
+                    throw new SCRDescriptorException( "Duplicate definition for reference " + refName + " in class "
+                        + reference.getJavaClassDescription().getName() );
                 }
-            } else {
+            }
+            else
+            {
                 // ensure interface
-                String type = reference.getNamedParameter(Constants.REFERENCE_INTERFACE);
-                if (StringUtils.isEmpty(type)) {
-                    if ( reference.getField() != null ) {
+                String type = reference.getNamedParameter( Constants.REFERENCE_INTERFACE );
+                if ( StringUtils.isEmpty( type ) )
+                {
+                    if ( reference.getField() != null )
+                    {
                         type = reference.getField().getType();
-                    } else {
-                        throw new MojoExecutionException("Interface missing for reference " + refName + " in class " + reference.getJavaClassDescription().getName());
                     }
-                } else if ( isInspectedClass ) {
+                    else
+                    {
+                        throw new SCRDescriptorException( "Interface missing for reference " + refName + " in class "
+                            + reference.getJavaClassDescription().getName() );
+                    }
+                }
+                else if ( isInspectedClass )
+                {
                     // check if the value points to a class/interface
                     // and search through the imports
-                    final JavaClassDescription serviceClass = reference.getJavaClassDescription().getReferencedClass(type);
-                    if ( serviceClass == null ) {
-                        throw new MojoExecutionException("Interface '"+ type + "' in class " + reference.getJavaClassDescription().getName() + " does not point to a valid class/interface.");
+                    final JavaClassDescription serviceClass = reference.getJavaClassDescription().getReferencedClass(
+                        type );
+                    if ( serviceClass == null )
+                    {
+                        throw new SCRDescriptorException( "Interface '" + type + "' in class "
+                            + reference.getJavaClassDescription().getName()
+                            + " does not point to a valid class/interface." );
                     }
                     type = serviceClass.getName();
                 }
-                references.put(refName, new Object[] {reference, type});
+                references.put( refName, new Object[]
+                    { reference, type } );
             }
         }
     }
 
-    protected String getReferenceName(JavaTag reference, String defaultName)
-    throws MojoExecutionException {
-        String name = reference.getNamedParameter(Constants.REFERENCE_NAME);
-        if (!StringUtils.isEmpty(name)) {
+
+    protected String getReferenceName( JavaTag reference, String defaultName ) throws SCRDescriptorException
+    {
+        String name = reference.getNamedParameter( Constants.REFERENCE_NAME );
+        if ( !StringUtils.isEmpty( name ) )
+        {
             return name;
         }
-        name = reference.getNamedParameter(Constants.REFERENCE_NAME_REF);
-        if (!StringUtils.isEmpty(name)) {
-            final JavaField refField = this.getReferencedField(reference, name);
+        name = reference.getNamedParameter( Constants.REFERENCE_NAME_REF );
+        if ( !StringUtils.isEmpty( name ) )
+        {
+            final JavaField refField = this.getReferencedField( reference, name );
             final String[] values = refField.getInitializationExpression();
-            if ( values == null || values.length == 0 ) {
-                throw new MojoExecutionException("Referenced field for " + name + " has no values for a reference name.");
-            }
-            if ( values.length > 1 ) {
-                throw new MojoExecutionException("Referenced field " + name + " has more than one value for a reference name.");
+            if ( values == null || values.length == 0 )
+            {
+                throw new SCRDescriptorException( "Referenced field for " + name
+                    + " has no values for a reference name." );
+            }
+            if ( values.length > 1 )
+            {
+                throw new SCRDescriptorException( "Referenced field " + name
+                    + " has more than one value for a reference name." );
             }
             name = values[0];
         }
@@ -664,64 +757,106 @@
         return defaultName;
     }
 
-    protected JavaField getReferencedField(final JavaTag tag, String ref)
-    throws MojoExecutionException {
-        int classSep = ref.lastIndexOf('.');
+
+    protected JavaField getReferencedField( final JavaTag tag, String ref ) throws SCRDescriptorException
+    {
+        int classSep = ref.lastIndexOf( '.' );
         JavaField field = null;
-        if ( classSep == -1 ) {
+        if ( classSep == -1 )
+        {
             // local variable
-            field = tag.getJavaClassDescription().getFieldByName(ref);
-        }
-        if ( field == null ) {
-            field = tag.getJavaClassDescription().getExternalFieldByName(ref);
+            field = tag.getJavaClassDescription().getFieldByName( ref );
         }
-        if ( field == null ) {
-            throw new MojoExecutionException("Reference references unknown field " + ref + " in class " + tag.getJavaClassDescription().getName());
+        if ( field == null )
+        {
+            field = tag.getJavaClassDescription().getExternalFieldByName( ref );
+        }
+        if ( field == null )
+        {
+            throw new SCRDescriptorException( "Reference references unknown field " + ref + " in class "
+                + tag.getJavaClassDescription().getName() );
         }
         return field;
     }
 
+
     /**
      * @param reference
      * @param defaultName
      * @param component
      */
-    protected void doReference(JavaTag reference, String name, Component component, String type)
-    throws MojoExecutionException {
-        final Reference ref = new Reference(reference, component.getJavaClassDescription());
-        ref.setName(name);
-        ref.setInterfacename(type);
-        ref.setCardinality(reference.getNamedParameter(Constants.REFERENCE_CARDINALITY));
-        if ( ref.getCardinality() == null ) {
-            ref.setCardinality("1..1");
-        }
-        ref.setPolicy(reference.getNamedParameter(Constants.REFERENCE_POLICY));
-        if ( ref.getPolicy() == null ) {
-            ref.setPolicy("static");
-        }
-        ref.setTarget(reference.getNamedParameter(Constants.REFERENCE_TARGET));
-        final String bindValue = reference.getNamedParameter(Constants.REFERENCE_BIND);
-        if ( bindValue != null ) {
-            ref.setBind(bindValue);
-        }
-        final String unbindValue = reference.getNamedParameter(Constants.REFERENCE_UNDBIND);
-        if ( unbindValue != null ) {
-            ref.setUnbind(unbindValue);
-        }
-        final String isChecked = reference.getNamedParameter(Constants.REFERENCE_CHECKED);
-        if ( isChecked != null ) {
-            ref.setChecked(Boolean.valueOf(isChecked).booleanValue());
-        }
-        final String strategy = reference.getNamedParameter(Constants.REFERENCE_STRATEGY);
-        if ( strategy != null ) {
-            ref.setStrategy(strategy);
-        }
-
-        component.addReference(ref);
-    }
-
-    public static boolean getBoolean(JavaTag tag, String name, boolean defaultValue) {
-        String value = tag.getNamedParameter(name);
-        return (value == null) ? defaultValue : Boolean.valueOf(value).booleanValue();
+    protected void doReference( JavaTag reference, String name, Component component, String type )
+        throws SCRDescriptorException
+    {
+        final Reference ref = new Reference( reference, component.getJavaClassDescription() );
+        ref.setName( name );
+        ref.setInterfacename( type );
+        ref.setCardinality( reference.getNamedParameter( Constants.REFERENCE_CARDINALITY ) );
+        if ( ref.getCardinality() == null )
+        {
+            ref.setCardinality( "1..1" );
+        }
+        ref.setPolicy( reference.getNamedParameter( Constants.REFERENCE_POLICY ) );
+        if ( ref.getPolicy() == null )
+        {
+            ref.setPolicy( "static" );
+        }
+        ref.setTarget( reference.getNamedParameter( Constants.REFERENCE_TARGET ) );
+        final String bindValue = reference.getNamedParameter( Constants.REFERENCE_BIND );
+        if ( bindValue != null )
+        {
+            ref.setBind( bindValue );
+        }
+        final String unbindValue = reference.getNamedParameter( Constants.REFERENCE_UNDBIND );
+        if ( unbindValue != null )
+        {
+            ref.setUnbind( unbindValue );
+        }
+        final String isChecked = reference.getNamedParameter( Constants.REFERENCE_CHECKED );
+        if ( isChecked != null )
+        {
+            ref.setChecked( Boolean.valueOf( isChecked ).booleanValue() );
+        }
+        final String strategy = reference.getNamedParameter( Constants.REFERENCE_STRATEGY );
+        if ( strategy != null )
+        {
+            ref.setStrategy( strategy );
+        }
+
+        component.addReference( ref );
+    }
+
+
+    public static boolean getBoolean( JavaTag tag, String name, boolean defaultValue )
+    {
+        String value = tag.getNamedParameter( name );
+        return ( value == null ) ? defaultValue : Boolean.valueOf( value ).booleanValue();
+    }
+
+
+    private void logMessages( final IssueLog iLog )
+    {
+        final Log log = logger;
+
+        // now log warnings and errors (warnings first)
+        // in strict mode everything is an error!
+        final Iterator<String> warnings = iLog.getWarnings();
+        while ( warnings.hasNext() )
+        {
+            if ( strictMode )
+            {
+                log.error( warnings.next() );
+            }
+            else
+            {
+                log.warn( warnings.next() );
+            }
+        }
+
+        final Iterator<String> errors = iLog.getErrors();
+        while ( errors.hasNext() )
+        {
+            log.error( errors.next() );
+        }
     }
 }

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

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

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

Copied: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java (from r820669, felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/IssueLog.java)
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java?p2=felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java&p1=felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/IssueLog.java&r1=820669&r2=820997&rev=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/IssueLog.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java Fri Oct  2 12:59:27 2009
@@ -16,13 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scrplugin;
+package org.apache.felix.scrplugin.helper;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
-import org.apache.maven.plugin.logging.Log;
-
 /**
  * Utility class for handling errors and warnings
  */
@@ -54,19 +53,11 @@
         warnings.add(e);
     }
 
-    public void log(final Log log) {
-        // now log warnings and errors (warnings first)
-        // in strict mode everything is an error!
-        for(String warn : warnings) {
-            if ( strictMode ) {
-                log.error(warn);
-            } else {
-                log.warn(warn);
-            }
-        }
-        for(String err : errors) {
-            log.error(err);
-        }
+    public Iterator<String> getWarnings() {
+        return warnings.iterator();
+    }
 
+    public Iterator<String> getErrors() {
+        return errors.iterator();
     }
 }

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

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

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

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/PropertyHandler.java (from r820669, felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java)
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/PropertyHandler.java?p2=felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/PropertyHandler.java&p1=felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java&r1=820669&r2=820997&rev=820997&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/PropertyHandler.java Fri Oct  2 12:59:27 2009
@@ -16,18 +16,23 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scrplugin;
-
-import java.util.*;
+package org.apache.felix.scrplugin.helper;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.SCRDescriptorGenerator;
 import org.apache.felix.scrplugin.om.Component;
 import org.apache.felix.scrplugin.om.Property;
 import org.apache.felix.scrplugin.om.metatype.AttributeDefinition;
 import org.apache.felix.scrplugin.om.metatype.OCD;
 import org.apache.felix.scrplugin.tags.JavaField;
 import org.apache.felix.scrplugin.tags.JavaTag;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.codehaus.plexus.util.StringUtils;
 import org.osgi.service.cm.ConfigurationAdmin;
 
 /**
@@ -62,7 +67,7 @@
                                    String    name,
                                    JavaField javaField,
                                    final IssueLog iLog)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final Property prop = new Property(tag);
         prop.setName(name);
         prop.setType(tag.getNamedParameter(Constants.PROPERTY_TYPE));
@@ -109,7 +114,7 @@
 
         // property is private if explicitly marked or a well known
         // service property such as service.pid
-        final boolean isPrivate = SCRDescriptorMojo.getBoolean(tag,
+        final boolean isPrivate = SCRDescriptorGenerator.getBoolean(tag,
             Constants.PROPERTY_PRIVATE, false)
             || name.equals(org.osgi.framework.Constants.SERVICE_PID)
             || name.equals(org.osgi.framework.Constants.SERVICE_DESCRIPTION)
@@ -200,7 +205,7 @@
      * @return The name of the property or the defaultName
      */
     protected String getPropertyName(JavaTag tag, JavaField field)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         // check name property
         String name = tag.getNamedParameter(Constants.PROPERTY_NAME);
 
@@ -211,10 +216,10 @@
                 final JavaField refField = this.getReferencedField(tag, name);
                 final String[] values = refField.getInitializationExpression();
                 if ( values == null || values.length == 0 ) {
-                    throw new MojoExecutionException("Referenced field for " + name + " has no values for a property name.");
+                    throw new SCRDescriptorException("Referenced field for " + name + " has no values for a property name.");
                 }
                 if ( values.length > 1 ) {
-                    throw new MojoExecutionException("Referenced field " + name + " has more than one value for a property name.");
+                    throw new SCRDescriptorException("Referenced field " + name + " has more than one value for a property name.");
                 }
                 name = values[0];
             }
@@ -238,7 +243,7 @@
     }
 
     protected void setPropertyValueRef(final JavaTag tag, Property property, String valueRef)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final String[] values = this.getPropertyValueRef(tag, property, valueRef);
         if ( values != null && values.length == 1 ) {
             property.setValue(values[0]);
@@ -248,7 +253,7 @@
     }
 
     protected JavaField getReferencedField(final JavaTag tag, String ref)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         int classSep = ref.lastIndexOf('.');
         JavaField field = null;
         if ( classSep == -1 ) {
@@ -259,13 +264,13 @@
             field = tag.getJavaClassDescription().getExternalFieldByName(ref);
         }
         if ( field == null ) {
-            throw new MojoExecutionException("Property references unknown field " + ref + " in class " + tag.getJavaClassDescription().getName());
+            throw new SCRDescriptorException("Property references unknown field " + ref + " in class " + tag.getJavaClassDescription().getName());
         }
         return field;
     }
 
     protected String[] getPropertyValueRef(final JavaTag tag, Property prop, String valueRef)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final JavaField field = this.getReferencedField(tag, valueRef);
 
         // determine type (if not set explicitly)
@@ -300,12 +305,12 @@
      * @param property The tag.
      * @param field
      * @param isInspectedClass
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
     public void testProperty(JavaTag   property,
                              JavaField field,
                              boolean   isInspectedClass)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final String propName = this.getPropertyName(property, field);
 
         if ( propName != null ) {
@@ -313,18 +318,18 @@
                 // if the current class is the class we are currently inspecting, we
                 // have found a duplicate definition
                 if ( isInspectedClass ) {
-                    throw new MojoExecutionException("Duplicate definition for property " + propName + " in class " + property.getJavaClassDescription().getName());
+                    throw new SCRDescriptorException("Duplicate definition for property " + propName + " in class " + property.getJavaClassDescription().getName());
                 }
             } else {
                 properties.put(propName, new PropertyDescription(property, field));
             }
         } else {
-            throw new MojoExecutionException("Property has no name " + property.getSourceLocation());
+            throw new SCRDescriptorException("Property has no name " + property.getSourceLocation());
         }
     }
 
     public void handleField(JavaField javaField, boolean isInspectedClass)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final JavaTag tag = javaField.getTagByName(Constants.PROPERTY);
         if (tag != null) {
             this.testProperty(tag, javaField, isInspectedClass);
@@ -335,11 +340,11 @@
      * Process all found properties for the component.
      * @param globalProperties Global properties are set on all components.
      * @param iLog The issue log.
-     * @throws MojoExecutionException
+     * @throws SCRDescriptorException
      */
     public void processProperties(final Map<String, String> globalProperties,
                                   final IssueLog iLog)
-    throws MojoExecutionException {
+    throws SCRDescriptorException {
         final Iterator<Map.Entry<String, PropertyDescription>> propIter = properties.entrySet().iterator();
         while ( propIter.hasNext() ) {
             final Map.Entry<String, PropertyDescription> entry = propIter.next();

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

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

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

Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/StringUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/StringUtils.java?rev=820997&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/StringUtils.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/helper/StringUtils.java Fri Oct  2 12:59:27 2009
@@ -0,0 +1,52 @@
+/*
+ * 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.helper;
+
+
+public class StringUtils
+{
+
+    public static String[] split( String value, String sep )
+    {
+        return value.split( sep );
+    }
+
+
+    public static boolean isEmpty( final String string )
+    {
+        return string == null || string.length() == 0;
+    }
+
+
+    public static String leftPad( final String base, final int width, final String pad )
+    {
+        StringBuilder builder = new StringBuilder( width );
+
+        int missing = width - base.length();
+        while ( missing > 0 )
+        {
+            builder.append( pad );
+            missing -= pad.length();
+        }
+
+        builder.append( base );
+
+        return builder.toString();
+    }
+}

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

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