openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r794378 - in /incubator/openwebbeans/trunk/webbeans-ejb: ./ src/main/java/org/apache/webbeans/ejb/ src/main/java/org/apache/webbeans/ejb/component/ src/main/java/org/apache/webbeans/ejb/component/creation/ src/main/java/org/apache/webbeans/...
Date Wed, 15 Jul 2009 19:44:29 GMT
Author: gerdogdu
Date: Wed Jul 15 19:44:28 2009
New Revision: 794378

URL: http://svn.apache.org/viewvc?rev=794378&view=rev
Log:
Update/delete old code. Support for session beans using OpenEJB container in Tomcat.

Added:
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/EjbBean.java
      - copied, changed from r793274, incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/EjbComponentImpl.java
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/EjbBeanCreator.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/EjbBeanCreatorImpl.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/resources/
Removed:
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/EjbType.java
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/EjbComponentImpl.java
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/definition/
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/proxy/EjbComponentProxy.java
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/xml/
    incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/apitype/businessmethod/
Modified:
    incubator/openwebbeans/trunk/webbeans-ejb/pom.xml
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/interceptor/OpenWebBeansEjbInterceptor.java
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbDefinitionUtility.java
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbUtility.java
    incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbValidator.java
    incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/EjbTestContext.java
    incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/apitype/EjbApiTypeTest.java
    incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/validator/EjbValidatorTest.java

Modified: incubator/openwebbeans/trunk/webbeans-ejb/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/pom.xml?rev=794378&r1=794377&r2=794378&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/pom.xml (original)
+++ incubator/openwebbeans/trunk/webbeans-ejb/pom.xml Wed Jul 15 19:44:28 2009
@@ -28,23 +28,24 @@
 	<packaging>jar</packaging>
 	<description>OpenWebBeans EJB Integration</description>
 	<dependencies>
+		
 		<dependency>
 			<groupId>org.apache.openwebbeans</groupId>
 			<artifactId>openwebbeans-impl</artifactId>
-			<version>1.0.0-incubating-SNAPSHOT</version>
 		</dependency>
+		
+        <dependency>
+            <groupId>org.apache.openejb</groupId>
+            <artifactId>openejb-core</artifactId>
+            <optional>true</optional>
+        </dependency>
+				
 		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
 			<version>4.5</version>
 			<scope>test</scope>
 		</dependency>
-		<dependency>
-			<groupId>org.apache.openwebbeans</groupId>
-			<artifactId>openwebbeans-impl</artifactId>
-			<version>1.0.0-incubating-SNAPSHOT</version>
-			<classifier>tests</classifier>
-			<scope>test</scope>
-		</dependency>
+		
 	</dependencies>
 </project>

Copied: incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/EjbBean.java
(from r793274, incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/EjbComponentImpl.java)
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/EjbBean.java?p2=incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/EjbBean.java&p1=incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/EjbComponentImpl.java&r1=793274&r2=794378&rev=794378&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/EjbComponentImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/EjbBean.java
Wed Jul 15 19:44:28 2009
@@ -16,61 +16,103 @@
  */
 package org.apache.webbeans.ejb.component;
 
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
 import javax.enterprise.context.spi.CreationalContext;
-
+import javax.enterprise.inject.spi.SessionBeanType;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.InterfaceType;
+import org.apache.openejb.assembler.classic.JndiBuilder;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
+import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.component.WebBeansType;
-import org.apache.webbeans.ejb.EjbType;
 
 /**
  * @version $Rev$ $Date$
  */
