fixed bug in adapter annotations: the services provided by adapters were specified as a Class, instead of a Class array. Removed  checkClassImplements in AnnotationCollector.java

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@937771 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java
index f820d4e..28d94fd 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java
@@ -37,10 +37,10 @@
 public @interface AdapterService
 {
     /**
-     * Returns the adapter service interface . By default, the directly implemented interface is used.
-     * @return The service interface to apply the adapter to.
+     * Returns the adapter service interface(s). By default, the directly implemented interface(s) is (are) used.
+     * @return The service interface(s) provided by this adapter.
      */
-    Class<?> adapterService() default Object.class;
+    Class<?>[] adapterService() default {};
 
     /**
      * The adapter service properites. They will be added to the adapted service properties.
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/BundleAdapterService.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/BundleAdapterService.java
index 53a099a..56ae2da 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/BundleAdapterService.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/BundleAdapterService.java
@@ -49,10 +49,10 @@
     int stateMask() default Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE;
     
     /**
-     * The interface to use when registering adapters. By default, the interface directly implemented
-     * by the annotated class is used.
+     * The interface(s) to use when registering adapters. By default, the interface(s) directly implemented
+     * by the annotated class is (are) used.
      */
-    Class<?> service() default Object.class;
+    Class<?>[] service() default {};
     
     /**
      * Additional properties to use with the service registration
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/ResourceAdapterService.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/ResourceAdapterService.java
index 3aebcac..28a1700 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/ResourceAdapterService.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/ResourceAdapterService.java
@@ -42,9 +42,9 @@
     String filter();
 
     /**
-     * The interface to use when registering adapters
+     * The interface(s) to use when registering adapters
      */
-    Class<?> service() default Object.class;
+    Class<?>[] service() default {};
 
     /**
      * Additional properties to use with the adapter service registration
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 27d1b43..eaed2bd 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
@@ -659,7 +659,6 @@
             info.addParam(Params.service, m_interfaces[0]);
         } else
         {
-            checkClassImplements(annotation, Params.service);
             info.addClassParam(annotation, Params.service, null);
         }
     }
@@ -694,27 +693,7 @@
         parseParameters(annotation, Params.adapterProperties, info);
 
         // Parse the optional adapter service (use directly implemented interface by default).
-        Object adapterService = annotation.get(Params.adapterService.toString());
-        if (adapterService == null) {
-            if (m_interfaces == null)
-            {
-                throw new IllegalStateException("Invalid AdapterService annotation: " +
-                    "the adapterService attribute has not been set and the class " + m_className + 
-                    " does not implement any interfaces");
-            }
-            if (m_interfaces.length != 1) 
-            {
-                throw new IllegalStateException("Invalid AdapterService annotation: " +
-                    "the adapterService attribute has not been set and the class " + m_className +
-                    " implements more than one interface");
-            }
-            
-            info.addParam(Params.adapterService, m_interfaces[0]);
-        } else 
-        {
-            checkClassImplements(annotation, Params.adapterService);
-            info.addClassParam(annotation, Params.adapterService, null);
-        }
+        info.addClassParam(annotation, Params.adapterService, m_interfaces);
     }
 
     /**
@@ -747,27 +726,7 @@
         parseParameters(annotation, Params.properties, info);
 
         // Parse the optional adapter service (use directly implemented interface by default).
-        Object service = annotation.get(Params.service.toString());
-        if (service == null) {
-            if (m_interfaces == null)
-            {
-                throw new IllegalStateException("Invalid BundleAdapterService annotation: " +
-                    "the service attribute has not been set and the class " + m_className + 
-                    " does not implement any interfaces");
-            }
-            if (m_interfaces.length != 1) 
-            {
-                throw new IllegalStateException("Invalid AdapterService annotation: " +
-                    "the service attribute has not been set and the class " + m_className +
-                    " implements more than one interface");
-            }
-            
-            info.addParam(Params.service, m_interfaces[0]);
-        } else 
-        {
-            checkClassImplements(annotation, Params.service);
-            info.addClassParam(annotation, Params.service, null);
-        }
+        info.addClassParam(annotation, Params.service, m_interfaces);
         
         // Parse propagate attribute
         info.addParam(annotation, Params.propagate, Boolean.FALSE);
@@ -800,27 +759,7 @@
         parseParameters(annotation, Params.properties, info);
 
         // Parse the optional adapter service (use directly implemented interface by default).
-        Object service = annotation.get(Params.service.toString());
-        if (service == null) {
-            if (m_interfaces == null)
-            {
-                throw new IllegalStateException("Invalid ResourceAdapterService annotation: " +
-                    "the service attribute has not been set and the class " + m_className + 
-                    " does not implement any interfaces");
-            }
-            if (m_interfaces.length != 1) 
-            {
-                throw new IllegalStateException("Invalid ResourceAdapterService annotation: " +
-                    "the service attribute has not been set and the class " + m_className +
-                    " implements more than one interface");
-            }
-            
-            info.addParam(Params.service, m_interfaces[0]);
-        } else 
-        {
-            checkClassImplements(annotation, Params.service);
-            info.addClassParam(annotation, Params.service, null);
-        }
+        info.addClassParam(annotation, Params.service, m_interfaces);
         
         // Parse propagate attribute
         info.addParam(annotation, Params.propagate, Boolean.FALSE);
@@ -866,32 +805,6 @@
     }
 
     /**
-     * Checks if an annotation attribute references an implemented interface. 
-     * @param annotation the parsed annotation
-     * @param attribute an annotation attribute that references an interface this class must
-     * implement.
-     */
-    private void checkClassImplements(Annotation annotation, Params attribute)
-    {
-        String iface = annotation.get(attribute.toString());
-        iface = parseClass(iface, m_classPattern, 1);
-        
-        if (m_interfaces != null)
-        {
-            for (String implemented : m_interfaces)
-            {
-                if (implemented.equals(iface))
-                {
-                    return;
-                }
-            }
-        }
-
-        throw new IllegalArgumentException("Class " + m_className + " does not implement the "
-            + iface + " interface.");
-    }
-    
-    /**
      * Parses a Param annotation (which represents a list of key-value pari).
      * @param annotation the annotation where the Param annotation is defined
      * @param attribute the attribute name which is of Param type