Return-Path: Delivered-To: apmail-incubator-openwebbeans-commits-archive@minotaur.apache.org Received: (qmail 88444 invoked from network); 15 Jul 2009 19:44:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Jul 2009 19:44:43 -0000 Received: (qmail 82978 invoked by uid 500); 15 Jul 2009 19:44:52 -0000 Delivered-To: apmail-incubator-openwebbeans-commits-archive@incubator.apache.org Received: (qmail 82964 invoked by uid 500); 15 Jul 2009 19:44:52 -0000 Mailing-List: contact openwebbeans-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: openwebbeans-dev@incubator.apache.org Delivered-To: mailing list openwebbeans-commits@incubator.apache.org Received: (qmail 82954 invoked by uid 99); 15 Jul 2009 19:44:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jul 2009 19:44:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jul 2009 19:44:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A89A223889E4; Wed, 15 Jul 2009 19:44:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: openwebbeans-commits@incubator.apache.org From: gerdogdu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090715194429.A89A223889E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ jar OpenWebBeans EJB Integration + org.apache.openwebbeans openwebbeans-impl - 1.0.0-incubating-SNAPSHOT + + + org.apache.openejb + openejb-core + true + + junit junit 4.5 test - - org.apache.openwebbeans - openwebbeans-impl - 1.0.0-incubating-SNAPSHOT - tests - test - + 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 extends AbstractInjectionTargetBean +public class EjbBean extends AbstractInjectionTargetBean implements EnterpriseBeanMarker { - private EjbType ejbType; + private SessionBeanType ejbType; - private Set businessMethods = new HashSet(); + private DeploymentInfo deploymentInfo; - public EjbComponentImpl(Class ejbClassType) + private T instance = null; + + public EjbBean(Class 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 creationalContext) + { + //No-operations + } + + @SuppressWarnings("unchecked") + public void injectFieldInInterceptor(Object instance, CreationalContext creationalContext) + { + super.injectFields((T)instance, (CreationalContext)creationalContext); + } + + @Override + @SuppressWarnings("unchecked") protected T createComponentInstance(CreationalContext creationalContext) { - return null; + if(this.instance == null) + { + ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); + Context jndiContext = containerSystem.getJNDIContext(); + DeploymentInfo deploymentInfo = this.getDeploymentInfo(); + try + { + Class 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 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 extends InjectedTargetBeanCreator +{ + +} 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 extends AbstractInjectedTargetBeanCreator implements EjbBeanCreator +{ + public EjbBeanCreatorImpl(EjbBean 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> threadLocal = new ThreadLocal>(); + + 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 bean = (EjbBean)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 businessInterfacesList = new ArrayList(); - - 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 defineEjbBeanProxy(EjbBean 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 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 void fireEvents(Class clazz, EjbBean ejbBean) { - Asserts.assertNotNull(ejbClass, "ejbClass parameter can not be null"); + AnnotatedType annotatedType = AnnotatedElementFactory.newAnnotatedType(clazz); + + //Fires ProcessAnnotatedType + ProcessAnnotatedTypeImpl processAnnotatedEvent = WebBeansUtil.fireProcessAnnotatedTypeEvent(annotatedType); + EjbBeanCreatorImpl ejbBeanCreator = new EjbBeanCreatorImpl(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 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> producerMethodBeans = ejbBeanCreator.defineProducerMethods(); + Set> producerFieldBeans = ejbBeanCreator.defineProducerFields(); + ejbBeanCreator.defineDisposalMethods(); + ejbBeanCreator.defineInjectedFields(); + ejbBeanCreator.defineInjectedMethods(); + ejbBeanCreator.defineObserverMethods(); + + //Fires ProcessInjectionTarget + ProcessInjectionTargetImpl 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,AnnotatedMethod> annotatedMethods = new HashMap, 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,AnnotatedField> annotatedFields = new HashMap, 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 processBeanEvent = new ProcessSessionBeanImpl((Bean)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 EjbComponentImpl defineEjbBean(Class ejbClass) + protected EjbBean defineEjbBean(Class 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 bean = defineEjbBean(Balki.class); + EjbBean bean = defineEjbBean(Balki.class); EjbDefinitionUtility.defineApiType(bean); Set types = bean.getTypes(); @@ -53,7 +53,7 @@ @Test public void testDefaultLocalBalkiApiType() { - EjbComponentImpl bean = defineEjbBean(Balki_DefaultLocal.class); + EjbBean bean = defineEjbBean(Balki_DefaultLocal.class); EjbDefinitionUtility.defineApiType(bean); Set types = bean.getTypes(); @@ -64,7 +64,7 @@ @Test public void testClassLocalBalkiApiType() { - EjbComponentImpl bean = defineEjbBean(Balki_ClassLocal.class); + EjbBean bean = defineEjbBean(Balki_ClassLocal.class); EjbDefinitionUtility.defineApiType(bean); Set types = bean.getTypes(); @@ -75,7 +75,7 @@ @Test public void testClassLocalViewBalkiApiType() { - EjbComponentImpl bean = defineEjbBean(Balki_ClassView.class); + EjbBean bean = defineEjbBean(Balki_ClassView.class); EjbDefinitionUtility.defineApiType(bean); Set 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)