-public class EjbComponentImpl<T> extends AbstractInjectionTargetBean<T>
+public class EjbBean<T> extends AbstractInjectionTargetBean<T> implements EnterpriseBeanMarker
 {
-    private EjbType ejbType;
+    private SessionBeanType ejbType;
     
-    private Set<Method> businessMethods = new HashSet<Method>();
+    private DeploymentInfo deploymentInfo;    
     
-    public EjbComponentImpl(Class<T> ejbClassType)
+    private T instance = null;
+    
+    public EjbBean(Class<T> ejbClassType)
     {
         super(WebBeansType.ENTERPRISE,ejbClassType);
     }
 
+    public void setDeploymentInfo(DeploymentInfo deploymentInfo)
+    {
+        this.deploymentInfo = deploymentInfo;
+    }
+        
+    public DeploymentInfo getDeploymentInfo()
+    {
+        return this.deploymentInfo;
+    }
+    
+        
     @Override
+    public void injectFields(T instance, CreationalContext<T> creationalContext)
+    {
+        //No-operations
+    }
+    
+    @SuppressWarnings("unchecked")
+    public void injectFieldInInterceptor(Object instance, CreationalContext<?> creationalContext)
+    {
+        super.injectFields((T)instance, (CreationalContext<T>)creationalContext);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
     protected T createComponentInstance(CreationalContext<T> creationalContext)
     {
-        return null;
+        if(this.instance == null)
+        {
+            ContainerSystem containerSystem =  SystemInstance.get().getComponent(ContainerSystem.class);
+            Context jndiContext = containerSystem.getJNDIContext();
+            DeploymentInfo deploymentInfo = this.getDeploymentInfo();
+            try
+            {
+                Class<T> intf = deploymentInfo.getInterface(InterfaceType.BUSINESS_LOCAL);
+                String jndiName = "java:openejb/Deployment/" + JndiBuilder.format(deploymentInfo.getDeploymentID(),
intf.getName()); 
+                this.instance = intf.cast(jndiContext.lookup(jndiName));                
            
+                
+            }catch(NamingException e)
+            {
+                throw new RuntimeException(e);
+            }        
+        }
+
+        return instance;
     }
 
     @Override
     protected void destroyComponentInstance(T instance)
     {
-        
+        this.instance = null;
     }
     
-    public void setEjbType(EjbType type)
+    public void setEjbType(SessionBeanType type)
     {
         this.ejbType = type;
         
     }
     
-    public EjbType getEjbType()
+    public String getEjbName()
     {
-        return this.ejbType;
-    }
-
-    public void addBusinessMethod(Method method)
-    {
-        this.businessMethods.add(method);
+        return this.deploymentInfo.getEjbName();
     }
     
-    public Set<Method> getBusinessMethods()
+    public SessionBeanType getEjbType()
     {
-        return Collections.unmodifiableSet(this.businessMethods);
+        return this.ejbType;
     }
-}
+
+}
\ No newline at end of file

Added: incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/EjbBeanCreator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/EjbBeanCreator.java?rev=794378&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/EjbBeanCreator.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/EjbBeanCreator.java
Wed Jul 15 19:44:28 2009
@@ -0,0 +1,21 @@
+/*
+ * 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.creation;
+
+import org.apache.webbeans.component.creation.InjectedTargetBeanCreator;
+
+public interface EjbBeanCreator<T> extends InjectedTargetBeanCreator<T> 
+{
+
+}

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

Added: incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/EjbBeanCreatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/EjbBeanCreatorImpl.java?rev=794378&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/EjbBeanCreatorImpl.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/component/creation/EjbBeanCreatorImpl.java
Wed Jul 15 19:44:28 2009
@@ -0,0 +1,34 @@
+/*
+ * 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.creation;
+
+import org.apache.webbeans.component.creation.AbstractInjectedTargetBeanCreator;
+import org.apache.webbeans.ejb.component.EjbBean;
+import org.apache.webbeans.ejb.util.EjbValidator;
+
+public class EjbBeanCreatorImpl<T> extends AbstractInjectedTargetBeanCreator<T>
implements EjbBeanCreator<T>
+{
+    public EjbBeanCreatorImpl(EjbBean<T> ejbBean)
+    {
+        super(ejbBean);
+    }
+
+    @Override
+    public void checkCreateConditions()
+    {
+        EjbValidator.validateDecoratorOrInterceptor(getBean().getReturnType());
+    }
+    
+    
+}

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

Modified: incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/interceptor/OpenWebBeansEjbInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/interceptor/OpenWebBeansEjbInterceptor.java?rev=794378&r1=794377&r2=794378&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/interceptor/OpenWebBeansEjbInterceptor.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/interceptor/OpenWebBeansEjbInterceptor.java
Wed Jul 15 19:44:28 2009
@@ -19,12 +19,32 @@
 import javax.annotation.PostConstruct;
 import javax.interceptor.InvocationContext;
 
+import org.apache.webbeans.ejb.component.EjbBean;
+
 public class OpenWebBeansEjbInterceptor
 {
+    private static ThreadLocal<EjbBean<?>> threadLocal = new ThreadLocal<EjbBean<?>>();
+    
+    public static void setThreadLocal(EjbBean<?> ejbBean)
+    {
+        threadLocal.set(ejbBean);
+    }
+    
+    public static void unsetThreadLocal()
+    {
+        threadLocal.remove();
+    }
+    
     @PostConstruct
-    public void afterConstruct(InvocationContext context)
+    @SuppressWarnings("unchecked")
+    public void afterConstruct(InvocationContext context) throws Exception
     {
+        Object instance = context.getTarget();
+        EjbBean<Object> bean = (EjbBean<Object>)threadLocal.get();
+        
+        threadLocal.get().injectFieldInInterceptor(instance, bean.getCreationalContext());
+        
         
     }
-
+    
 }

Modified: incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbDefinitionUtility.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbDefinitionUtility.java?rev=794378&r1=794377&r2=794378&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbDefinitionUtility.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbDefinitionUtility.java
Wed Jul 15 19:44:28 2009
@@ -16,19 +16,13 @@
  */
 package org.apache.webbeans.ejb.util;
 
