/**
* <p>
- * Component instantiation listener that injects references into a component
- * using the injector mini-framework. Together with an implementation of the
+ * Component instantiation listener that injects references into a component
+ * using the injector mini-framework. Together with an implementation of the
* mini-framework, Contexts and Dependency Injection support can be provided or
- * for standard Java EE injection into components. Or, other injection
+ * for standard Java EE injection into components. Or, other injection
* frameworks can be used.
* </p>
*
* <p>
- * To use this injector override {@link WebApplication#init()} and add the
- * listener:
+ * To use this injector override {@link WebApplication#init()} and add the
+ * listener:
* </p>
+ *
* <pre>
- * @Override
- * protected void init() {
- * super.init();
- * addComponentInstantiationListener(new ComponentInstantiationInjector());
- * }
+ * @Override
+ * protected void init() {
+ * super.init();
+ * addComponentInstantiationListener(new ComponentInstantiationInjector());
+ * }
* </pre>
*
* @author Erik Brakkee
*/
public class ComponentInstantiationInjector implements
- IComponentInstantiationListener {
-
- private SimpleInjector injector;
-
+ IComponentInstantiationListener {
+
+ private SimpleInjector injector;
+
/**
- * Constructs the component instantiation listener.
+ * Constructs the component instantiation listener.
*/
- public ComponentInstantiationInjector() {
+ public ComponentInstantiationInjector() {
injector = new SimpleInjector(InjectorBuilder.getInjectorFactory());
}
-
+
@Override
public void onInstantiation(Component aComponent) {
injector.inject(aComponent);
+ aComponent.add(new InjectionBehavior());
}
}