added a new name attribute, allowing to dynamically configure the service dependency filter/required attributes

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@953576 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
index e9c20c1..6900360 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
@@ -90,6 +90,7 @@
     private String m_method;
     private String m_descriptor;
     private Set<String> m_methods = new HashSet<String>();
+    private Set<String> m_dependencyNames = new HashSet<String>();
     private List<EntryWriter> m_writers = new ArrayList<EntryWriter>(); // Last elem is either Service or AspectService
     private MetaType m_metaType;
     private String m_startMethod;
@@ -210,13 +211,13 @@
             //Patterns.parseMethod(m_method, m_descriptor, Patterns.VOID);
             // TODO check if method takes optional params like Service, DependencyManager, etc ...
             m_initMethod = m_method;
-        }
+        } 
         else if (annotation.getName().equals(A_START))
         {
             //Patterns.parseMethod(m_method, m_descriptor, Patterns.VOID);
             // TODO check if method takes optional params like Service, DependencyManager, etc ...
             m_startMethod = m_method;
-        }
+        } 
         else if (annotation.getName().equals(A_STOP))
         {
             //Patterns.parseMethod(m_method, m_descriptor, Patterns.VOID);
@@ -362,7 +363,7 @@
         Long t = (Long) annotation.get(EntryParam.timeout.toString());
         if (t != null && t.longValue() < -1)
         {
-            throw new IllegalArgumentException("Invalid timeout value " + t + " in ServiceDependency annotation in class " + m_className);
+            throw new IllegalArgumentException("Invalid timeout value " + t + " in ServiceDependency annotation from class " + m_className);
         }
         
         // required attribute (not valid if parsing a temporal service dependency)
@@ -372,7 +373,14 @@
         writer.putString(annotation, EntryParam.changed, null);
 
         // removed callback
-        writer.putString(annotation, EntryParam.removed, null);       
+        writer.putString(annotation, EntryParam.removed, null); 
+        
+        // name attribute
+        writer.putString(annotation, EntryParam.name, null);
+        String name = annotation.get(EntryParam.name.toString());
+        if (name != null && ! m_dependencyNames.add(name)) {
+            throw new IllegalArgumentException("Duplicate dependency name " + name + " in ServiceDependency annotation from class " + m_className);
+        }
     }
 
     /**
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/EntryParam.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/EntryParam.java
index 2c14eef..caa83c0 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/EntryParam.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/EntryParam.java
@@ -34,5 +34,6 @@
     ranking,
     factory,
     factoryConfigure,
-    field
+    field,
+    name
 }