openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bergm...@apache.org
Subject svn commit: r1135868 - in /openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb: EjbPlugin.java component/NewOpenEjbBean.java
Date Wed, 15 Jun 2011 00:20:44 GMT
Author: bergmark
Date: Wed Jun 15 00:20:44 2011
New Revision: 1135868

URL: http://svn.apache.org/viewvc?rev=1135868&view=rev
Log:
[OWB-574] First pass at NewBean code for openwebbeans-openejb

Added:
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/NewOpenEjbBean.java
  (with props)
Modified:
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java

Modified: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java?rev=1135868&r1=1135867&r2=1135868&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
(original)
+++ openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
Wed Jun 15 00:20:44 2011
@@ -18,18 +18,21 @@
  */
 package org.apache.webbeans.ejb;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
+import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArraySet;
 
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
 import javax.enterprise.inject.spi.SessionBeanType;
 
@@ -49,14 +52,19 @@ import org.apache.openejb.core.stateful.
 import org.apache.openejb.core.stateless.StatelessContainer;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.spi.ContainerSystem;
+import org.apache.webbeans.annotation.DependentScopeLiteral;
+import org.apache.webbeans.annotation.NewLiteral;
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.ejb.common.util.EjbDefinitionUtility;
 import org.apache.webbeans.ejb.common.util.EjbUtility;
+import org.apache.webbeans.ejb.component.NewOpenEjbBean;
 import org.apache.webbeans.ejb.component.OpenEjbBean;
 import org.apache.webbeans.ejb.resource.EJBInstanceProxy;
 import org.apache.webbeans.ejb.service.OpenEJBSecurityService;
 import org.apache.webbeans.ejb.service.OpenEJBTransactionService;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.intercept.InterceptorData;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.spi.SecurityService;
 import org.apache.webbeans.spi.TransactionService;
@@ -322,6 +330,11 @@ public class EjbPlugin extends AbstractO
         bean.setDeploymentInfo(info);
 
         EjbUtility.fireEvents(clazz, bean, processAnnotatedTypeEvent);
+        
+        //Add the @New Bean as we are temporarily bypassing this in EJBUtility.fireEvents
+        WebBeansContext webBeansContext = bean.getWebBeansContext();
+        BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
+        manager.addBean(createNewBean(bean));
 
         return bean;
     }
@@ -584,5 +597,48 @@ public class EjbPlugin extends AbstractO
 
         return bindings;
     }
+    
+    /**
+     * Creates a version of the OpenEjbBean that implements the NewBean
+     * interface and has the properties of a NewBean
+     */
+    public <T> OpenEjbBean<T> createNewBean(OpenEjbBean<T> ejbBean)
+    {
+
+        OpenEjbBean<T> atNewEjb = new NewOpenEjbBean<T>((Class<T>) ejbBean.getBeanClass(),
ejbBean.getEjbType());
+
+        Class clazz = ejbBean.getBeanClass();
+
+        atNewEjb.setImplScopeType(new DependentScopeLiteral());
+        atNewEjb.addQualifier(new NewLiteral(clazz));
+
+        atNewEjb.getTypes().addAll(ejbBean.getTypes());
+
+        for (Field injectedField : ejbBean.getInjectedFields())
+        {
+            atNewEjb.addInjectedField(injectedField);
+        }
+
+        for (Method injectedMethod : ejbBean.getInjectedMethods())
+        {
+            atNewEjb.addInjectedMethod(injectedMethod);
+        }
+
+        List<InterceptorData> interceptorList = ejbBean.getInterceptorStack();
+        if (!interceptorList.isEmpty())
+        {
+            atNewEjb.getInterceptorStack().addAll(interceptorList);
+        }
+
+        Set<InjectionPoint> injectionPoints = ejbBean.getInjectionPoints();
+        for (InjectionPoint injectionPoint : injectionPoints)
+        {
+            atNewEjb.addInjectionPoint(injectionPoint);
+        }
+
+        atNewEjb.setDeploymentInfo(ejbBean.getDeploymentInfo());
+
+        return atNewEjb;
+    }
 
 }

Added: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/NewOpenEjbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/NewOpenEjbBean.java?rev=1135868&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/NewOpenEjbBean.java
(added)
+++ openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/NewOpenEjbBean.java
Wed Jun 15 00:20:44 2011
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.ejb.component;
+
+import javax.enterprise.inject.spi.SessionBeanType;
+
+import org.apache.webbeans.component.NewBean;
+
+public class NewOpenEjbBean<T> extends OpenEjbBean<T> implements NewBean<T>
+{
+    /**
+     * Creates a new instance of the session bean.
+     * @param ejbClassType ebj class type
+     */
+    public NewOpenEjbBean(Class<T> ejbClassType, SessionBeanType type)
+    {
+        super(ejbClassType, type);
+    }
+    
+    /**
+     * always true for New qualifier
+     */
+    @Override
+    public boolean isDependent()
+    {
+        return true;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/NewOpenEjbBean.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message