tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1139710 - in /openejb/trunk/openejb3: container/openejb-core/src/main/java/org/apache/openejb/cdi/ tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ tck/cdi-embedded/src/test/resources/
Date Sun, 26 Jun 2011 04:38:56 GMT
Author: dblevins
Date: Sun Jun 26 04:38:56 2011
New Revision: 1139710

URL: http://svn.apache.org/viewvc?rev=1139710&view=rev
Log:
OPENEJB-1594: SessionBeans as @New beans

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/NewCdiEjbBean.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java
    openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ContainersImpl.java
    openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Report.java
    openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/all-failing.xml
    openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/failing.xml
    openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/passing.xml

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java?rev=1139710&r1=1139709&r2=1139710&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
Sun Jun 26 04:38:56 2011
@@ -32,10 +32,12 @@ import javax.enterprise.context.Dependen
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.New;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.SessionBeanType;
 import javax.enterprise.util.AnnotationLiteral;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -105,6 +107,14 @@ public class CdiEjbBean<T> extends BaseE
         return (T) home.create();
     }
 
+    @Override
+    protected void afterConstructor(T instance, CreationalContext<T> tCreationalContext)
{
+    }
+
+//    @Override
+//    public void postConstruct(T instance, CreationalContext<T> cretionalContext)
{
+//    }
+
     public String getEjbName() {
         return this.beanContext.getEjbName();
     }
@@ -145,6 +155,27 @@ public class CdiEjbBean<T> extends BaseE
         return findRemove(beanContext.getBeanClass(), beanContext.getBusinessLocalInterface());
     }
 
+    public List<InjectionPoint> getInjectionPoint(Member member)
+    {
+        if (member instanceof Method) {
+            Method method = (Method) member;
+            member = beanContext.getMatchingBeanMethod(method);
+        }
+
+        List<InjectionPoint> points = new ArrayList<InjectionPoint>();
+
+        for(InjectionPoint ip : injectionPoints)
+        {
+            if(ip.getMember().equals(member))
+            {
+                points.add(ip);
+            }
+        }
+
+        return points;
+    }
+
+
     @SuppressWarnings("unchecked")
     private List<Method> findRemove(Class beanClass, Class beanInterface) {
         List<Method> toReturn = new ArrayList<Method>();

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/NewCdiEjbBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/NewCdiEjbBean.java?rev=1139710&r1=1139709&r2=1139710&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/NewCdiEjbBean.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/NewCdiEjbBean.java
Sun Jun 26 04:38:56 2011
@@ -20,6 +20,7 @@ import org.apache.webbeans.annotation.Ne
 import org.apache.webbeans.component.NewBean;
 
 import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.New;
 import javax.enterprise.util.AnnotationLiteral;
 import java.lang.annotation.Annotation;
@@ -37,7 +38,8 @@ public class NewCdiEjbBean<T> extends Cd
 
         this.getImplQualifiers().add(new NewLiteral(getReturnType()));
 
-
+        this.apiTypes.clear();
+        this.apiTypes.addAll(that.getTypes());
         this.setName(null);
         this.getInjectedFields().addAll(that.getInjectedFields());
         this.getInjectedFromSuperFields().addAll(that.getInjectedFromSuperFields());

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java?rev=1139710&r1=1139709&r2=1139710&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java
Sun Jun 26 04:38:56 2011
@@ -273,15 +273,15 @@ public class OpenEJBLifecycle implements
             //Fire Event
             deployer.fireAfterDeploymentValidationEvent();
 
-//            for (BeanContext beanContext : stuff.getBeanContexts()) {
-//
-//                final CdiEjbBean<Object> bean = beanContext.get(CdiEjbBean.class);;
-//
-//                if (bean == null) continue;
-//
-//                final BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
-//                manager.addBean(new NewCdiEjbBean<Object>(bean));
-//            }
+            for (BeanContext beanContext : stuff.getBeanContexts()) {
+
+                final CdiEjbBean<Object> bean = beanContext.get(CdiEjbBean.class);;
+
+                if (bean == null) continue;
+
+                final BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
+                manager.addBean(new NewCdiEjbBean<Object>(bean));
+            }
 
         } catch (Exception e1) {
             Assembler.logger.error("CDI Beans module deployment failed", e1);

Modified: openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ContainersImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ContainersImpl.java?rev=1139710&r1=1139709&r2=1139710&view=diff
==============================================================================
--- openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ContainersImpl.java
(original)
+++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ContainersImpl.java
Sun Jun 26 04:38:56 2011
@@ -29,6 +29,7 @@ import org.jboss.testharness.spi.Contain
 
 import javax.ejb.embeddable.EJBContainer;
 import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.Closeable;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -36,8 +37,11 @@ import java.io.Flushable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.RandomAccessFile;
 import java.lang.reflect.Field;
 import java.net.URL;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
@@ -109,6 +113,24 @@ public class ContainersImpl implements C
         return clazz.getClassLoader().getResource(resourcePath);
     }
 
