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 /**
13 * Will ask the container to instantiate a bean of the given class and does inject all constructor defined dependencies.
14 * Currently we have only spring as a container that will autowire this bean.
15 *
16 * @param clazz the Class to instantiate. Cannot be null.
17 *
18 * @return an instantiated bean.
19 */
20 <T> T createBean(Class<T> clazz);
21
22 /**
23 * Injects an existing bean instance with any dependencies via setters or private field injection
24 * @param bean The instantiated bean to inject
25 * @param <T> The bean type
26 * @since 3.0
27 */
28 <T> T injectBean(T bean);
29
30 /**
31 * Retrieves a bean by name from the container.
32 *
33 * @param id the id of the container bean, cannot be null
34 *
35 * @return the bean object, or null if cannot be found
36 * @since 3.0
37 */
38 <T> T getBean(String id);
39
40 /**
41 * Gets all the beans that implement a given interface
42 *
43 * @param interfaceClass The interface class
44 * @param <T> The target interface type
45 * @return A collection of implementations from the plugin's container
46 */
47 <T> Collection<T> getBeansOfType(Class<T> interfaceClass);
48 }