-import java.io.Externalizable;
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
 import java.util.List;
 
-import javax.ejb.Local;
-import javax.ejb.Remote;
+import javassist.util.proxy.ProxyFactory;
 
-import org.apache.webbeans.ejb.component.EjbComponentImpl;
-import org.apache.webbeans.util.AnnotationUtil;
-import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.ejb.component.EjbBean;
+import org.apache.webbeans.ejb.proxy.EjbBeanProxyHandler;
+import org.apache.webbeans.exception.WebBeansException;
 
 /**
  * @version $Rev$ $Date$
@@ -40,91 +34,29 @@
         
     }
 
-    public static void defineApiType(EjbComponentImpl<?> ejbComponent)
-    {
-        Class<?> ejbClass = ejbComponent.getReturnType();        
-        
-        Type[] businessInterfacesDefined = ejbClass.getGenericInterfaces();
-        
-        List<Type> businessInterfacesList = new ArrayList<Type>();
-        
-        for(Type businessInterfacesDefinedInArray : businessInterfacesDefined)
-        {
-            if(!(businessInterfacesDefinedInArray.equals(Serializable.class) || businessInterfacesDefinedInArray.equals(Externalizable.class)))
-            {
-                businessInterfacesList.add(businessInterfacesDefinedInArray);   
-            }
-        }
-        
-        businessInterfacesDefined = new Type[businessInterfacesList.size()];
-        businessInterfacesDefined = businessInterfacesList.toArray(businessInterfacesDefined);
-        
-        if(businessInterfacesDefined.length == 0)
-        {            
-            Annotation localAnnotation = AnnotationUtil.getAnnotation(ejbClass.getDeclaredAnnotations(),
Local.class);
-                         
-            if(localAnnotation != null)
-            {
-                Local local = (Local)localAnnotation;
-                Class<?>[] localInterfaces = local.value();
-                
-                for(Class<?> localInterface : localInterfaces)
-                {
-                    if(!ClassUtil.isDefinitionConstainsTypeVariables(localInterface))
-                    {
-                        ClassUtil.setTypeHierarchy(ejbComponent.getTypes(), localInterface);
-                        
-                        EjbUtility.configureEjbBusinessMethods(ejbComponent, localInterface);
-                    }
-                }
-            }
-            else
-            {
-                defineLocalClassType(ejbComponent);
-            }
-            
-        }
-        else if(businessInterfacesDefined.length == 1)
-        {
-            Type businessInterface = businessInterfacesDefined[0];
-            defineLocalBusinessInterfaceType(ejbComponent, businessInterface);
-        }
-        else
-        {
-            for(Type busType : businessInterfacesDefined)
-            {
-                defineLocalBusinessInterfaceType(ejbComponent, busType);
-            }            
-        }
-        
+    public static void defineApiType(EjbBean<?> ejbComponent)
+    {        
         ejbComponent.getTypes().add(Object.class);
     }
     
-    private static void defineLocalBusinessInterfaceType(EjbComponentImpl<?> ejbComponent,
Type type)
-    {
-        Class<?> businessInterfaceClass = EjbClassUtility.getLocalInterfaceClass(type);
-        
-        if(businessInterfaceClass != null)
-        {
-            if(!AnnotationUtil.isAnnotationExistOnClass(businessInterfaceClass, Remote.class))
-            {                    
-                ClassUtil.setTypeHierarchy(ejbComponent.getTypes(), businessInterfaceClass);
-                
-                EjbUtility.configureEjbBusinessMethods(ejbComponent, businessInterfaceClass);
-            }
-        }                                
-    }
-    
-    private static void defineLocalClassType(EjbComponentImpl<?> ejbComponent)
+    @SuppressWarnings("unchecked")
+    public static <T> T defineEjbBeanProxy(EjbBean<T> bean)
     {
-        Class<?> clazz = ejbComponent.getReturnType();
-        
-        if(!ClassUtil.isDefinitionConstainsTypeVariables(clazz))
+        try
         {
-            ClassUtil.setClassTypeHierarchy(ejbComponent.getTypes(), clazz);
+            ProxyFactory factory = new ProxyFactory();
+            
+            EjbBeanProxyHandler handler = new EjbBeanProxyHandler(bean);
             
-            EjbUtility.configureEjbBusinessMethods(ejbComponent, clazz);
+            factory.setHandler(handler);
+            List<Class> interfaces = bean.getDeploymentInfo().getBusinessLocalInterfaces();
           
+            factory.setInterfaces(interfaces.toArray(new Class[0]));  
+         
+            return (T)factory.createClass().newInstance();
+            
+        }catch(Exception e)
+        {
+            throw new WebBeansException(e);
         }
-        
     }
 }

Modified: incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbUtility.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbUtility.java?rev=794378&r1=794377&r2=794378&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbUtility.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbUtility.java
Wed Jul 15 19:44:28 2009
@@ -16,60 +16,132 @@
  */
 package org.apache.webbeans.ejb.util;
 
