FELIX-1010 : Add annotations support for SCR plugin. Apply patch from Stefan Seifert

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@760528 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/pom.xml b/scrplugin/pom.xml
index 5432ddb..a704547 100644
--- a/scrplugin/pom.xml
+++ b/scrplugin/pom.xml
@@ -97,5 +97,29 @@
             <artifactId>slf4j-simple</artifactId>
             <version>1.4.3</version>
         </dependency>
+        
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>maven-scr-plugin-annotations</artifactId>
+			<version>1.0.11-SNAPSHOT</version>
+		</dependency>
+		
 	</dependencies>
+	
+	<build>
+		<plugins>
+
+		  <!-- JDK 1.5 needed for annotation support -->
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+				  <source>1.5</source>
+				  <target>1.5</target>
+				</configuration>
+			</plugin>
+			
+		</plugins>
+  </build>
+	
 </project>
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
index f7e5e6e..266148a 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
@@ -39,7 +39,7 @@
      * This is a map using the property name as the key and
      * {@link PropertyDescription} as values.
      */
-    final private Map properties = new LinkedHashMap();
+    final private Map<String, PropertyDescription> properties = new LinkedHashMap<String, PropertyDescription>();
 
     /** The component. */
     final private Component component;
@@ -76,15 +76,15 @@
                 this.setPropertyValueRef(tag, prop, valueRef);
             } else {
                 // check for multivalue - these can either be values or value refs
-                final List values = new ArrayList();
-                final Map valueMap = tag.getNamedParameterMap();
-                for (Iterator vi = valueMap.entrySet().iterator(); vi.hasNext();) {
-                    final Map.Entry entry = (Map.Entry) vi.next();
-                    final String key = (String) entry.getKey();
+                final List<String> values = new ArrayList<String>();
+                final Map<String, String> valueMap = tag.getNamedParameterMap();
+                for (Iterator<Map.Entry<String, String>> vi = valueMap.entrySet().iterator(); vi.hasNext();) {
+                    final Map.Entry<String, String> entry = vi.next();
+                    final String key = entry.getKey();
                     if (key.startsWith(Constants.PROPERTY_MULTIVALUE_PREFIX) ) {
                         values.add(entry.getValue());
                     } else if ( key.startsWith(Constants.PROPERTY_MULTIVALUE_REF_PREFIX) ) {
-                        final String[] stringValues = this.getPropertyValueRef(tag, prop, (String)entry.getValue());
+                        final String[] stringValues = this.getPropertyValueRef(tag, prop, entry.getValue());
                         if ( stringValues != null ) {
                             for(int i=0; i<stringValues.length; i++) {
                                 values.add(stringValues[i]);
@@ -93,7 +93,7 @@
                     }
                 }
                 if ( values.size() > 0 ) {
-                    prop.setMultiValue((String[])values.toArray(new String[values.size()]));
+                    prop.setMultiValue(values.toArray(new String[values.size()]));
                 } else {
                     // we have no value, valueRef or values so let's try to
                     // get the value of the field if a name attribute is specified
@@ -166,10 +166,10 @@
 
             // check options
             String[] parameters = tag.getParameters();
-            Map options = null;
+            Map<String, String> options = null;
             for (int j=0; j < parameters.length; j++) {
                 if (Constants.PROPERTY_OPTIONS.equals(parameters[j])) {
-                    options = new LinkedHashMap();
+                    options = new LinkedHashMap<String, String>();
                 } else if (options != null) {
                     String optionLabel = parameters[j];
                     String optionValue = (j < parameters.length-2) ? parameters[j+2] : null;
@@ -334,25 +334,25 @@
      * Process all found properties for the component.
      * @throws MojoExecutionException
      */
-    public void processProperties(final Map globalProperties)
+    public void processProperties(final Map<String, String> globalProperties)
     throws MojoExecutionException {
-        final Iterator propIter = properties.entrySet().iterator();
+        final Iterator<Map.Entry<String, PropertyDescription>> propIter = properties.entrySet().iterator();
         while ( propIter.hasNext() ) {
-            final Map.Entry entry = (Map.Entry)propIter.next();
-            final String propName = entry.getKey().toString();
-            final PropertyDescription desc = (PropertyDescription)entry.getValue();
+            final Map.Entry<String, PropertyDescription> entry = propIter.next();
+            final String propName = entry.getKey();
+            final PropertyDescription desc = entry.getValue();
             this.processProperty(desc.propertyTag, propName, desc.field);
         }
         // apply pre configured global properties
         if ( globalProperties != null ) {
-            final Iterator globalPropIter = globalProperties.entrySet().iterator();
+            final Iterator<Map.Entry<String, String>> globalPropIter = globalProperties.entrySet().iterator();
             while ( globalPropIter.hasNext() ) {
-                final Map.Entry entry = (Map.Entry)globalPropIter.next();
-                final String name = entry.getKey().toString();
+                final Map.Entry<String, String> entry = globalPropIter.next();
+                final String name = entry.getKey();
 
                 // check if the service already provides this property
                 if ( !properties.containsKey(name) && entry.getValue() != null ) {
-                    final String value = entry.getValue().toString();
+                    final String value = entry.getValue();
 
                     final Property p = new Property();
                     p.setName(name);
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
index 283e326..c1fa0a7 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
@@ -92,7 +92,18 @@
      *
      * @parameter
      */
-    private Map properties = new HashMap();
+    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 = {};
 
     /**
      * @see org.apache.maven.plugin.AbstractMojo#execute()
@@ -105,6 +116,7 @@
 
         JavaClassDescriptorManager jManager = new JavaClassDescriptorManager(this.getLog(),
                                                                              this.project,
+                                                                             this.annotationTagProviders,
                                                                              this.sourceExcludes);
         // iterate through all source classes and check for component tag
         final JavaClassDescription[] javaSources = jManager.getSourceDescriptions();
@@ -154,9 +166,10 @@
         // 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 ( metaData.getDescriptors().size() > 0 ) {
+            final int size = metaData.getOCDs().size() + metaData.getDesignates().size();
+            if (size > 0 ) {
                 this.getLog().info("Generating "
-                    + metaData.getDescriptors().size()
+                    + size
                     + " MetaType Descriptors to " + mtFile);
                 mtFile.getParentFile().mkdirs();
                 MetaTypeIO.write(metaData, mtFile);
@@ -223,9 +236,10 @@
         if (addResources) {
             final String ourRsrcPath = this.outputDirectory.getAbsolutePath();
             boolean found = false;
-            final Iterator rsrcIterator = this.project.getResources().iterator();
+            @SuppressWarnings("unchecked")
+            final Iterator<Resource> rsrcIterator = this.project.getResources().iterator();
             while ( !found && rsrcIterator.hasNext() ) {
-                final Resource rsrc = (Resource)rsrcIterator.next();
+                final Resource rsrc = rsrcIterator.next();
                 found = rsrc.getDirectory().equals(ourRsrcPath);
             }
             if ( !found ) {
@@ -256,7 +270,7 @@
         this.doServices(description.getTagsByName(Constants.SERVICE, inherited), component, description);
 
         // collect references from class tags and fields
-        final Map references = new HashMap();
+        final Map<String, Object[]> references = new HashMap<String, Object[]>();
         // Utility handler for propertie
         final PropertyHandler propertyHandler = new PropertyHandler(component, ocd);
 
@@ -292,11 +306,11 @@
         propertyHandler.processProperties(this.properties);
 
         // process references
-        final Iterator refIter = references.entrySet().iterator();
+        final Iterator<Map.Entry<String, Object[]>> refIter = references.entrySet().iterator();
         while ( refIter.hasNext() ) {
-            final Map.Entry entry = (Map.Entry)refIter.next();
-            final String refName = entry.getKey().toString();
-            final Object[] values = (Object[])entry.getValue();
+            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());
         }
@@ -306,9 +320,9 @@
         if ( createPid ) {
             // check for an existing pid first
             boolean found = false;
-            final Iterator iter = component.getProperties().iterator();
+            final Iterator<Property> iter = component.getProperties().iterator();
             while ( !found && iter.hasNext() ) {
-                final Property prop = (Property)iter.next();
+                final Property prop = iter.next();
                 found = org.osgi.framework.Constants.SERVICE_PID.equals( prop.getName() );
             }
             if ( !found ) {
@@ -319,18 +333,18 @@
             }
         }
 
-        final List issues = new ArrayList();
-        final List warnings = new ArrayList();
+        final List<String> issues = new ArrayList<String>();
+        final List<String> warnings = new ArrayList<String>();
         component.validate(issues, warnings);
 
         // now log warnings and errors (warnings first)
-        Iterator i = warnings.iterator();
+        Iterator<String> i = warnings.iterator();
         while ( i.hasNext() ) {
-            this.getLog().warn((String)i.next());
+            this.getLog().warn(i.next());
         }
         i = issues.iterator();
         while ( i.hasNext() ) {
-            this.getLog().error((String)i.next());
+            this.getLog().error(i.next());
         }
 
         // return nothing if validation fails
@@ -475,7 +489,7 @@
      * @param isInspectedClass
      * @throws MojoExecutionException
      */
-    protected void testReference(Map references, JavaTag reference, String defaultName, boolean isInspectedClass)
+    protected void testReference(Map<String, Object[]> references, JavaTag reference, String defaultName, boolean isInspectedClass)
     throws MojoExecutionException {
         final String refName = this.getReferenceName(reference, defaultName);
 
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
index 70055cc..20f5f0c 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
@@ -18,7 +18,8 @@
  */
 package org.apache.felix.scrplugin.om;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.felix.scrplugin.tags.*;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -46,13 +47,13 @@
     protected Implementation implementation;
 
     /** All properties. */
-    protected List properties = new ArrayList();
+    protected List<Property> properties = new ArrayList<Property>();
 
     /** The corresponding service. */
     protected Service service;
 
     /** The references. */
-    protected List references = new ArrayList();
+    protected List<Reference> references = new ArrayList<Reference>();
 
     /** Is this an abstract description? */
     protected boolean isAbstract;
@@ -87,11 +88,11 @@
     /**
      * @return All properties of this component.
      */
-    public List getProperties() {
+    public List<Property> getProperties() {
         return this.properties;
     }
 
-    public void setProperties(List properties) {
+    public void setProperties(List<Property> properties) {
         this.properties = properties;
     }
 
@@ -147,11 +148,11 @@
         this.service = service;
     }
 
-    public List getReferences() {
+    public List<Reference> getReferences() {
         return this.references;
     }
 
-    public void setReferences(List references) {
+    public void setReferences(List<Reference> references) {
         this.references = references;
     }
 
@@ -180,7 +181,7 @@
      * If errors occur a message is added to the issues list,
      * warnings can be added to the warnings list.
      */
-    public void validate(List issues, List warnings)
+    public void validate(List<String> issues, List<String> warnings)
     throws MojoExecutionException {
         final int currentIssueCount = issues.size();
 
@@ -231,8 +232,7 @@
                     }
 
                     // verify properties
-                    for (Iterator pi = this.getProperties().iterator(); pi.hasNext();) {
-                        Property prop = (Property) pi.next();
+                    for(final Property prop : this.getProperties()) {
                         prop.validate(issues, warnings);
                     }
 
@@ -259,8 +259,7 @@
             }
             if ( issues.size() == currentIssueCount ) {
                 // verify references
-                for (Iterator ri = this.getReferences().iterator(); ri.hasNext();) {
-                    final Reference ref = (Reference) ri.next();
+                for(final Reference ref : this.getReferences()) {
                     ref.validate(issues, warnings, this.isAbstract);
                 }
             }
@@ -273,7 +272,7 @@
      * @param methodName The method name.
      * @param warnings The list of warnings used to add new warnings.
      */
-    protected void checkLifecycleMethod(JavaClassDescription javaClass, String methodName, List warnings)
+    protected void checkLifecycleMethod(JavaClassDescription javaClass, String methodName, List<String> warnings)
     throws MojoExecutionException {
         final JavaMethod method = javaClass.getMethodBySignature(methodName, new String[] {"org.osgi.service.component.ComponentContext"});
         if ( method != null ) {
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Components.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Components.java
index b3db488..05f2944 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Components.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Components.java
@@ -29,19 +29,19 @@
 public class Components {
 
     /** The list of {@link Component}s. */
-    protected List components = new ArrayList();
+    protected List<Component> components = new ArrayList<Component>();
 
     /**
      * Return the list of {@link Component}s.
      */
-    public List getComponents() {
+    public List<Component> getComponents() {
         return this.components;
     }
 
     /**
      * Set the list of {@link Component}s.
      */
-    public void setComponents(List components) {
+    public void setComponents(List<Component> components) {
         this.components = components;
     }
 
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Interface.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Interface.java
index eb798e8..956c3b1 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Interface.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Interface.java
@@ -59,7 +59,7 @@
      * If errors occur a message is added to the issues list,
      * warnings can be added to the warnings list.
      */
-    public void validate(List issues, List warnings)
+    public void validate(List<String> issues, List<String> warnings)
     throws MojoExecutionException {
         final JavaClassDescription javaClass = this.tag.getJavaClassDescription();
         if (javaClass == null) {
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java
index 1880d01..265b35d 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java
@@ -91,7 +91,7 @@
      * If errors occur a message is added to the issues list,
      * warnings can be added to the warnings list.
      */
-    public void validate(List issues, List warnings) {
+    public void validate(List<String> issues, List<String> warnings) {
         if ( name == null || name.trim().length() == 0 ) {
             issues.add(this.getMessage("Property name can not be empty."));
         }
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
index 764be66..3bf26f3 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
@@ -37,7 +37,7 @@
     protected String policy;
     protected String bind;
     protected String unbind;
-    
+
     /** @since 1.0.9 */
     protected String strategy;
 
@@ -128,7 +128,7 @@
     public void setChecked(boolean checked) {
         this.checked = checked;
     }
-    
+
     /** @since 1.0.9 */
     public String getStrategy() {
         return strategy;
@@ -138,7 +138,7 @@
     public void setStrategy(String strategy) {
         this.strategy = strategy;
     }
-    
+
     /** @since 1.0.9 */
     public boolean isLookupStrategy() {
         return "lookup".equals(getStrategy());
@@ -149,7 +149,7 @@
      * If errors occur a message is added to the issues list,
      * warnings can be added to the warnings list.
      */
-    public void validate(List issues, List warnings, boolean componentIsAbstract)
+    public void validate(List<String> issues, List<String> warnings, boolean componentIsAbstract)
     throws MojoExecutionException {
         // if this reference is already checked, return immediately
         if ( this.checked ) {
@@ -181,7 +181,7 @@
         } else if (!"static".equals(this.policy) && !"dynamic".equals(this.policy)) {
             issues.add(this.getMessage("Invalid Policy specification " + this.policy));
         }
-        
+
         // validate strategy
         if (this.strategy == null) {
             this.strategy = "event";
@@ -214,9 +214,9 @@
         }
     }
 
-    protected String validateMethod(String  methodName,
-                                    List    issues,
-                                    List    warnings,
+    protected String validateMethod(String       methodName,
+                                    List<String> issues,
+                                    List<String> warnings,
                                     boolean componentIsAbstract)
     throws MojoExecutionException {
         final JavaMethod method = this.findMethod(methodName);
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java
index 02a4435..aa18742 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java
@@ -31,7 +31,7 @@
     protected boolean isServicefactory;
 
     /** The list of implemented interfaces. */
-    protected final List interfaces = new ArrayList();
+    protected final List<Interface> interfaces = new ArrayList<Interface>();
 
     /**
      * Default constructor.
@@ -54,7 +54,7 @@
         this.isServicefactory = flag;
     }
 
-    public List getInterfaces() {
+    public List<Interface> getInterfaces() {
         return this.interfaces;
     }
 
@@ -64,9 +64,9 @@
      * @return The interface if it is implemented by this service or null.
      */
     public Interface findInterface(String name) {
-        final Iterator i = this.interfaces.iterator();
+        final Iterator<Interface> i = this.getInterfaces().iterator();
         while ( i.hasNext() ) {
-            final Interface current = (Interface)i.next();
+            final Interface current = i.next();
             if ( current.getInterfacename().equals(name) ) {
                 return current;
             }
@@ -90,11 +90,9 @@
      * If errors occur a message is added to the issues list,
      * warnings can be added to the warnings list.
      */
-    public void validate(List issues, List warnings)
+    public void validate(List<String> issues, List<String> warnings)
     throws MojoExecutionException {
-        final Iterator i = this.interfaces.iterator();
-        while ( i.hasNext() ) {
-            final Interface interf = (Interface)i.next();
+        for(final Interface interf : this.getInterfaces()) {
             interf.validate(issues, warnings);
         }
     }
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
index 8f63f66..c32ccb1 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
@@ -38,7 +38,7 @@
 
     protected Integer cardinality;
 
-    protected Map options;
+    protected Map<String, String> options;
 
     public String getId() {
         return this.id;
@@ -108,11 +108,11 @@
         this.cardinality = cardinality;
     }
 
-    public Map getOptions() {
+    public Map<String, String> getOptions() {
         return this.options;
     }
 
-    public void setOptions(Map options) {
+    public void setOptions(Map<String, String> options) {
         this.options = options;
     }
 }
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/MetaData.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/MetaData.java
index e1084e1..33841cd 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/MetaData.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/MetaData.java
@@ -18,14 +18,16 @@
  */
 package org.apache.felix.scrplugin.om.metatype;
 
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
 
 public class MetaData {
 
     protected String localization;
 
-    protected List descriptors = new ArrayList();
+    protected List<OCD> ocds = new ArrayList<OCD>();
+
+    protected List<Designate> designates = new ArrayList<Designate>();
 
     public String getLocalization() {
         return this.localization;
@@ -35,15 +37,19 @@
         this.localization = localization;
     }
 
-    public List getDescriptors() {
-        return this.descriptors;
+    public List<OCD> getOCDs() {
+        return this.ocds;
+    }
+
+    public List<Designate> getDesignates() {
+        return this.designates;
     }
 
     public void addOCD(OCD ocd) {
-        this.descriptors.add(ocd);
+        this.ocds.add(ocd);
     }
 
     public void addDesignate(Designate d) {
-        this.descriptors.add(d);
+        this.designates.add(d);
     }
 }
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java
index 50dd6c7..f167d49 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java
@@ -29,7 +29,7 @@
 
     protected String description;
 
-    protected List properties = new ArrayList();
+    protected List<AttributeDefinition> properties = new ArrayList<AttributeDefinition>();
 
     public String getId() {
         return this.id;
@@ -55,11 +55,11 @@
         this.description = description;
     }
 
-    public List getProperties() {
+    public List<AttributeDefinition> getProperties() {
         return this.properties;
     }
 
-    public void setProperties(List properties) {
+    public void setProperties(List<AttributeDefinition> properties) {
         this.properties = properties;
     }
 }
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java
index 2980bb1..80a9cbe 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java
@@ -37,14 +37,11 @@
  * <li>Finally, the natural order of the class names is returned
  * </ol>
  */
-public class JavaClassDescriptionInheritanceComparator implements Comparator
+public class JavaClassDescriptionInheritanceComparator implements Comparator<JavaClassDescription>
 {
 
-    public int compare( Object o1, Object o2 )
+    public int compare( JavaClassDescription cd1, JavaClassDescription cd2 )
     {
-        JavaClassDescription cd1 = ( JavaClassDescription ) o1;
-        JavaClassDescription cd2 = ( JavaClassDescription ) o2;
-
         // the descriptors are the same
         if ( equals( cd1, cd2 ) )
         {
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
index 48035e2..1d060c6 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
@@ -27,6 +27,8 @@
 import org.apache.felix.scrplugin.Constants;
 import org.apache.felix.scrplugin.om.Component;
 import org.apache.felix.scrplugin.om.Components;
+import org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription;
+import org.apache.felix.scrplugin.tags.annotation.AnnotationTagProviderManager;
 import org.apache.felix.scrplugin.tags.cl.ClassLoaderJavaClassDescription;
 import org.apache.felix.scrplugin.tags.qdox.QDoxJavaClassDescription;
 import org.apache.felix.scrplugin.xml.ComponentDescriptorIO;
@@ -59,41 +61,50 @@
     protected final ClassLoader classloader;
 
     /** A cache containing the java class descriptions hashed by classname. */
-    protected final Map javaClassDescriptions = new HashMap();
+    protected final Map<String, JavaClassDescription> javaClassDescriptions = new HashMap<String, JavaClassDescription>();
 
     /** The component definitions from other bundles hashed by classname. */
-    protected final Map componentDescriptions = new HashMap();
+    protected final Map<String, Component> componentDescriptions = new HashMap<String, Component>();
 
     /** The maven project. */
     protected final MavenProject project;
 
     /**
+     * Supports mapping of built-in and custom java anntoations to {@link JavaTag} implementations.
+     */
+    protected final AnnotationTagProviderManager annotationTagProviderManager;
+
+    /**
      * Construct a new manager.
      * @param log
      * @param project
+     * @param annotationTagProviders List of annotation tag providers
      * @throws MojoFailureException
      * @throws MojoExecutionException
      */
     public JavaClassDescriptorManager(final Log          log,
                                       final MavenProject project,
+                                      final String[] annotationTagProviders,
                                       final String       excludeString)
     throws MojoFailureException, MojoExecutionException {
         this.log = log;
         this.project = project;
+        this.annotationTagProviderManager = new AnnotationTagProviderManager(annotationTagProviders);
         this.classloader = this.getCompileClassLoader();
 
         // get all the class sources through qdox
         this.log.debug("Setting up QDox");
         JavaDocBuilder builder = new JavaDocBuilder();
         builder.getClassLibrary().addClassLoader(this.classloader);
-        final Iterator i = project.getCompileSourceRoots().iterator();
+        @SuppressWarnings("unchecked")
+        final Iterator<String> i = project.getCompileSourceRoots().iterator();
         // FELIX-509: check for excludes
         if ( excludeString != null ) {
             final String[] excludes = StringUtils.split(excludeString, ",");
             final String[] includes = new String[] {"**/*.java"};
 
             while ( i.hasNext() ) {
-                final String tree = (String)i.next();
+                final String tree = i.next();
                 this.log.debug("Scanning source tree " + tree);
                 final File directory = new File(tree);
                 final DirectoryScanner scanner = new DirectoryScanner();
@@ -123,7 +134,7 @@
             }
         } else {
             while ( i.hasNext() ) {
-                final String tree = (String)i.next();
+                final String tree = i.next();
                 this.log.debug("Adding source tree " + tree);
                 final File directory = new File(tree);
                 builder.addSourceTree(directory);
@@ -132,19 +143,21 @@
         this.sources = builder.getSources();
 
         // and now scan artifacts
-        final List components = new ArrayList();
-        final Map resolved = project.getArtifactMap();
-        final Set artifacts = project.getDependencyArtifacts();
-        final Iterator it = artifacts.iterator();
+        final List<Component> components = new ArrayList<Component>();
+        @SuppressWarnings("unchecked")
+        final Map<String, Artifact> resolved = project.getArtifactMap();
+        @SuppressWarnings("unchecked")
+        final Set<Artifact> artifacts = project.getDependencyArtifacts();
+        final Iterator<Artifact> it = artifacts.iterator();
         while ( it.hasNext() ) {
-            final Artifact declared = (Artifact) it.next();
+            final Artifact declared = it.next();
             this.log.debug("Checking artifact " + declared);
             if ( this.isJavaArtifact(declared)) {
                 if (Artifact.SCOPE_COMPILE.equals(declared.getScope())
                     || Artifact.SCOPE_RUNTIME.equals(declared.getScope())
                     || Artifact.SCOPE_PROVIDED.equals(declared.getScope())) {
                     this.log.debug("Resolving artifact " + declared);
-                    final Artifact artifact = (Artifact) resolved.get(ArtifactUtils.versionlessKey(declared));
+                    final Artifact artifact = resolved.get(ArtifactUtils.versionlessKey(declared));
                     if (artifact != null) {
                         this.log.debug("Trying to get manifest from artifact " + artifact);
                         try {
@@ -197,9 +210,7 @@
             }
         }
         // now create map with component descriptions
-        final Iterator cI = components.iterator();
-        while ( cI.hasNext() ) {
-            final Component component = (Component) cI.next();
+        for(final Component component : components) {
             this.componentDescriptions.put(component.getImplementation().getClassame(), component);
         }
     }
@@ -239,6 +250,13 @@
     }
 
     /**
+     * @return Annotation tag provider manager
+     */
+    public AnnotationTagProviderManager getAnnotationTagProviderManager() {
+        return this.annotationTagProviderManager;
+    }
+
+    /**
      * Read the service component description.
      * @param artifact
      * @param entry
@@ -272,11 +290,12 @@
 
     protected ClassLoader getCompileClassLoader()
     throws MojoFailureException {
-        List artifacts = this.getProject().getCompileArtifacts();
+        @SuppressWarnings("unchecked")
+        List<Artifact> artifacts = this.getProject().getCompileArtifacts();
         URL[] path = new URL[artifacts.size() + 1];
         int i = 0;
-        for (Iterator ai=artifacts.iterator(); ai.hasNext(); ) {
-            Artifact a = (Artifact) ai.next();
+        for (Iterator<Artifact> ai=artifacts.iterator(); ai.hasNext(); ) {
+            Artifact a = ai.next();
             try {
                 path[i++] = a.getFile().toURI().toURL();
             } catch (IOException ioe) {
@@ -343,7 +362,13 @@
         for(int i=0; i<this.sources.length; i++) {
             final String className = this.sources[i].getClasses()[0].getFullyQualifiedName();
             try {
-                descs[i] = new QDoxJavaClassDescription(this.classloader.loadClass(className), this.sources[i], this);
+                // check for java annotation descriptions - fallback to QDox if none found
+                Class clazz = this.classloader.loadClass(className);
+                if (getAnnotationTagProviderManager().hasScrPluginAnnotation(clazz)) {
+                    descs[i] = new AnnotationJavaClassDescription(clazz, this.sources[i], this);
+                } else {
+                    descs[i] = new QDoxJavaClassDescription(clazz, this.sources[i], this);
+                }
             } catch (ClassNotFoundException e) {
                 throw new MojoExecutionException("Unable to load class " + className);
             }
@@ -359,15 +384,22 @@
      */
     public JavaClassDescription getJavaClassDescription(String className)
     throws MojoExecutionException {
-        JavaClassDescription result = (JavaClassDescription) this.javaClassDescriptions.get(className);
+        JavaClassDescription result = this.javaClassDescriptions.get(className);
         if ( result == null ) {
             this.log.debug("Searching description for: " + className);
             int index = 0;
             while ( result == null && index < this.sources.length) {
                 if ( this.sources[index].getClasses()[0].getFullyQualifiedName().equals(className) ) {
                     try {
-                        this.log.debug("Found qdox description for: " + className);
-                        result = new QDoxJavaClassDescription(this.classloader.loadClass(className), this.sources[index], this);
+                        // check for java annotation descriptions - fallback to QDox if none found
+                        Class clazz = this.classloader.loadClass(className);
+                        if (getAnnotationTagProviderManager().hasScrPluginAnnotation(clazz)) {
+                            this.log.debug("Found java annotation description for: " + className);
+                            result = new AnnotationJavaClassDescription(clazz, this.sources[index], this);
+                        } else {
+                            this.log.debug("Found qdox description for: " + className);
+                            result = new QDoxJavaClassDescription(clazz, this.sources[index], this);
+                        }
                     } catch (ClassNotFoundException e) {
                         throw new MojoExecutionException("Unable to load class " + className);
                     }
@@ -378,7 +410,7 @@
             if ( result == null ) {
                 try {
                     this.log.debug("Generating classloader description for: " + className);
-                    result = new ClassLoaderJavaClassDescription(this.classloader.loadClass(className), (Component)this.componentDescriptions.get(className), this);
+                    result = new ClassLoaderJavaClassDescription(this.classloader.loadClass(className), this.componentDescriptions.get(className), this);
                 } catch (ClassNotFoundException e) {
                     throw new MojoExecutionException("Unable to load class " + className);
                 }
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaTag.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaTag.java
index fb8503d..ba82aa1 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaTag.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaTag.java
@@ -38,5 +38,5 @@
 
     JavaField getField();
 
-    Map getNamedParameterMap();
+    Map<String, String> getNamedParameterMap();
 }
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
new file mode 100644
index 0000000..5bc342c
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
@@ -0,0 +1,134 @@
+/*
+ * 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.tags.annotation;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.JavaClassDescriptorManager;
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+import org.apache.felix.scrplugin.tags.qdox.QDoxJavaClassDescription;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import com.thoughtworks.qdox.model.JavaSource;
+
+/**
+ * Reading class description based on java annotations. This extends
+ * {@link QDoxJavaClassDescription} to re-use annotation-independent logic and
+ * automatic generation of bind/unbind methods.
+ */
+public class AnnotationJavaClassDescription extends QDoxJavaClassDescription {
+
+    /**
+     * @param clazz Java class
+     * @param source QDox source
+     * @param manager description manager
+     */
+    public AnnotationJavaClassDescription(Class clazz, JavaSource source, JavaClassDescriptorManager manager) {
+        super(clazz, source, manager);
+    }
+
+    /**
+     * @see JavaClassDescription#getTagByName(String)
+     */
+    @Override
+    public JavaTag getTagByName(String name) {
+        for (Annotation annotation : this.clazz.getAnnotations()) {
+            List<JavaTag> tags = manager.getAnnotationTagProviderManager().getTags(annotation, this);
+            for (JavaTag tag : tags) {
+                if (tag.getName().equals(name)) {
+                    return tag;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * @see JavaClassDescription#getTagsByName(String, boolean)
+     */
+    @Override
+    public JavaTag[] getTagsByName(String name, boolean inherited) throws MojoExecutionException {
+
+        List<JavaTag> tags = new ArrayList<JavaTag>();
+
+        for (Annotation annotation : this.clazz.getAnnotations()) {
+            List<JavaTag> annotationTags = manager.getAnnotationTagProviderManager().getTags(annotation, this);
+            for (JavaTag tag : annotationTags) {
+                if (tag.getName().equals(name)) {
+                    tags.add(tag);
+                }
+            }
+        }
+
+        if (inherited && this.getSuperClass() != null) {
+            final JavaTag[] superTags = this.getSuperClass().getTagsByName(name, inherited);
+            if (superTags.length > 0) {
+                tags.addAll(Arrays.asList(superTags));
+            }
+        }
+
+        return tags.toArray(new JavaTag[tags.size()]);
+    }
+
+    /**
+     * @see JavaClassDescription#getFields()
+     */
+    @Override
+    public JavaField[] getFields() {
+        final Field[] fields = this.clazz.getDeclaredFields();
+        final JavaField[] javaFields = new JavaField[fields.length];
+        for (int i = 0; i < fields.length; i++) {
+            javaFields[i] = new AnnotationJavaField(fields[i], this);
+        }
+        return javaFields;
+    }
+
+    /**
+     * @see JavaClassDescription#getFieldByName(String)
+     */
+    @Override
+    public JavaField getFieldByName(String name) throws MojoExecutionException {
+        Field field = null;
+        try {
+            field = this.clazz.getField(name);
+        } catch (SecurityException e) {
+            // ignore
+        } catch (NoSuchFieldException e) {
+            // ignore
+        }
+        if (field != null) {
+            return new AnnotationJavaField(field, this);
+        }
+        if (this.getSuperClass() != null) {
+            this.getSuperClass().getFieldByName(name);
+        }
+        return null;
+    }
+
+    protected JavaClassDescriptorManager getManager() {
+        return this.manager;
+    }
+
+}
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaField.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaField.java
new file mode 100644
index 0000000..d2edabc
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaField.java
@@ -0,0 +1,85 @@
+/*
+ * 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.tags.annotation;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.List;
+
+import org.apache.felix.scrplugin.tags.ClassUtil;
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+
+/**
+ * Description of a java field
+ */
+public class AnnotationJavaField implements JavaField {
+
+    protected final Field field;
+
+    protected final AnnotationJavaClassDescription description;
+
+    /**
+     * @param field Field
+     * @param description description
+     */
+    public AnnotationJavaField(Field field, AnnotationJavaClassDescription description) {
+        this.field = field;
+        this.description = description;
+    }
+
+    /**
+     * @see JavaField#getInitializationExpression()
+     */
+    public String[] getInitializationExpression() {
+        return ClassUtil.getInitializationExpression(this.description.getCompiledClass(), this.getName());
+    }
+
+    /**
+     * @see JavaField#getName()
+     */
+    public String getName() {
+        return this.field.getName();
+    }
+
+    /**
+     * @see JavaField#getTagByName(String)
+     */
+    public JavaTag getTagByName(String name) {
+        for (Annotation annotation : this.field.getAnnotations()) {
+            List<JavaTag> tags = description.getManager().getAnnotationTagProviderManager().getTags(annotation,
+                    this.description, this);
+            for (JavaTag tag : tags) {
+                if (tag.getName().equals(name)) {
+                    return tag;
+                }
+
+            }
+        }
+        return null;
+    }
+
+    /**
+     * @see JavaField#getType()
+     */
+    public String getType() {
+        return this.field.getType().getName();
+    }
+
+}
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java
new file mode 100644
index 0000000..9bbdaa5
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java
@@ -0,0 +1,44 @@
+/*
+ * 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.tags.annotation;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+
+/**
+ * Interface for provider classes, that map java annotations to {@link JavaTag}
+ * implementations.
+ */
+public interface AnnotationTagProvider {
+
+    /**
+     * Maps a annotation to one or many {@link JavaTag} implementations.
+     * @param pAnnotation Java annotation
+     * @param description Annotations-based java class description
+     * @param field Reference to field (set on field-level annotations, null on
+     *            other annotations)
+     * @return List of tag implementations. Return empty list if this provider
+     *         cannot map the annotation to any tag instance.
+     */
+    List<JavaTag> getTags(Annotation pAnnotation, AnnotationJavaClassDescription description, JavaField field);
+
+}
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
new file mode 100644
index 0000000..cc553a8
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
@@ -0,0 +1,121 @@
+/*
+ * 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.tags.annotation;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+import org.apache.felix.scrplugin.tags.annotation.defaulttag.DefaultAnnotationTagProvider;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Supports mapping of built-in and custom java anntoations to {@link JavaTag}
+ * implementations.
+ */
+public class AnnotationTagProviderManager {
+
+    /**
+     * 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.
+     */
+    private final List<AnnotationTagProvider> annotationTagProviders = new ArrayList<AnnotationTagProvider>();
+
+    /**
+     * @param annotationTagProviderClasses List of classes that implements
+     *            {@link AnnotationTagProvider} interface.
+     * @throws MojoFailureException
+     */
+    public AnnotationTagProviderManager(String[] annotationTagProviderClasses) throws MojoFailureException {
+
+        // always add provider supporting built-in SCR default properties
+        annotationTagProviders.add(new DefaultAnnotationTagProvider());
+
+        // add custom providers defined in pom
+        for (int i = 0; i < annotationTagProviderClasses.length; i++) {
+            try {
+                Class clazz = Class.forName(annotationTagProviderClasses[i]);
+                try {
+                    annotationTagProviders.add((AnnotationTagProvider) clazz.newInstance());
+                } catch (ClassCastException e) {
+                    throw new MojoFailureException("Class '" + clazz.getName() + "' "
+                            + "does not implement interface '" + AnnotationTagProvider.class.getName() + "'.");
+                } catch (InstantiationException e) {
+                    throw new MojoFailureException("Unable to instantiate class '" + clazz.getName() + "': "
+                            + e.getMessage());
+                } catch (IllegalAccessException e) {
+                    throw new MojoFailureException("Illegal access to class '" + clazz.getName() + "': "
+                            + e.getMessage());
+                }
+            } catch (ClassNotFoundException ex) {
+                throw new MojoFailureException("Annotation provider class '" + annotationTagProviderClasses[i]
+                        + "' not found.");
+            }
+        }
+
+    }
+
+    /**
+     * Converts a java annotation to {@link JavaTag} if a mapping can be found.
+     * 
+     * @param annotation Java annotation
+     * @param description Description
+     * @return Tag declaration or null if no mapping found
+     */
+    public List<JavaTag> getTags(Annotation annotation, AnnotationJavaClassDescription description) {
+        return getTags(annotation, description, null);
+    }
+
+    /**
+     * Converts a java annotation to {@link JavaTag} if a mapping can be found.
+     * 
+     * @param annotation Java annotation
+     * @param description Description
+     * @param field Field
+     * @return Tag declaration or null if no mapping found
+     */
+    public List<JavaTag> getTags(Annotation annotation, AnnotationJavaClassDescription description, JavaField field) {
+        List<JavaTag> tags = new ArrayList<JavaTag>();
+
+        for (AnnotationTagProvider provider : this.annotationTagProviders) {
+            tags.addAll(provider.getTags(annotation, description, field));
+        }
+
+        return tags;
+    }
+
+    /**
+     * Checks if the given class has any SCR plugin java annotations defined.
+     * @param pClass Class
+     * @return true if SCR plugin java annotation found
+     */
+    public boolean hasScrPluginAnnotation(Class pClass) {
+        for (Annotation annotation : pClass.getAnnotations()) {
+            if (getTags(annotation, null).size() > 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+}
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/AbstractTag.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/AbstractTag.java
new file mode 100644
index 0000000..02f483c
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/AbstractTag.java
@@ -0,0 +1,108 @@
+/*
+ * 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.tags.annotation.defaulttag;
+
+import java.util.Map;
+
+import org.apache.felix.scrplugin.tags.*;
+
+/**
+ * Description of a java tag for components.
+ */
+public abstract class AbstractTag implements JavaTag {
+
+    protected final JavaClassDescription description;
+
+    protected final JavaField field;
+
+    /**
+     * @param desc Description
+     * @param field Field
+     */
+    public AbstractTag(JavaClassDescription desc, JavaField field) {
+        this.description = desc;
+        this.field = field;
+    }
+
+    /**
+     * @see JavaTag#getNamedParameter(String)
+     */
+    public String getNamedParameter(String name) {
+        final Map<String, String> map = this.getNamedParameterMap();
+        if (map != null) {
+            return map.get(name);
+        }
+        return null;
+    }
+
+    /**
+     * @see JavaTag#getParameters()
+     */
+    public String[] getParameters() {
+        final Map<?, ?> map = this.getNamedParameterMap();
+        if (map != null) {
+            return map.keySet().toArray(new String[5]);
+        }
+        return new String[0];
+    }
+
+    /**
+     * @see JavaTag#getSourceLocation()
+     */
+    public String getSourceLocation() {
+        return "Java annotations in " + this.description.getName();
+    }
+
+    /**
+     * @see JavaTag#getJavaClassDescription()
+     */
+    public JavaClassDescription getJavaClassDescription() {
+        return this.description;
+    }
+
+    /**
+     * @see JavaTag#getField()
+     */
+    public JavaField getField() {
+        return this.field;
+    }
+
+    /**
+     * Maps an empty or null string value to null
+     * @param value String value
+     * @return Non-empty string value or null
+     */
+    protected String emptyToNull(String value) {
+        if (value == null || value.length() == 0) {
+            return null;
+        }
+        return value;
+    }
+
+    /**
+     * @see JavaTag#getName()
+     */
+    public abstract String getName();
+
+    /**
+     * @see JavaTag#getNamedParameterMap()
+     */
+    public abstract Map<String, String> getNamedParameterMap();
+
+}
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
new file mode 100644
index 0000000..510956e
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
@@ -0,0 +1,68 @@
+/*
+ * 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.tags.annotation.defaulttag;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.annotations.Component;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+
+/**
+ * Description of a java tag for components.
+ */
+public class ComponentTag extends AbstractTag {
+
+    protected final Component annotation;
+
+    /**
+     * @param annotation Annotation
+     * @param desc Description
+     */
+    public ComponentTag(Component annotation, JavaClassDescription desc) {
+        super(desc, null);
+        this.annotation = annotation;
+    }
+
+    @Override
+    public String getName() {
+        return Constants.COMPONENT;
+    }
+
+    @Override
+    public Map<String, String> getNamedParameterMap() {
+        final Map<String, String> map = new HashMap<String, String>();
+
+        map.put(Constants.COMPONENT_NAME, emptyToNull(this.annotation.name()));
+        map.put(Constants.COMPONENT_LABEL, emptyToNull(this.annotation.label()));
+        map.put(Constants.COMPONENT_DESCRIPTION, emptyToNull(this.annotation.description()));
+        map.put(Constants.COMPONENT_ENABLED, String.valueOf(this.annotation.enabled()));
+        map.put(Constants.COMPONENT_FACTORY, emptyToNull(this.annotation.factory()));
+        map.put(Constants.COMPONENT_IMMEDIATE, String.valueOf(this.annotation.immediate()));
+        map.put(Constants.COMPONENT_INHERIT, String.valueOf(this.annotation.inherit()));
+        map.put(Constants.COMPONENT_METATYPE, String.valueOf(this.annotation.metatype()));
+        map.put(Constants.COMPONENT_ABSTRACT, String.valueOf(this.annotation.componentAbstract()));
+        map.put(Constants.COMPONENT_DS, String.valueOf(this.annotation.ds()));
+        map.put(Constants.COMPONENT_CREATE_PID, String.valueOf(this.annotation.createPid()));
+
+        return map;
+    }
+
+}
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java
new file mode 100644
index 0000000..203bcc8
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java
@@ -0,0 +1,78 @@
+/*
+ * 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.tags.annotation.defaulttag;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.felix.scrplugin.annotations.Component;
+import org.apache.felix.scrplugin.annotations.Properties;
+import org.apache.felix.scrplugin.annotations.Property;
+import org.apache.felix.scrplugin.annotations.Reference;
+import org.apache.felix.scrplugin.annotations.References;
+import org.apache.felix.scrplugin.annotations.Service;
+import org.apache.felix.scrplugin.annotations.Services;
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+import org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription;
+import org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider;
+
+/**
+ * Provides mapping of default SCR annotations to tag implementations.
+ */
+public class DefaultAnnotationTagProvider implements AnnotationTagProvider {
+
+    /**
+     * @see AnnotationTagProvider#getTags(Annotation,
+     *      AnnotationJavaClassDescription, JavaField)
+     */
+    public List<JavaTag> getTags(Annotation annotation, AnnotationJavaClassDescription description, JavaField field) {
+        List<JavaTag> tags = new ArrayList<JavaTag>();
+
+        // check for single annotations
+        if (annotation instanceof Component) {
+            tags.add(new ComponentTag((Component) annotation, description));
+        } else if (annotation instanceof Property) {
+            tags.add(new PropertyTag((Property) annotation, description));
+        } else if (annotation instanceof Service) {
+            tags.add(new ServiceTag((Service) annotation, description));
+        } else if (annotation instanceof Reference) {
+            tags.add(new ReferenceTag((Reference) annotation, description, field));
+        }
+
+        // check for multi-annotations
+        else if (annotation instanceof Properties) {
+            for (Property property : ((Properties) annotation).value()) {
+                tags.add(new PropertyTag(property, description));
+            }
+        } else if (annotation instanceof Services) {
+            for (Service service : ((Services) annotation).value()) {
+                tags.add(new ServiceTag(service, description));
+            }
+        } else if (annotation instanceof References) {
+            for (Reference reference : ((References) annotation).value()) {
+                tags.add(new ReferenceTag(reference, description, field));
+            }
+        }
+
+        return tags;
+    }
+
+}
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
new file mode 100644
index 0000000..0fc24a0
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
@@ -0,0 +1,105 @@
+/*
+ * 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.tags.annotation.defaulttag;
+
+import java.util.*;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.annotations.*;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+
+/**
+ * Description of a java tag for components.
+ */
+public class PropertyTag extends AbstractTag {
+
+    protected final Property annotation;
+
+    /**
+     * @param annotation Annotation
+     * @param desc Description
+     */
+    public PropertyTag(Property annotation, JavaClassDescription desc) {
+        super(desc, null);
+        this.annotation = annotation;
+    }
+
+    @Override
+    public String getName() {
+        return Constants.PROPERTY;
+    }
+
+    @Override
+    public Map<String, String> getNamedParameterMap() {
+        final Map<String, String> map = new HashMap<String, String>();
+
+        map.put(Constants.PROPERTY_NAME, emptyToNull(this.annotation.name()));
+        map.put(Constants.PROPERTY_LABEL, emptyToNull(this.annotation.label()));
+        map.put(Constants.PROPERTY_DESCRIPTION, emptyToNull(this.annotation.description()));
+
+        String[] values = this.annotation.value();
+        if (values == null || values.length == 0) {
+            map.put(Constants.PROPERTY_VALUE, "");
+        } else if (values.length == 1) {
+            map.put(Constants.PROPERTY_VALUE, values[0]);
+        } else {
+            for (int i = 0; i < values.length; i++) {
+                map.put(Constants.PROPERTY_MULTIVALUE_PREFIX + '.' + i, values[i]);
+            }
+        }
+
+        String type = null;
+        if (this.annotation.type() != AutoDetect.class) {
+            type = this.annotation.type().getSimpleName();
+        }
+        map.put(Constants.PROPERTY_TYPE, type);
+
+        if (this.annotation.cardinality() != 0) {
+            map.put(Constants.PROPERTY_CARDINALITY, String.valueOf(this.annotation.cardinality()));
+        }
+
+        map.put(Constants.PROPERTY_PRIVATE, String.valueOf(this.annotation.propertyPrivate()));
+
+        return map;
+    }
+
+    @Override
+    public String[] getParameters() {
+        List<String> parameters = new ArrayList<String>();
+
+        String[] defaultParameters = super.getParameters();
+        if (defaultParameters != null) {
+            parameters.addAll(Arrays.asList(defaultParameters));
+        }
+
+        // if defined: add options as parameters to the end of parameter list
+        // (strange parsing due to qdox tag restrictions...)
+        if (this.annotation.options().length > 0) {
+            parameters.add(Constants.PROPERTY_OPTIONS);
+            for (PropertyOption option : this.annotation.options()) {
+                parameters.add(option.name());
+                parameters.add("=");
+                parameters.add(option.value());
+            }
+        }
+
+        return parameters.toArray(new String[parameters.size()]);
+    }
+
+}
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java
new file mode 100644
index 0000000..4cf97e7
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java
@@ -0,0 +1,75 @@
+/*
+ * 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.tags.annotation.defaulttag;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.annotations.AutoDetect;
+import org.apache.felix.scrplugin.annotations.Reference;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.JavaField;
+
+/**
+ * Description of a java tag for components.
+ */
+public class ReferenceTag extends AbstractTag {
+
+    protected final Reference annotation;
+
+    /**
+     * @param annotation Annotation
+     * @param desc Description
+     * @param field Field
+     */
+    public ReferenceTag(Reference annotation, JavaClassDescription desc, JavaField field) {
+        super(desc, field);
+        this.annotation = annotation;
+    }
+
+    @Override
+    public String getName() {
+        return Constants.REFERENCE;
+    }
+
+    @Override
+    public Map<String, String> getNamedParameterMap() {
+        final Map<String, String> map = new HashMap<String, String>();
+
+        map.put(Constants.REFERENCE_NAME, emptyToNull(this.annotation.name()));
+
+        String referenceInterface = null;
+        if (this.annotation.referenceInterface() != AutoDetect.class) {
+            referenceInterface = this.annotation.referenceInterface().getName();
+        }
+        map.put(Constants.REFERENCE_INTERFACE, referenceInterface);
+
+        map.put(Constants.REFERENCE_CARDINALITY, this.annotation.cardinality().getCardinalityString());
+        map.put(Constants.REFERENCE_POLICY, this.annotation.policy().getPolicyString());
+        map.put(Constants.REFERENCE_TARGET, emptyToNull(this.annotation.target()));
+        map.put(Constants.REFERENCE_BIND, emptyToNull(this.annotation.bind()));
+        map.put(Constants.REFERENCE_UNDBIND, emptyToNull(this.annotation.unbind()));
+        map.put(Constants.REFERENCE_CHECKED, String.valueOf(this.annotation.checked()));
+        map.put(Constants.REFERENCE_STRATEGY, emptyToNull(this.annotation.strategy()));
+
+        return map;
+    }
+
+}
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
new file mode 100644
index 0000000..7578f25
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
@@ -0,0 +1,65 @@
+/*
+ * 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.tags.annotation.defaulttag;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.annotations.AutoDetect;
+import org.apache.felix.scrplugin.annotations.Service;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+
+/**
+ * Description of a java tag for components.
+ */
+public class ServiceTag extends AbstractTag {
+
+    protected final Service annotation;
+
+    /**
+     * @param annotation Annotation
+     * @param desc Description
+     */
+    public ServiceTag(Service annotation, JavaClassDescription desc) {
+        super(desc, null);
+        this.annotation = annotation;
+    }
+
+    @Override
+    public String getName() {
+        return Constants.SERVICE;
+    }
+
+    @Override
+    public Map<String, String> getNamedParameterMap() {
+        final Map<String, String> map = new HashMap<String, String>();
+
+        String serviceInterface = null;
+        if (this.annotation.value() != AutoDetect.class) {
+            serviceInterface = this.annotation.value().getName();
+        }
+        map.put(Constants.SERVICE_INTERFACE, serviceInterface);
+
+        map.put(Constants.SERVICE_FACTORY, String.valueOf(this.annotation.serviceFactory()));
+
+        return map;
+    }
+
+}
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java
new file mode 100644
index 0000000..67c4673
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+/**
+ * SCR plugin annotation tag provider default implementation for annotations provided in package
+ * <code>org.apache.felix.scrplugin.annotations</code>.
+ */
+package org.apache.felix.scrplugin.tags.annotation.defaulttag;
+
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/package-info.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/package-info.java
new file mode 100644
index 0000000..a00ab18
--- /dev/null
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * Extracting SCR tags from source file declared as Java 1.5 annotations.   
+ */
+package org.apache.felix.scrplugin.tags.annotation;
+
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
index 34468a3..299f83f 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
@@ -22,7 +22,7 @@
 import java.util.*;
 
 import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.om.*;
+import org.apache.felix.scrplugin.om.Component;
 import org.apache.felix.scrplugin.tags.*;
 import org.apache.maven.plugin.MojoExecutionException;
 
@@ -194,7 +194,7 @@
                      this.component.getService().getInterfaces().size() > 0 ) {
                     javaTags = new JavaTag[this.component.getService().getInterfaces().size()];
                     for(int i=0; i<this.component.getService().getInterfaces().size(); i++) {
-                        javaTags[i] = new ClassLoaderJavaTag(this, (Interface)this.component.getService().getInterfaces().get(i),
+                        javaTags[i] = new ClassLoaderJavaTag(this, this.component.getService().getInterfaces().get(i),
                                                              this.component.getService().isServicefactory());
                     }
                 }
@@ -202,14 +202,14 @@
                 if ( this.component.getProperties().size() > 0 ) {
                     javaTags = new JavaTag[this.component.getProperties().size()];
                     for(int i=0; i<this.component.getProperties().size(); i++) {
-                        javaTags[i] = new ClassLoaderJavaTag(this, (Property)this.component.getProperties().get(i));
+                        javaTags[i] = new ClassLoaderJavaTag(this, this.component.getProperties().get(i));
                     }
                 }
             } else if ( Constants.REFERENCE.equals(name) ) {
                 if ( this.component.getReferences().size() > 0 ) {
                     javaTags = new JavaTag[this.component.getReferences().size()];
                     for(int i=0; i<this.component.getReferences().size(); i++) {
-                        javaTags[i] = new ClassLoaderJavaTag(this, (Reference)this.component.getReferences().get(i));
+                        javaTags[i] = new ClassLoaderJavaTag(this, this.component.getReferences().get(i));
                     }
                 }
             }
@@ -217,9 +217,9 @@
         if ( inherited && this.getSuperClass() != null ) {
             final JavaTag[] superTags = this.getSuperClass().getTagsByName(name, inherited);
             if ( superTags.length > 0 ) {
-                final List list = new ArrayList(Arrays.asList(javaTags));
+                final List<JavaTag> list = new ArrayList<JavaTag>(Arrays.asList(javaTags));
                 list.addAll(Arrays.asList(superTags));
-                javaTags = (JavaTag[]) list.toArray(new JavaTag[list.size()]);
+                javaTags = list.toArray(new JavaTag[list.size()]);
             }
         }
         return javaTags;
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java
index 8980aeb..cfe721e 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java
@@ -92,9 +92,9 @@
      * @see org.apache.felix.scrplugin.tags.JavaTag#getNamedParameter(java.lang.String)
      */
     public String getNamedParameter(String name) {
-        final Map map = this.getNamedParameterMap();
+        final Map<String, String> map = this.getNamedParameterMap();
         if ( map != null ) {
-            return (String)map.get(name);
+            return map.get(name);
         }
         return null;
     }
@@ -102,9 +102,9 @@
     /**
      * @see org.apache.felix.scrplugin.tags.JavaTag#getNamedParameterMap()
      */
-    public Map getNamedParameterMap() {
+    public Map<String, String> getNamedParameterMap() {
         if ( this.reference != null ) {
-            final Map map = new HashMap();
+            final Map<String, String> map = new HashMap<String, String>();
             map.put(Constants.REFERENCE_BIND, this.reference.getBind());
             map.put(Constants.REFERENCE_CARDINALITY, this.reference.getCardinality());
             map.put(Constants.REFERENCE_INTERFACE, this.reference.getInterfacename());
@@ -116,7 +116,7 @@
             map.put(Constants.REFERENCE_STRATEGY, this.reference.getStrategy());
             return map;
         } else if ( this.property != null ) {
-            final Map map = new HashMap();
+            final Map<String, String> map = new HashMap<String, String>();
             map.put(Constants.PROPERTY_TYPE, this.property.getType());
             map.put(Constants.PROPERTY_NAME, this.property.getName());
             final String[] values = this.property.getMultiValue();
@@ -139,7 +139,7 @@
             }
             return map;
         } else if ( this.interf != null ) {
-            final Map map = new HashMap();
+            final Map<String, String> map = new HashMap<String, String>();
             map.put(Constants.SERVICE_INTERFACE, this.interf.getInterfacename());
             if ( this.isServiceFactory ) {
                 map.put(Constants.SERVICE_FACTORY, "true");
@@ -153,9 +153,9 @@
      * @see org.apache.felix.scrplugin.tags.JavaTag#getParameters()
      */
     public String[] getParameters() {
-        final Map map = this.getNamedParameterMap();
+        final Map<String, String> map = this.getNamedParameterMap();
         if ( map != null ) {
-            return (String[])map.keySet().toArray(new String[5]);
+            return map.keySet().toArray(new String[5]);
         }
         return new String[0];
     }
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
index a59eab3..064e996 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
@@ -102,9 +102,9 @@
         if ( inherited && this.getSuperClass() != null ) {
             final JavaTag[] superTags = this.getSuperClass().getTagsByName(name, inherited);
             if ( superTags.length > 0 ) {
-                final List list = new ArrayList(Arrays.asList(javaTags));
+                final List<JavaTag> list = new ArrayList<JavaTag>(Arrays.asList(javaTags));
                 list.addAll(Arrays.asList(superTags));
-                javaTags = (JavaTag[]) list.toArray(new JavaTag[list.size()]);
+                javaTags = list.toArray(new JavaTag[list.size()]);
             }
         }
         return javaTags;
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaTag.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaTag.java
index d0a6f05..53e9353 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaTag.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaTag.java
@@ -84,7 +84,8 @@
     /**
      * @see org.apache.felix.scrplugin.tags.JavaTag#getNamedParameterMap()
      */
-    public Map getNamedParameterMap() {
+    @SuppressWarnings("unchecked")
+    public Map<String, String> getNamedParameterMap() {
         return this.docletTag.getNamedParameterMap();
     }
 
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
index 627ef5e..1468522 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
@@ -20,7 +20,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.StringTokenizer;
 
 import javax.xml.transform.TransformerException;
@@ -119,9 +118,7 @@
         contentHandler.startElement("", ComponentDescriptorIO.COMPONENTS, ComponentDescriptorIO.COMPONENTS, new AttributesImpl());
         IOUtils.newline(contentHandler);
 
-        final Iterator i = components.getComponents().iterator();
-        while ( i.hasNext() ) {
-            final Component component = (Component)i.next();
+        for(final Component component : components.getComponents()) {
             generateXML(component, contentHandler, isScrPrivateFile);
         }
         // end wrapper element
@@ -153,16 +150,12 @@
             generateXML(component.getService(), contentHandler);
         }
         if ( component.getProperties() != null ) {
-            final Iterator i = component.getProperties().iterator();
-            while ( i.hasNext() ) {
-                final Property property = (Property)i.next();
+            for(final Property property : component.getProperties()) {
                 generateXML(property, contentHandler, isScrPrivateFile);
             }
         }
         if ( component.getReferences() != null ) {
-            final Iterator i = component.getReferences().iterator();
-            while ( i.hasNext() ) {
-                final Reference reference = (Reference)i.next();
+            for(final Reference reference : component.getReferences()) {
                 generateXML(reference, contentHandler, isScrPrivateFile);
             }
         }
@@ -201,9 +194,7 @@
         contentHandler.startElement(INNER_NAMESPACE_URI, ComponentDescriptorIO.SERVICE, ComponentDescriptorIO.SERVICE_QNAME, ai);
         if ( service.getInterfaces() != null && service.getInterfaces().size() > 0 ) {
             IOUtils.newline(contentHandler);
-            final Iterator i = service.getInterfaces().iterator();
-            while ( i.hasNext() ) {
-                final Interface interf = (Interface)i.next();
+            for(final Interface interf : service.getInterfaces()) {
                 generateXML(interf, contentHandler);
             }
             IOUtils.indent(contentHandler, 2);
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
index 0259cb7..46b819a 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
@@ -133,19 +133,19 @@
         /**
          * The prefixes of startPrefixMapping() declarations for the coming element.
          */
-        private List prefixList = new ArrayList();
+        private List<String> prefixList = new ArrayList<String>();
 
         /**
          * The URIs of startPrefixMapping() declarations for the coming element.
          */
-        private List uriList = new ArrayList();
+        private List<String> uriList = new ArrayList<String>();
 
         /**
          * Maps of URI<->prefix mappings. Used to work around a bug in the Xalan
          * serializer.
          */
-        private Map uriToPrefixMap = new HashMap();
-        private Map prefixToUriMap = new HashMap();
+        private Map<String, String> uriToPrefixMap = new HashMap<String, String>();
+        private Map<String, String> prefixToUriMap = new HashMap<String, String>();
 
         /**
          * True if there has been some startPrefixMapping() for the coming element.
@@ -215,8 +215,8 @@
                 for (int mapping = 0; mapping < mappingCount; mapping++) {
 
                     // Build infos for this namespace
-                    String uri = (String) this.uriList.get(mapping);
-                    String prefix = (String) this.prefixList.get(mapping);
+                    String uri = this.uriList.get(mapping);
+                    String prefix = this.prefixList.get(mapping);
                     String qName = prefix.length() == 0 ? "xmlns" : ("xmlns:" + prefix);
 
                     // Search for the corresponding xmlns* attribute
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
index aa680c2..978a7a7 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
@@ -95,15 +95,13 @@
         contentHandler.startElement(NAMESPACE_URI, METADATA_ELEMENT, METADATA_ELEMENT_QNAME, ai);
         IOUtils.newline(contentHandler);
 
-        final Iterator i = metaData.getDescriptors().iterator();
-        while ( i.hasNext() ) {
-            final Object obj = i.next();
-            if ( obj instanceof OCD ) {
-                generateXML((OCD)obj, contentHandler);
-            } else {
-                generateXML((Designate)obj, contentHandler);
-            }
+        for(final OCD ocd : metaData.getOCDs()) {
+            generateXML(ocd, contentHandler);
         }
+        for(final Designate d : metaData.getDesignates()) {
+            generateXML(d, contentHandler);
+        }
+
         // end wrapper element
         contentHandler.endElement(NAMESPACE_URI, METADATA_ELEMENT, METADATA_ELEMENT_QNAME);
         IOUtils.newline(contentHandler);
@@ -122,9 +120,9 @@
 
         if ( ocd.getProperties().size() > 0 ) {
             IOUtils.newline(contentHandler);
-            final Iterator i = ocd.getProperties().iterator();
+            final Iterator<AttributeDefinition> i = ocd.getProperties().iterator();
             while ( i.hasNext() ) {
-                final AttributeDefinition ad = (AttributeDefinition) i.next();
+                final AttributeDefinition ad = i.next();
                 generateXML(ad, contentHandler);
             }
             IOUtils.indent(contentHandler, 1);
@@ -159,11 +157,11 @@
 
         if (ad.getOptions() != null && ad.getOptions().size() > 0) {
             IOUtils.newline(contentHandler);
-            for (Iterator oi=ad.getOptions().entrySet().iterator(); oi.hasNext(); ) {
-                final Map.Entry entry = (Map.Entry) oi.next();
+            for (Iterator<Map.Entry<String, String>> oi=ad.getOptions().entrySet().iterator(); oi.hasNext(); ) {
+                final Map.Entry<String, String> entry = oi.next();
                 ai.clear();
-                IOUtils.addAttribute(ai, "value", String.valueOf(entry.getKey()));
-                IOUtils.addAttribute(ai, "label", String.valueOf(entry.getValue()));
+                IOUtils.addAttribute(ai, "value", entry.getKey());
+                IOUtils.addAttribute(ai, "label", entry.getValue());
                 IOUtils.indent(contentHandler, 3);
                 contentHandler.startElement(INNER_NAMESPACE_URI, OPTION_ELEMENT, OPTION_ELEMENT_QNAME, ai);
                 contentHandler.endElement(INNER_NAMESPACE_URI, OPTION_ELEMENT, OPTION_ELEMENT_QNAME);