View Javadoc
1   package com.atlassian.plugin.spring.scanner.annotation.imports;
2   
3   import java.lang.annotation.ElementType;
4   import java.lang.annotation.Retention;
5   import java.lang.annotation.RetentionPolicy;
6   import java.lang.annotation.Target;
7   
8   /**
9    * Annotation representing an OSGi service that's required to be imported into this bundle.
10   * Can be applied to constructor params where the param type is a service interface exported
11   * by another bundle
12   */
13  @Target({ElementType.PARAMETER, ElementType.ANNOTATION_TYPE, ElementType.FIELD})
14  @Retention(RetentionPolicy.RUNTIME)
15  public @interface ComponentImport {
16  
17      /**
18       * Override the default spring bean name to assign <b>within this plugin</b> for the imported OSGi service.
19       * Not usually needed.
20       * <p>
21       * The default is to use the imported interface name with the first character lowercased,
22       * e.g. this code will result in a bean name of {@code contentService}:
23       * <pre><code>
24       * &#64;Named
25       * public class MyComponent {
26       *     &#64;Inject
27       *     public MyComponent(&#64;ComponentImport ContentService myExternalService) {
28       *         // more stuff here
29       *     }
30       * }
31       * </code></pre>
32       * So you only need to set this if you want to override the default: e.g. if you're importing
33       * two services with the same classname from different packages, you need to set different names for them;
34       * or if you need specific bean names to use with {@code @Qualifier("yourBeanName")}.
35       * <p>
36       * This name is local to this plugin's spring context;
37       * it's unrelated to the name of the bean (inside the product's or the providing plugin's spring context)
38       * that's exporting the service we're importing.
39       */
40      String value() default "";
41  }