-import java.lang.reflect.Method;
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
 
-import org.apache.webbeans.ejb.EJBUtil;
-import org.apache.webbeans.ejb.EjbType;
-import org.apache.webbeans.ejb.component.EjbComponentImpl;
-import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.ClassUtil;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Producer;
 
+import org.apache.webbeans.component.ProducerFieldBean;
+import org.apache.webbeans.component.ProducerMethodBean;
+import org.apache.webbeans.component.creation.BeanCreator.MetaDataProvider;
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.ejb.component.EjbBean;
+import org.apache.webbeans.ejb.component.creation.EjbBeanCreatorImpl;
+import org.apache.webbeans.portable.AnnotatedElementFactory;
+import org.apache.webbeans.portable.events.ProcessAnnotatedTypeImpl;
+import org.apache.webbeans.portable.events.ProcessInjectionTargetImpl;
+import org.apache.webbeans.portable.events.ProcessProducerImpl;
+import org.apache.webbeans.portable.events.ProcessSessionBeanImpl;
+import org.apache.webbeans.util.WebBeansUtil;
+
+@SuppressWarnings("unchecked")
 public final class EjbUtility
 {
     private EjbUtility()
     {
         
     }
-    
-    
-    public static EjbType getEjbTypeForAnnotatedClass(Class<?> ejbClass)
+        
+    public static <T> void fireEvents(Class<T> clazz, EjbBean<T> ejbBean)
     {
-        Asserts.assertNotNull(ejbClass, "ejbClass parameter can not be null");
+        AnnotatedType<T> annotatedType = AnnotatedElementFactory.newAnnotatedType(clazz);
+        
+        //Fires ProcessAnnotatedType
+        ProcessAnnotatedTypeImpl<T> processAnnotatedEvent = WebBeansUtil.fireProcessAnnotatedTypeEvent(annotatedType);
            
+        EjbBeanCreatorImpl<T> ejbBeanCreator = new EjbBeanCreatorImpl<T>(ejbBean);
         
-        if(EJBUtil.isEJBSessionStateless(ejbClass))
+        if(processAnnotatedEvent.isVeto())
         {
-            return EjbType.STATELESS;
+            return;
         }
-        else if(EJBUtil.isEJBSessionStatefulClass(ejbClass))
+        
+        if(processAnnotatedEvent.isSet())
         {
-            return EjbType.STATEFULL;
+            ejbBeanCreator.setMetaDataProvider(MetaDataProvider.THIRDPARTY);
         }
-        //TODO ejb 3.1 jars
-        else
+        
+        //Define meta-data
+        ejbBeanCreator.defineSerializable();
+        ejbBeanCreator.defineStereoTypes();
+        Class<? extends Annotation> deploymentType = ejbBeanCreator.defineDeploymentType("There
are more than one @DeploymentType annotation in Session Bean implementation class : " + ejbBean.getReturnType().getName());
+        ejbBeanCreator.defineApiType();
+        ejbBeanCreator.defineScopeType("Session Bean implementation class : " + clazz.getName()
+ " stereotypes must declare same @ScopeType annotations");
+        ejbBeanCreator.defineBindingType();
+        ejbBeanCreator.defineName(WebBeansUtil.getSimpleWebBeanDefaultName(clazz.getSimpleName()));
           
+        Set<ProducerMethodBean<?>> producerMethodBeans = ejbBeanCreator.defineProducerMethods();
       
+        Set<ProducerFieldBean<?>> producerFieldBeans = ejbBeanCreator.defineProducerFields();
          
+        ejbBeanCreator.defineDisposalMethods();
+        ejbBeanCreator.defineInjectedFields();
+        ejbBeanCreator.defineInjectedMethods();
+        ejbBeanCreator.defineObserverMethods();        
+        
+        //Fires ProcessInjectionTarget
+        ProcessInjectionTargetImpl<T> processInjectionTargetEvent = WebBeansUtil.fireProcessInjectionTargetEvent(ejbBean);
           
+        if(processInjectionTargetEvent.isSet())
         {
-            return EjbType.SINGLETON;
+            ejbBeanCreator.setInjectedTarget(processInjectionTargetEvent.getInjectionTarget());
         }
-    }
-    
-    public static void configureEjbBusinessMethods(EjbComponentImpl<?> ejbComponent,
Class<?> businessInterface)
-    {
-        Asserts.assertNotNull(ejbComponent,"ejbComponent parameter can not be null");
-        Asserts.assertNotNull(businessInterface, "businessInterface parameter can not be
null");
         
-        if(!businessInterface.equals(Object.class))
+        Map<ProducerMethodBean<?>,AnnotatedMethod<?>> annotatedMethods
= new HashMap<ProducerMethodBean<?>, AnnotatedMethod<?>>(); 
+        for(ProducerMethodBean<?> producerMethod : producerMethodBeans)
         {
-            Method[] methods = businessInterface.getMethods();
+            AnnotatedMethod<?> method = AnnotatedElementFactory.newAnnotatedMethod(producerMethod.getCreatorMethod(),
producerMethod.getParent().getReturnType());
+            ProcessProducerImpl<?, ?> producerEvent = WebBeansUtil.fireProcessProducerEventForMethod(producerMethod,method);
+
+            annotatedMethods.put(producerMethod, method);
             
-            for(Method method : methods)
+            if(producerEvent.isProducerSet())
             {
-                if(!ClassUtil.isObjectMethod(method.getName()))
-                {
-                    ejbComponent.addBusinessMethod(method);   
-                }
-            }                
+                producerMethod.setProducer((Producer) ejbBeanCreator.getProducer());
+            }
+            
+            producerEvent.setProducerSet(false);
+        }
+        
+        Map<ProducerFieldBean<?>,AnnotatedField<?>> annotatedFields = new
HashMap<ProducerFieldBean<?>, AnnotatedField<?>>();
+        for(ProducerFieldBean<?> producerField : producerFieldBeans)
+        {
+            AnnotatedField<?> field = AnnotatedElementFactory.newAnnotatedField(producerField.getCreatorField(),
producerField.getParent().getReturnType());
+            ProcessProducerImpl<?, ?> producerEvent = WebBeansUtil.fireProcessProducerEventForField(producerField,
field);
+            
+            annotatedFields.put(producerField, field);
+            
+            if(producerEvent.isProducerSet())
+            {
+                producerField.setProducer((Producer) ejbBeanCreator.getProducer());
+            }
+            
+            producerEvent.setProducerSet(false);
         }
 
+        //Fires ProcessManagedBean
+        ProcessSessionBeanImpl<T> processBeanEvent = new ProcessSessionBeanImpl<T>((Bean<Object>)ejbBean,annotatedType,ejbBean.getEjbName(),ejbBean.getEjbType());
           
+        BeanManagerImpl.getManager().fireEvent(processBeanEvent, new Annotation[0]);
+        
+        //Fires ProcessProducerMethod
+        WebBeansUtil.fireProcessProducerMethodBeanEvent(annotatedMethods);
+        
+        //Fires ProcessProducerField
+        WebBeansUtil.fireProcessProducerFieldBeanEvent(annotatedFields);
+                
+        //Set InjectionTarget that is used by the container to inject dependencies!
+        if(ejbBeanCreator.isInjectionTargetSet())
+        {
+            ejbBean.setInjectionTarget(ejbBeanCreator.getInjectedTarget());   
+        }
+        
+        // Check if the deployment type is enabled.
+        if (WebBeansUtil.isDeploymentTypeEnabled(deploymentType))
+        {                                
+            BeanManagerImpl.getManager().addBean(ejbBean);
+            BeanManagerImpl.getManager().getBeans().addAll(producerMethodBeans);
+            BeanManagerImpl.getManager().getBeans().addAll(producerFieldBeans);
+        }        
     }
-    
-
-}
+}
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbValidator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbValidator.java?rev=794378&r1=794377&r2=794378&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbValidator.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/util/EjbValidator.java
Wed Jul 15 19:44:28 2009
@@ -20,11 +20,11 @@
 import javax.decorator.Decorator;
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.spi.SessionBeanType;
 import javax.interceptor.Interceptor;
 
 import org.apache.webbeans.ejb.EjbConstants;
-import org.apache.webbeans.ejb.EjbType;
-import org.apache.webbeans.ejb.component.EjbComponentImpl;
+import org.apache.webbeans.ejb.component.EjbBean;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
@@ -37,7 +37,7 @@
     }
     
     
-    public static void validateEjbScopeType(EjbComponentImpl<?> ejbComponent)
+    public static void validateEjbScopeType(EjbBean<?> ejbComponent)
     {
         Asserts.assertNotNull(ejbComponent, "scopeType parameter can not be null");
 
@@ -51,7 +51,7 @@
             throw new NullPointerException("EjbComponent ejb type can not be null");
         }
         
-        if(ejbComponent.getEjbType().equals(EjbType.STATELESS))
+        if(ejbComponent.getEjbType().equals(SessionBeanType.STATELESS))
         {
             if(!ejbComponent.getScopeType().equals(Dependent.class))
             {
@@ -59,7 +59,7 @@
                 		"can not define scope other than @Dependent");
             }
         }
-        else if(ejbComponent.getEjbType().equals(EjbType.SINGLETON))
+        else if(ejbComponent.getEjbType().equals(SessionBeanType.SINGLETON))
         {
             if(!(ejbComponent.getScopeType().equals(Dependent.class) || ejbComponent.getScopeType().equals(ApplicationScoped.class)
))
             {

Modified: incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/EjbTestContext.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/EjbTestContext.java?rev=794378&r1=794377&r2=794378&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/EjbTestContext.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/EjbTestContext.java
Wed Jul 15 19:44:28 2009
@@ -16,8 +16,7 @@
  */
 package org.apache.webbeans.ejb;
 
-import org.apache.webbeans.ejb.component.EjbComponentImpl;
-import org.apache.webbeans.ejb.definition.EjbDefinition;
+import org.apache.webbeans.ejb.component.EjbBean;
 import org.apache.webbeans.test.servlet.TestContext;
 
 public abstract class EjbTestContext extends TestContext
@@ -27,8 +26,8 @@
         super(name);
     }
 
-    protected <T> EjbComponentImpl<T> defineEjbBean(Class<T> ejbClass)
+    protected <T> EjbBean<T> defineEjbBean(Class<T> ejbClass)
     {
-        return EjbDefinition.defineEjbBean(ejbClass);
+        return null;
     }
 }

