(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Wed, 14 Jul 2010 21:42:18 +0000 (21:42 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Wed, 14 Jul 2010 21:42:18 +0000 (21:42 +0000)
support/cdi/src/main/java/org/wamblee/cdi/BeanManagerLookup.java
support/cdi/src/main/java/org/wamblee/cdi/Injectable.java
support/cdi/src/main/java/org/wamblee/cdi/SimpleInjector.java

index 2952653870e18ebcfbf974232bedafb10be522e5..50bed00a907aae1be4913e5a3108da8b75f6944b 100644 (file)
@@ -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;
 
     /**
index 6e9f7b8c1784a4c41dcc1b7bc37f5aa74ab12bdd..2a9a8e883fe8bb6db2cb21056606b13cf96041dd 100644 (file)
@@ -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);
     }
 }
index 7a8db0da4397c21531acfcf3e5d75522248d6431..12ebc30729b5104624963c4775f61e28aafb0500 100644 (file)
@@ -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);
     }
 }