Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 43315 invoked from network); 25 Apr 2010 09:41:02 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 25 Apr 2010 09:41:02 -0000 Received: (qmail 26040 invoked by uid 500); 25 Apr 2010 09:41:02 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 25954 invoked by uid 500); 25 Apr 2010 09:41:00 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 25947 invoked by uid 99); 25 Apr 2010 09:40:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Apr 2010 09:40:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Apr 2010 09:40:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6E7B823888EC; Sun, 25 Apr 2010 09:40:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r937771 - in /felix/trunk/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation: api/AdapterService.java api/BundleAdapterService.java api/ResourceAdapterService.java plugin/bnd/AnnotationCollector.java Date: Sun, 25 Apr 2010 09:40:13 -0000 To: commits@felix.apache.org From: pderop@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100425094013.6E7B823888EC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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