Created
September 14, 2010 13:33
-
-
Save pmuir/579034 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The context in which instance injection occurs. | |
* | |
* @author Pete Muir | |
* | |
*/ | |
public interface InjectionContext<T> | |
{ | |
/** | |
* Calling {@link #proceed()} will cause the next injector to perform injection on the | |
* instance as it normally would. It is legal to not call {@link #proceed()}, | |
* however the container must ensure all injection occurs. | |
*/ | |
public void proceed(); | |
/** | |
* Get the underlying instance to be injected. | |
*/ | |
public T getTarget(); | |
/** | |
* Get the {@link AnnotatedMember} for the instance being injected | |
* | |
*/ | |
public AnnotatedMember<T> getAnnotatedMember(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Injector<T> { | |
// Inject any fields or methods that should be injected | |
void inject(InjectionContext<T> ctx); | |
// Create an instance, performing constructor injection as required | |
T produce(ProductionContext<T> ctx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface InjectorRegistry { | |
/** | |
* Per module registry of injectors, registered with a priority to allow calling in a determined order. | |
*/ | |
void addInjector(int priority, Injector<?> injector); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The context in which instance injection occurs. | |
* | |
* @author Pete Muir | |
* | |
*/ | |
public interface ProductionContext<T> | |
{ | |
/** | |
* Calling {@link #proceed()} will cause the next injector to perform production on the | |
* instance as it normally would. It is legal to not call {@link #proceed()}, | |
* however the container must ensure all injection occurs. | |
* | |
* @return the instance produced by the next injector in the chain | |
*/ | |
public T proceed(); | |
/** | |
* Get the {@link AnnotatedMember} for the instance being injected | |
* | |
*/ | |
public AnnotatedMember<T> getAnnotatedMember(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment