tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1133594 - in /openejb/trunk/openejb3/container/openejb-core/src: main/java/org/apache/openejb/ main/java/org/apache/openejb/junit/ test/java/org/apache/openejb/cdi/
Date Wed, 08 Jun 2011 22:58:59 GMT
Author: dblevins
Date: Wed Jun  8 22:58:59 2011
New Revision: 1133594

URL: http://svn.apache.org/viewvc?rev=1133594&view=rev
Log:
OPENEJB-1571: CDI Injection for OpenEjbContainer and ApplicationComposer

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/BasicObserverTest.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/StatefulDecoratorInjectionTest.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java?rev=1133594&r1=1133593&r2=1133594&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
Wed Jun  8 22:58:59 2011
@@ -18,6 +18,7 @@ package org.apache.openejb;
 
 import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.cdi.OWBInjector;
 import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.ConfigurationFactory;
 import org.apache.openejb.config.ConnectorModule;
@@ -126,6 +127,14 @@ public class OpenEjbContainer extends EJ
         final InjectionProcessor processor = new InjectionProcessor(object, context.getInjections(),
context.getJndiContext());
 
         try {
+            OWBInjector beanInjector = new OWBInjector(appContext.getWebBeansContext());
+            beanInjector.inject(object);
+        } catch (Throwable t) {
+            // TODO handle this differently
+            // this is temporary till the injector can be rewritten
+        }
+
+        try {
             return (T) processor.createInstance();
         } catch (OpenEJBException e) {
             throw new InjectionException(clazz.getName(), e);

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java?rev=1133594&r1=1133593&r2=1133594&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
Wed Jun  8 22:58:59 2011
@@ -16,10 +16,12 @@
  */
 package org.apache.openejb.junit;
 
+import org.apache.openejb.AppContext;
 import org.apache.openejb.BeanContext;
 import org.apache.openejb.InjectionProcessor;
 import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.cdi.OWBInjector;
 import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.ConfigurationFactory;
 import org.apache.openejb.config.ConnectorModule;
@@ -258,7 +260,7 @@ public class ApplicationComposer extends
 
                 final AppInfo appInfo = config.configureApplication(appModule);
 
-                assembler.createApplication(appInfo);
+                final AppContext appContext = assembler.createApplication(appInfo);
 
                 try {
                     final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
@@ -268,6 +270,15 @@ public class ApplicationComposer extends
 
                     processor.createInstance();
 
+                    try {
+                        OWBInjector beanInjector = new OWBInjector(appContext.getWebBeansContext());
+                        beanInjector.inject(testInstance);
+                    } catch (Throwable t) {
+                        // TODO handle this differently
+                        // this is temporary till the injector can be rewritten
+                    }
+
+
                     System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
 
                     final ThreadContext previous = ThreadContext.enter(new ThreadContext(context,
null, Operation.BUSINESS));

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/BasicObserverTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/BasicObserverTest.java?rev=1133594&r1=1133593&r2=1133594&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/BasicObserverTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/BasicObserverTest.java
Wed Jun  8 22:58:59 2011
@@ -19,12 +19,12 @@ package org.apache.openejb.cdi;
 import org.apache.openejb.jee.Beans;
 import org.apache.openejb.junit.ApplicationComposer;
 import org.apache.openejb.junit.Module;
-import org.apache.webbeans.config.WebBeansContext;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -37,9 +37,11 @@ import static junit.framework.Assert.ass
 @RunWith(ApplicationComposer.class)
 public class BasicObserverTest {
 
+    @Inject
+    private BeanManager beanManager;
+
     @Test
     public void test() throws Exception {
-        final BeanManager beanManager = WebBeansContext.getInstance().getBeanManagerImpl();
         assertNotNull(beanManager);
 
         final Catastrophy catastrophy = new Catastrophy();

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/StatefulDecoratorInjectionTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/StatefulDecoratorInjectionTest.java?rev=1133594&r1=1133593&r2=1133594&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/StatefulDecoratorInjectionTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/StatefulDecoratorInjectionTest.java
Wed Jun  8 22:58:59 2011
@@ -29,13 +29,11 @@ import javax.decorator.Decorator;
 import javax.decorator.Delegate;
 import javax.ejb.ApplicationException;
 import javax.ejb.EJB;
-import javax.ejb.EJBAccessException;
 import javax.ejb.Local;
 import javax.ejb.SessionContext;
 import javax.ejb.Stateful;
 import javax.enterprise.inject.Produces;
 import javax.inject.Inject;
-
 import java.security.Principal;
 
 import static junit.framework.Assert.assertNotNull;



Mime
View raw message