Repository navigation
Expand file tree
/
Copy pathDependencyInjector.java
More file actions
51 lines (44 loc) · 1.9 KB
/
Copy pathDependencyInjector.java
File metadata and controls
51 lines (44 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package act.di;
import act.app.AppService;
import act.util.ActContext;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
public interface DependencyInjector<DI extends DependencyInjector> extends AppService<DI> {
/**
* Create an instance of type T using the class of type T
* @param clazz
* @param <T>
* @return the injector instance
*/
<T> T create(Class<T> clazz);
/**
* Create an injector that is able to inject {@link ActContext} instance if the type
* is required
* @param context
* @return a injector instance support injecting app context
*/
DependencyInjector<DI> createContextAwareInjector(ActContext context);
/**
* Register a {@link DependencyInjectionBinder} to the injector
* @param binder the binder
*/
void registerDiBinder(DependencyInjectionBinder binder);
/**
* Register a {@link DependencyInjectionListener} to the injector
* @param listener the dependency injection event listener
*/
void registerDiListener(DependencyInjectionListener listener);
/**
* Once an object has been created and ready for injection, this method will be
* called to call back to the {@link DependencyInjectionListener listeners} that has been
* {@link #registerDiListener(DependencyInjectionListener) registered}
* @param injectee the object to be injected
* @param typeParameters if the object is to be injected to a field, and the field's
* {@link Field#getGenericType() generic type} is kind of
* {@link java.lang.reflect.ParameterizedType} then the
* {@link ParameterizedType#getActualTypeArguments() type parameters}
* will be passed to the listener
*/
void fireInjectedEvent(Object injectee, Type[] typeParameters);
}