private static final Logger LOGGER = Logger
.getLogger(BeanManagerLookup.class.getName());
- private static final String BEAN_MANAGER_JNDI = "java:comp/BeanManager";
+ public static final String BEAN_MANAGER_JNDI = "java:comp/BeanManager";
private static BeanManager mgr = null;
/**
* @author Erik Brakkee
*/
public abstract class Injectable {
+
+ private static final SimpleInjector INJECTOR = new SimpleInjector();
/**
* Inheritance style constructor.
*/
protected Injectable() {
- SimpleInjector.inject(this);
+ INJECTOR.inject(this);
}
}
*/
public class SimpleInjector {
- private static InjectorCache cache = new InjectorCache(
+ private InjectorCache cache = new InjectorCache(
new CdiInjectorFactory());
/**
- * Override the injector factory (mainly fo runit test).
- *
- * @param aFactory
- * Factory.
+ * Constructs the injector.
*/
- public static void setInjectorFactory(InjectorFactory aFactory) {
+ public SimpleInjector() {
+ cache = new InjectorCache(new CdiInjectorFactory());
+ }
+
+ /**
+ * Construcst the injector.
+ * @param aFactory Factory to use.
+ */
+ public SimpleInjector(InjectorFactory aFactory) {
cache = new InjectorCache(aFactory);
}
-
+
/**
* Injects into a given object.
*
* @param aObject
* Object to inject into.
*/
- public static void inject(Object aObject) {
+ public void inject(Object aObject) {
cache.getInjector(aObject.getClass()).inject(aObject);
}
}