You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Carsten Ziegeler (JIRA)" <ji...@apache.org> on 2014/07/23 16:04:39 UTC

[jira] [Assigned] (FELIX-4296) Cannot deactivate service interface detection in DS annotations

     [ https://issues.apache.org/jira/browse/FELIX-4296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler reassigned FELIX-4296:
---------------------------------------

    Assignee: Carsten Ziegeler

> Cannot deactivate service interface detection in DS annotations
> ---------------------------------------------------------------
>
>                 Key: FELIX-4296
>                 URL: https://issues.apache.org/jira/browse/FELIX-4296
>             Project: Felix
>          Issue Type: Bug
>          Components: SCR Tooling
>    Affects Versions: scr generator 1.10.0, scr ds annotations 1.2.4
>            Reporter: Serge Huber
>            Assignee: Carsten Ziegeler
>             Fix For: scr generator 1.10.2, scr ds annotations 1.2.6
>
>
> I am trying to use DS annotations to declare an extender, and I have the following annotation and class definition in order to prevent declaring a service with a SynchronousBundleListener interface : 
> @Component(service={})
> public class ExtenderBundleListener implements SynchronousBundleListener {
> According to the DS annotation specification this is value, as is illustrated from the javadoc :
> 	/**
> 	 * The types under which to register this Component as a service.
> 	 *
> 	 * <p>
> 	 * If no service should be registered, the empty value
> 	 * <code>&#x7B;&#x7D;</code> must be specified.
> 	 *
> 	 * <p>
> 	 * If not specified, the service types for this Component are all the
> 	 * <i>directly</i> implemented interfaces of the class being annotated.
> 	 *
> 	 * @see "The service element of a Component Description."
> 	 */
> 	Class< ? >[] service() default {};
> Unfortunately this doesn't work, as it seems that the annotation parser transforms the {} value into "null" so the following code in the DS annotation processor doesn't work as expected : 
>         final List<String> listedInterfaces = new ArrayList<String>();
>         if (cad.getValue("service") != null) {
>             final String[] interfaces = (String[]) cad.getValue("service");
>             for (final String t : interfaces) {
>                 listedInterfaces.add(t);
>             }
>         } else {
>             // scan directly implemented interfaces
>             this.searchInterfaces(listedInterfaces, scannedClass.getScannedClass());
>         }
> This is a bit problematic to solve because we would need to differentiate between the null and empty case, but it seems that this is somehow not supported by the annotations parser ?
> For the moment I worked around the problem by using the following annotation, but it's rather ugly since it still generates a service that is not needed :
> @Component(service={ExtenderBundleListener.class}, immediate = true) // ideally we would like to not specify any service but it's seems that due to a bug in the DS annotation processor this is not possible so we use the immediate setting instead
> public class ExtenderBundleListener implements SynchronousBundleListener {



--
This message was sent by Atlassian JIRA
(v6.2#6252)