01: package com.bm.ejb3guice.introspect;
02:
03: import com.bm.ejb3guice.inject.Key;
04: import com.bm.ejb3guice.inject.Provider;
05: import com.bm.ejb3guice.inject.Scope;
06:
07: import java.lang.reflect.Constructor;
08: import java.util.Set;
09:
10: /**
11: * Javadoc.
12: *
13: * @author Kevin Bourrillion (kevinb9n@gmail.com)
14: */
15: public interface Implementation<T> {
16:
17: enum ProvisionStrategy {
18:
19: /**
20: * An instance was provided to Guice by the Module; this instance will be
21: * used to fulfill every request.
22: */
23: INSTANCE,
24:
25: /**
26: * Guice obtains instances for this implementation by invoking an injectable
27: * constructor (either the lone constructor marked with {@code @Inject} or
28: * a parameterless constructor).
29: */
30: CONSTRUCTOR,
31:
32: /**
33: * Guice will resolve a Provider key to an instance, then use this provider
34: * instance to provide the current implementation.
35: */
36: PROVIDER,
37:
38: /**
39: * This is a reserved key that Guice provides natively, like Injector or
40: * Stage.
41: */
42: RESERVED,
43: }
44:
45: /**
46: * Returns the strategy Guice will use to provide instances for this
47: * implementation.
48: */
49: ProvisionStrategy getProvisionStrategy();
50:
51: /**
52: * Returns the constructor Guice will use to obtain instances for this
53: * implementation.
54: *
55: * @throws IllegalStateException if {@link #getProvisionStrategy()} is not
56: * {@link ProvisionStrategy#CONSTRUCTOR}.
57: */
58: Constructor<? extends T> getInjectableConstructor();
59:
60: /**
61: * Returns the provider Guice will use to obtain instances for this
62: * implementation. TODO: what about @Provides methods?
63: *
64: * @throws IllegalStateException if {@link #getProvisionStrategy()} is not
65: * {@link ProvisionStrategy#PROVIDER}.
66: */
67: Implementation<? extends Provider<? extends T>> getProvider();
68:
69: /**
70: * Returns the scope applied to this implementation, or null if there is none.
71: */
72: Scope getScope();
73:
74: /**
75: * Returns all keys which resolve to this implementation.
76: */
77: Set<Key<? super T>> getKeys();
78:
79: /**
80: * Returns a Dependency instance for each dependency this implementation has;
81: * that is, "everyone we depend on."
82: */
83: Set<Dependency<?>> getDependencies();
84:
85: /**
86: * Returns a Dependency instance for each dependent this implementation has;
87: * that is, "everyone who depends on us."
88: */
89: Set<Dependency<?>> getDependents();
90: }
|