+
+    public static void main(String[] args) throws IOException {
+        new ContainersImpl().memoryMappedFile();
+
+        System.out.println();
+    }
+
+    public void memoryMappedFile() throws IOException {
+
+        FileChannel rwChannel = new RandomAccessFile(new File("/tmp/memory-mapped.txt"),
"rw").getChannel();
+
+        final byte[] bytes = "hello world".getBytes();
+
+        ByteBuffer writeonlybuffer = rwChannel.map(FileChannel.MapMode.READ_WRITE, 0, bytes.length);
+        writeonlybuffer.put(bytes);
+        writeonlybuffer.compact();
+    }
+
     private File writeToFile(InputStream archive, String name) throws IOException {
         final File file = File.createTempFile("deploy", "-" + name);
         file.deleteOnExit();
@@ -116,34 +138,32 @@ public class ContainersImpl implements C
         try {
 
             Map<String, URL> resources = new HashMap<String, URL>();
-            
+
             final Class<?> clazz = this.getClass().getClassLoader().loadClass(name.replace(".jar",
""));
 
             if (clazz.isAnnotationPresent(EjbJarXml.class)) {
                 final URL resource = getResource(clazz, clazz.getAnnotation(EjbJarXml.class).value());
-                
+
                 if (resource != null) resources.put("META-INF/ejb-jar.xml", resource);
             }
 
             if (clazz.isAnnotationPresent(PersistenceXml.class)) {
                 final URL resource = getResource(clazz, clazz.getAnnotation(PersistenceXml.class).value());
-                
+
                 if (resource != null) resources.put("META-INF/persistence.xml", resource);
             }
 
             final boolean isJar = name.endsWith(".jar");
 
             final ZipInputStream zin = new ZipInputStream(archive);
-            final ZipOutputStream zout = new ZipOutputStream(new BufferedOutputStream(new
FileOutputStream(file)));
+            final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(524288);
+            final ZipOutputStream zout = new ZipOutputStream(byteArrayOutputStream);
 
             for (ZipEntry entry; (entry = zin.getNextEntry()) != null; ) {
                 String entryName = entry.getName();
 
-                if (entryName.startsWith("WEB-INF")) {
-                    System.out.println(entryName);
-                }
                 if (isJar && entryName.startsWith("WEB-INF/classes/")) {
-                    entryName = entryName.replaceFirst("WEB-INF/classes/","");
+                    entryName = entryName.replaceFirst("WEB-INF/classes/", "");
                 }
 
                 InputStream src = zin;
@@ -168,12 +188,23 @@ public class ContainersImpl implements C
 
             close(zin);
             close(zout);
+
+            writeToFile(file, byteArrayOutputStream);
+
         } catch (Exception e) {
             e.printStackTrace();
         }
         return file;
     }
 
+    private void writeToFile(File file, ByteArrayOutputStream byteArrayOutputStream) throws
IOException {
+        final byte[] bytes = byteArrayOutputStream.toByteArray();
+
+        final FileOutputStream fileOutputStream = new FileOutputStream(file);
+        fileOutputStream.write(bytes);
+        fileOutputStream.close();
+    }
+
     private static void copy(InputStream from, OutputStream to) throws IOException {
         byte[] buffer = new byte[1024];
         int length = 0;

Modified: openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Report.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Report.java?rev=1139710&r1=1139709&r2=1139710&view=diff
==============================================================================
--- openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Report.java
(original)
+++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Report.java
Sun Jun 26 04:38:56 2011
@@ -48,6 +48,7 @@ public class Report {
     private void main() throws Exception {
 //        final File file = new File("/Users/dblevins/work/uber/geronimo-tck-public-trunk/jcdi-tck-runner/target/surefire-reports/testng-results.xml");
         final File file = new File("/Users/dblevins/work/uber/openejb/tck/cdi-embedded/target/surefire-reports/testng-results.xml");
+//        final File file = new File("/Users/dblevins/work/uber/testng-results.xml");
 
         final SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
 
@@ -86,17 +87,15 @@ public class Report {
 
         out.println("<suite name=\"CDI TCK\" verbose=\"0\">");
         out.println("  <test name=\"CDI TCK\">");
-        out.println("    <!--<packages>-->\n" +
-                "        <!--<package name=\"org.jboss.jsr299.tck.tests.*\"/>-->\n"
+
-                "        <!--<package name=\"org.jboss.jsr299.tck.interceptors.tests.*\"/>-->\n"
+
-                "    <!--</packages>-->");
+        out.println("    <packages>\n" +
+                "        <package name=\"org.jboss.jsr299.tck.tests.*\"/>\n" +
+                "        <package name=\"org.jboss.jsr299.tck.interceptors.tests.*\"/>\n"
+
+                "    </packages>");
         out.println("    <classes>");
 
         for (TestClass testClass : classes) {
 
-            if (!contains(testClass, Status.FAIL)) {
-                out.printf("      <class name=\"%s\"/>\n", testClass.name);
-            } else if (contains(testClass, Status.PASS)) {
+            if (contains(testClass, Status.FAIL)) {
                 out.printf("      <class name=\"%s\">\n", testClass.name);
                 out.printf("        <methods>\n");
 

Modified: openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/all-failing.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/all-failing.xml?rev=1139710&r1=1139709&r2=1139710&view=diff
==============================================================================
--- openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/all-failing.xml (original)
+++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/all-failing.xml Sun Jun 26
04:38:56 2011
@@ -22,8 +22,7 @@
       <class name="org.jboss.jsr299.tck.tests.deployment.packaging.bundledLibrary.LibraryInEarTest"/>
       <class name="org.jboss.jsr299.tck.tests.deployment.packaging.bundledLibrary.LibraryInWarTest"/>
       <class name="org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle.EnterpriseBeanLifecycleTest"/>
-      <class name="org.jboss.jsr299.tck.tests.implementation.enterprise.newBean.NewEnterpriseBeanICTest"/>
-      <class name="org.jboss.jsr299.tck.tests.implementation.enterprise.newBean.NewEnterpriseBeanTest"/>
+      <class name="org.jboss.jsr299.tck.tests.implementation.enterprise.remove.EnterpriseBeanRemoveMethodTest"/>
       <class name="org.jboss.jsr299.tck.tests.implementation.producer.method.definition.enterprise.EnterpriseProducerMethodDefinitionTest"/>
       <class name="org.jboss.jsr299.tck.tests.implementation.simple.resource.env.EnvInjectionTest"/>
       <class name="org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext.PersistenceContextInjectionTest"/>

Modified: openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/failing.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/failing.xml?rev=1139710&r1=1139709&r2=1139710&view=diff
==============================================================================
--- openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/failing.xml (original)
+++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/failing.xml Sun Jun 26 04:38:56
2011
@@ -6,19 +6,14 @@
     <!--</packages>-->
     <classes>
       <class name="org.jboss.jsr299.tck.tests.context.dependent.ejb.DependentContextEjbTest"/>
-      <!--<class name="org.jboss.jsr299.tck.tests.context.passivating.broken.dependentScopedProducerFieldReturnsNonSerializableObjectForInjectionIntoStatefulSessionBean.EnterpriseBeanWithIllegalDependencyTest"/>-->
-      <!--<class name="org.jboss.jsr299.tck.tests.context.passivating.broken.dependentScopedProducerMethodReturnsNonSerializableObjectForInjectionIntoStatefulSessionBean.EnterpriseBeanWithIllegalDependencyTest"/>-->
+      <class name="org.jboss.jsr299.tck.tests.context.passivating.broken.dependentScopedProducerFieldReturnsNonSerializableObjectForInjectionIntoStatefulSessionBean.EnterpriseBeanWithIllegalDependencyTest"/>
+      <class name="org.jboss.jsr299.tck.tests.context.passivating.broken.dependentScopedProducerMethodReturnsNonSerializableObjectForInjectionIntoStatefulSessionBean.EnterpriseBeanWithIllegalDependencyTest"/>
       <class name="org.jboss.jsr299.tck.tests.context.request.ejb.EJBRequestContextTest"/>
-      <class name="org.jboss.jsr299.tck.tests.deployment.packaging.bundledLibrary.LibraryInEarTest"/>
+      <class name="org.jboss.jsr299.tck.tests.extensions.producer.ProducerTest"/>
+      <class name="org.jboss.jsr299.tck.tests.implementation.builtin.BuiltInBeansTest"/>
       <class name="org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle.EnterpriseBeanLifecycleTest"/>
-      <class name="org.jboss.jsr299.tck.tests.implementation.enterprise.newBean.NewEnterpriseBeanICTest"/>
       <class name="org.jboss.jsr299.tck.tests.implementation.producer.method.definition.enterprise.EnterpriseProducerMethodDefinitionTest"/>
-      <class name="org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.EnterpriseBeanSpecializationIntegrationTest"/>
-      <class name="org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.EnterpriseBeanSpecializationTest"/>
-      <class name="org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.broken.directlyExtendsNothing.DirectlyExtendsNothingTest"/>
-      <class name="org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.broken.directlyExtendsSimpleBean.DirectlyExtendsSimpleBeanTest"/>
-      <class name="org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.broken.implementInterfaceAndExtendsNothing.ImplementsInterfaceAndExtendsNothingTest"/>
-      <class name="org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.broken.sameName.SameNameTest"/>
+      <class name="org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb.EjbInjectionTest"/>
       <class name="org.jboss.jsr299.tck.tests.interceptors.definition.enterprise.nonContextualReference.SessionBeanInterceptorOnNonContextualEjbReferenceTest"/>
       <class name="org.jboss.jsr299.tck.tests.lookup.injection.non.contextual.ws.InjectionIntoWebServiceEndPointTest"/>
     </classes>

Modified: openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/passing.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/passing.xml?rev=1139710&r1=1139709&r2=1139710&view=diff
==============================================================================
--- openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/passing.xml (original)
+++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/passing.xml Sun Jun 26 04:38:56
2011
@@ -121,25 +121,12 @@
         <methods>
           <exclude name="testCreateSFSB"/>
           <exclude name="testDependentObjectsDestroyed"/>
-          <exclude name="testDestroyRemovesSFSB"/>
           <exclude name="testSerializeSFSB"/>
         </methods>
       </class>
-      <class name="org.jboss.jsr299.tck.tests.implementation.enterprise.newBean.NewEnterpriseBeanICTest">
+      <class name="org.jboss.jsr299.tck.tests.implementation.enterprise.remove.EnterpriseBeanRemoveMethodTest">
         <methods>
-          <exclude name="testNewBeanHasNoDisposalMethods"/>
-          <exclude name="testNewBeanHasNoProducerMethods"/>
-          <exclude name="testNewBeanHasSameConstructor"/>
-          <exclude name="testNewBeanHasSameInitializers"/>
-        </methods>
-      </class>
-      <class name="org.jboss.jsr299.tck.tests.implementation.enterprise.newBean.NewEnterpriseBeanTest">
-        <methods>
-          <exclude name="testForEachEnterpriseBeanANewBeanExists"/>
-          <exclude name="testNewBeanHasNoBeanELName"/>
-          <exclude name="testNewBeanHasNoStereotypes"/>
-          <exclude name="testNewBeanIsHasOnlyNewBinding"/>
-          <exclude name="testNewBeanIsDependentScoped"/>
+          <exclude name="testApplicationCannotCallRemoveMethodOnNonDependentScopedSessionEnterpriseBean"/>
         </methods>
       </class>
       <class name="org.jboss.jsr299.tck.tests.implementation.producer.method.definition.enterprise.EnterpriseProducerMethodDefinitionTest">



Mime
View raw message