View Javadoc
1   package com.atlassian.plugin.module;
2   
3   import java.util.Collection;
4   
5   /**
6    * The ContainerAccessor allows access to the underlying plugin container (e.g. spring).
7    *
8    * @since 2.5.0
9    */
10  public interface ContainerAccessor {
11      /**
12       * Will ask the container to instantiate a bean of the given class and does inject all constructor defined dependencies.
13       * Currently we have only spring as a container that will autowire this bean.
14       *
15       * @param clazz the Class to instantiate. Cannot be null.
16       * @return an instantiated bean.
17       */
18      <T> T createBean(Class<T> clazz);
19  
20      /**
21       * Injects an existing bean instance with any dependencies via setters or private field injection
22       *
23       * @param bean The instantiated bean to inject
24       * @param <T>  The bean type
25       * @since 3.0
26       */
27      <T> T injectBean(T bean);
28  
29      /**
30       * Retrieves a bean by name from the container.
31       *
32       * @param id the id of the container bean, cannot be null
33       * @return the bean object, or null if cannot be found
34       * @since 3.0
35       */
36      <T> T getBean(String id);
37  
38      /**
39       * Gets all the beans that implement a given interface
40       *
41       * @param interfaceClass The interface class
42       * @param <T>            The target interface type
43       * @return A collection of implementations from the plugin's container
44       */
45      <T> Collection<T> getBeansOfType(Class<T> interfaceClass);
46  }