From: erik Date: Wed, 14 Jul 2010 21:42:18 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.3~91 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=155ab1be087090ec5f78f2983f0bac93d2af7b7f;p=utils --- diff --git a/support/cdi/src/main/java/org/wamblee/cdi/BeanManagerLookup.java b/support/cdi/src/main/java/org/wamblee/cdi/BeanManagerLookup.java index 29526538..50bed00a 100644 --- a/support/cdi/src/main/java/org/wamblee/cdi/BeanManagerLookup.java +++ b/support/cdi/src/main/java/org/wamblee/cdi/BeanManagerLookup.java @@ -35,7 +35,7 @@ public class BeanManagerLookup { 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; /** diff --git a/support/cdi/src/main/java/org/wamblee/cdi/Injectable.java b/support/cdi/src/main/java/org/wamblee/cdi/Injectable.java index 6e9f7b8c..2a9a8e88 100644 --- a/support/cdi/src/main/java/org/wamblee/cdi/Injectable.java +++ b/support/cdi/src/main/java/org/wamblee/cdi/Injectable.java @@ -26,11 +26,13 @@ package org.wamblee.cdi; * @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); } } diff --git a/support/cdi/src/main/java/org/wamblee/cdi/SimpleInjector.java b/support/cdi/src/main/java/org/wamblee/cdi/SimpleInjector.java index 7a8db0da..12ebc307 100644 --- a/support/cdi/src/main/java/org/wamblee/cdi/SimpleInjector.java +++ b/support/cdi/src/main/java/org/wamblee/cdi/SimpleInjector.java @@ -23,26 +23,31 @@ package org.wamblee.cdi; */ 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); } }