Author: pderop
Date: Sun Apr 25 09:40:13 2010
New Revision: 937771
URL: http://svn.apache.org/viewvc?rev=937771&view=rev
Log:
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
Modified:
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/BundleAdapterService.java
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/ResourceAdapterService.java
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
Modified:
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java?rev=937771&r1=937770&r2=937771&view=diff
==============================================================================
---
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java
(original)
+++
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java
Sun Apr 25 09:40:13 2010
@@ -37,10 +37,10 @@ import java.lang.annotation.Target;
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.
Modified:
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/BundleAdapterService.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/BundleAdapterService.java?rev=937771&r1=937770&r2=937771&view=diff
==============================================================================
---
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/BundleAdapterService.java
(original)
+++
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/BundleAdapterService.java
Sun Apr 25 09:40:13 2010
@@ -49,10 +49,10 @@ public @Retention(RetentionPolicy.CLASS)
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
Modified:
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/ResourceAdapterService.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/ResourceAdapterService.java?rev=937771&r1=937770&r2=937771&view=diff
==============================================================================
---
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/ResourceAdapterService.java
(original)
+++
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/ResourceAdapterService.java
Sun Apr 25 09:40:13 2010
@@ -42,9 +42,9 @@ public @interface ResourceAdapterService
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
Modified:
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java?rev=937771&r1=937770&r2=937771&view=diff
==============================================================================
---
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
(original)
+++
felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
Sun Apr 25 09:40:13 2010
@@ -659,7 +659,6 @@ public class AnnotationCollector extends
info.addParam(Params.service, m_interfaces[0]);
} else
{
- checkClassImplements(annotation, Params.service);
info.addClassParam(annotation, Params.service, null);
}
}
@@ -694,27 +693,7 @@ public class AnnotationCollector extends
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 @@ public class AnnotationCollector extends
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 @@ public class AnnotationCollector extends
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 @@ public class AnnotationCollector extends
}
/**
- * 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