Skip to content

Instantly share code, notes, and snippets.

@pmuir
Created September 14, 2010 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pmuir/579034 to your computer and use it in GitHub Desktop.
Save pmuir/579034 to your computer and use it in GitHub Desktop.
/**
* 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();
}
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);
}
interface InjectorRegistry {
/**
* Per module registry of injectors, registered with a priority to allow calling in a determined order.
*/
void addInjector(int priority, Injector<?> injector);
}
/**
* 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