View Javadoc
1   package com.atlassian.plugin.spring.scanner.test.dynamic;
2   
3   import com.atlassian.plugin.spring.scanner.annotation.Profile;
4   import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
5   import com.atlassian.plugin.spring.scanner.test.InternalComponent;
6   import com.atlassian.plugin.spring.scanner.test.otherplugin.DynamicallyImportedServiceFromAnotherPlugin;
7   import org.springframework.beans.factory.annotation.Autowired;
8   import org.springframework.stereotype.Component;
9   
10  /**
11   * Due to the '@Profile', this is not instantiated until the "dynamic" profile is loaded by {@link DynamicContextManager}.
12   */
13  @Profile("dynamic")
14  @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
15  @Component
16  public class DynamicComponent {
17      private final DynamicallyImportedServiceFromAnotherPlugin dynamicService;
18      private final InternalComponent internalComponent;
19  
20      /**
21       * @param dynamicService Not referenced elsewhere, so only imported once the dynamic profile is started by {@link DynamicContextManager}
22       */
23      @Autowired
24      public DynamicComponent(@ComponentImport final DynamicallyImportedServiceFromAnotherPlugin dynamicService,
25                              final InternalComponent internalComponent) {
26          this.dynamicService = dynamicService;
27          this.internalComponent = internalComponent;
28      }
29  }