1 package com.atlassian.plugin;
2
3 /**
4 * Defines a plugin that is capable of creating and autowiring beans. The name and autowire types copied from Spring's
5 * AutowireCapableBeanFactory.
6 */
7 public interface AutowireCapablePlugin
8 {
9 /**
10 * The autowire strategy to use when creating and wiring a bean
11 */
12 enum AutowireStrategy
13 {
14 AUTOWIRE_NO,
15 /** Performs setter-based injection by name */
16 AUTOWIRE_BY_NAME,
17
18 /** Performs setter-based injection by type */
19 AUTOWIRE_BY_TYPE,
20
21 /** Performs construction-based injection by type */
22 AUTOWIRE_BY_CONSTRUCTOR,
23
24 /**
25 * Autodetects appropriate injection by first seeing if any no-arg constructors exist. If not, performs constructor
26 * injection, and if so, autowires by type then name
27 */
28 AUTOWIRE_AUTODETECT
29 }
30
31 /**
32 * Creates and autowires a class using the default strategy.
33 * @param clazz The class to create
34 * @return The created and wired bean
35 */
36 <T> T autowire(Class<T> clazz);
37
38 /**
39 * Creates and autowires a class with a specific autowire strategy
40 *
41 * @param clazz The class to create
42 * @param autowireStrategy The autowire strategy
43 * @return The created and wired bean
44 */
45 <T> T autowire(Class<T> clazz, AutowireStrategy autowireStrategy);
46
47 /**
48 * Autowires an existing object using the default strategy.
49 * @param instance The object to inject
50 */
51 void autowire(Object instance);
52
53 /**
54 * Autowires an existing object with a specific autowire strategy
55 *
56 * @param instance The object to autowire
57 * @param autowireStrategy The autowire strategy, must not be constructor
58 */
59 void autowire(Object instance, AutowireStrategy autowireStrategy);
60 }