tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1183145 - in /openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main: java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEEnricher.java resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher
Date Thu, 13 Oct 2011 22:29:25 GMT
Author: rmannibucau
Date: Thu Oct 13 22:29:24 2011
New Revision: 1183145

URL: http://svn.apache.org/viewvc?rev=1183145&view=rev
Log:
missing tomee enricher files

Added:
    openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEEnricher.java
    openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher

Added: openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEEnricher.java
URL: http://svn.apache.org/viewvc/openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEEnricher.java?rev=1183145&view=auto
==============================================================================
--- openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEEnricher.java
(added)
+++ openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEEnricher.java
Thu Oct 13 22:29:24 2011
@@ -0,0 +1,50 @@
+package org.apache.openejb.arquillian.embedded;
+
+import org.apache.openejb.cdi.ThreadSingletonServiceImpl;
+import org.jboss.arquillian.test.spi.TestEnricher;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+import java.lang.reflect.Method;
+
+/**
+ * @author rmannibucau
+ */
+public class EmbeddedTomEEEnricher implements TestEnricher {
+    @Override public void enrich(Object testCase) {
+        BeanManager mgr = getBeanManager();
+        if (mgr != null) {
+            AnnotatedType<?> type =  mgr.createAnnotatedType(getClass());
+            InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>)
mgr.createInjectionTarget(type);
+            CreationalContext<Object> context = mgr.createCreationalContext(null);
+
+            injectionTarget.inject(testCase, context);
+            injectionTarget.postConstruct(this);
+        } else {
+            throw new NullPointerException("bean manager is null");
+        }
+
+        /* TODO: see if this code could be called after tests
+                *
+                * if (injectionTarget != null) {
+                *        injectionTarget.preDestroy(this);
+                *    }
+                *   if (context != null) {
+                *        context.release();
+                *    }
+                *
+                *   injectionTarget = null;
+                *   context = null;
+                */
+    }
+
+    @Override public Object[] resolve(Method method) {
+        return new Object[method.getParameterTypes().length];
+    }
+
+    public BeanManager getBeanManager() {
+        return ThreadSingletonServiceImpl.get().getBeanManagerImpl();
+    }
+}

Added: openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher
URL: http://svn.apache.org/viewvc/openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher?rev=1183145&view=auto
==============================================================================
--- openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher
(added)
+++ openejb/trunk/arquillian-tomee/arquillian-tomee-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher
Thu Oct 13 22:29:24 2011
@@ -0,0 +1 @@
+org.apache.openejb.arquillian.embedded.EmbeddedTomEEEnricher



Mime
View raw message