Modified: incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/apitype/EjbApiTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/apitype/EjbApiTypeTest.java?rev=794378&r1=794377&r2=794378&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/apitype/EjbApiTypeTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/apitype/EjbApiTypeTest.java
Wed Jul 15 19:44:28 2009
@@ -20,7 +20,7 @@
 import java.util.Set;
 
 import org.apache.webbeans.ejb.EjbTestContext;
-import org.apache.webbeans.ejb.component.EjbComponentImpl;
+import org.apache.webbeans.ejb.component.EjbBean;
 import org.apache.webbeans.ejb.util.EjbDefinitionUtility;
 import org.junit.Assert;
 import org.junit.Before;
@@ -42,7 +42,7 @@
     @Test
     public void testBalkiApiType()
     {
-        EjbComponentImpl<Balki> bean = defineEjbBean(Balki.class);
+        EjbBean<Balki> bean = defineEjbBean(Balki.class);
         EjbDefinitionUtility.defineApiType(bean);
         
         Set<Type> types = bean.getTypes();
@@ -53,7 +53,7 @@
     @Test
     public void testDefaultLocalBalkiApiType()
     {
-        EjbComponentImpl<Balki_DefaultLocal> bean = defineEjbBean(Balki_DefaultLocal.class);
+        EjbBean<Balki_DefaultLocal> bean = defineEjbBean(Balki_DefaultLocal.class);
         EjbDefinitionUtility.defineApiType(bean);
         
         Set<Type> types = bean.getTypes();
@@ -64,7 +64,7 @@
     @Test
     public void testClassLocalBalkiApiType()
     {
-        EjbComponentImpl<Balki_ClassLocal> bean = defineEjbBean(Balki_ClassLocal.class);
+        EjbBean<Balki_ClassLocal> bean = defineEjbBean(Balki_ClassLocal.class);
         EjbDefinitionUtility.defineApiType(bean);
         
         Set<Type> types = bean.getTypes();
@@ -75,7 +75,7 @@
     @Test
     public void testClassLocalViewBalkiApiType()
     {
-        EjbComponentImpl<Balki_ClassView> bean = defineEjbBean(Balki_ClassView.class);
+        EjbBean<Balki_ClassView> bean = defineEjbBean(Balki_ClassView.class);
         EjbDefinitionUtility.defineApiType(bean);
         
         Set<Type> types = bean.getTypes();

Modified: incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/validator/EjbValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/validator/EjbValidatorTest.java?rev=794378&r1=794377&r2=794378&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/validator/EjbValidatorTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-ejb/src/test/java/org/apache/webbeans/ejb/definition/validator/EjbValidatorTest.java
Wed Jul 15 19:44:28 2009
@@ -17,7 +17,7 @@
 package org.apache.webbeans.ejb.definition.validator;
 
 import org.apache.webbeans.ejb.EjbTestContext;
-import org.apache.webbeans.ejb.definition.EjbDefinition;
+import org.apache.webbeans.ejb.util.EjbValidator;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.junit.Assert;
 import org.junit.Before;
@@ -43,7 +43,7 @@
         
         try
         {
-            EjbDefinition.defineEjbBean(Babos_Broken_Decorator.class);
+            EjbValidator.validateDecoratorOrInterceptor(Babos_Broken_Decorator.class);
             
         }
         catch(WebBeansConfigurationException e)
@@ -61,7 +61,7 @@
         
         try
         {
-            EjbDefinition.defineEjbBean(Babos_Broken_Interceptor.class);
+            EjbValidator.validateDecoratorOrInterceptor(Babos_Broken_Interceptor.class);
             
         }
         catch(WebBeansConfigurationException e)



Mime
View raw message