[jboss-cvs] JBossAS SVN: r102893 - in tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss: ejb3/metamodel and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 24 12:07:29 EDT 2010
Author: mbenitez
Date: 2010-03-24 12:07:27 -0400 (Wed, 24 Mar 2010)
New Revision: 102893
Added:
tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java
tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java
tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java
tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java
Log:
Copy 43 specific resources to ejb3/src/main
Added: tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java (rev 0)
+++ tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2010-03-24 16:07:27 UTC (rev 102893)
@@ -0,0 +1,2026 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javassist.bytecode.ClassFile;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.DenyAll;
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Init;
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.MessageDriven;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Remove;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+
+import org.jboss.annotation.IgnoreDependency;
+import org.jboss.annotation.IgnoreDependencyImpl;
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.ClusteredImpl;
+import org.jboss.annotation.ejb.Consumer;
+import org.jboss.annotation.ejb.ConsumerImpl;
+import org.jboss.annotation.ejb.CurrentMessage;
+import org.jboss.annotation.ejb.CurrentMessageImpl;
+import org.jboss.annotation.ejb.DefaultActivationSpecs;
+import org.jboss.annotation.ejb.DefaultActivationSpecsImpl;
+import org.jboss.annotation.ejb.DeliveryMode;
+import org.jboss.annotation.ejb.Depends;
+import org.jboss.annotation.ejb.DependsImpl;
+import org.jboss.annotation.ejb.ExcludeClassInterceptorsImpl;
+import org.jboss.annotation.ejb.ExcludeDefaultInterceptorsImpl;
+import org.jboss.annotation.ejb.LocalBinding;
+import org.jboss.annotation.ejb.LocalBindingImpl;
+import org.jboss.annotation.ejb.LocalHomeBinding;
+import org.jboss.annotation.ejb.LocalHomeBindingImpl;
+import org.jboss.annotation.ejb.LocalHomeImpl;
+import org.jboss.annotation.ejb.Management;
+import org.jboss.annotation.ejb.ManagementImpl;
+import org.jboss.annotation.ejb.MessageProperties;
+import org.jboss.annotation.ejb.MessagePropertiesImpl;
+import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.PoolClassImpl;
+import org.jboss.annotation.ejb.Producers;
+import org.jboss.annotation.ejb.RemoteBinding;
+import org.jboss.annotation.ejb.RemoteBindingImpl;
+import org.jboss.annotation.ejb.RemoteBindings;
+import org.jboss.annotation.ejb.RemoteBindingsImpl;
+import org.jboss.annotation.ejb.RemoteHomeBinding;
+import org.jboss.annotation.ejb.RemoteHomeBindingImpl;
+import org.jboss.annotation.ejb.RemoteHomeImpl;
+import org.jboss.annotation.ejb.ResourceAdapter;
+import org.jboss.annotation.ejb.ResourceAdapterImpl;
+import org.jboss.annotation.ejb.SerializedConcurrentAccess;
+import org.jboss.annotation.ejb.SerializedConcurrentAccessImpl;
+import org.jboss.annotation.ejb.Service;
+import org.jboss.annotation.ejb.ServiceImpl;
+import org.jboss.annotation.ejb.TransactionTimeout;
+import org.jboss.annotation.ejb.TransactionTimeoutImpl;
+import org.jboss.annotation.ejb.cache.Cache;
+import org.jboss.annotation.ejb.cache.CacheImpl;
+import org.jboss.annotation.ejb.cache.simple.PersistenceManager;
+import org.jboss.annotation.ejb.cache.simple.PersistenceManagerImpl;
+import org.jboss.annotation.internal.DefaultInterceptorMarker;
+import org.jboss.annotation.internal.DefaultInterceptorMarkerImpl;
+import org.jboss.annotation.security.RunAsPrincipalImpl;
+import org.jboss.annotation.security.SecurityDomain;
+import org.jboss.annotation.security.SecurityDomainImpl;
+import org.jboss.aop.annotation.AnnotationRepository;
+import org.jboss.ejb.ActivationConfigPropertyImpl;
+import org.jboss.ejb.AroundInvokeImpl;
+import org.jboss.ejb.DeclareRolesImpl;
+import org.jboss.ejb.DenyAllImpl;
+import org.jboss.ejb.InitImpl;
+import org.jboss.ejb.InterceptorsImpl;
+import org.jboss.ejb.LocalImpl;
+import org.jboss.ejb.MessageDrivenImpl;
+import org.jboss.ejb.PermitAllImpl;
+import org.jboss.ejb.PostActivateImpl;
+import org.jboss.ejb.PostConstructImpl;
+import org.jboss.ejb.PreDestroyImpl;
+import org.jboss.ejb.PrePassivateImpl;
+import org.jboss.ejb.RemoteImpl;
+import org.jboss.ejb.RemoveImpl;
+import org.jboss.ejb.ResourceImpl;
+import org.jboss.ejb.RolesAllowedImpl;
+import org.jboss.ejb.RunAsImpl;
+import org.jboss.ejb.StatelessImpl;
+import org.jboss.ejb.TransactionAttributeImpl;
+import org.jboss.ejb.TransactionManagementImpl;
+import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.ejb3.mdb.ConsumerContainer;
+import org.jboss.ejb3.mdb.MDB;
+import org.jboss.ejb3.mdb.ProducerImpl;
+import org.jboss.ejb3.mdb.ProducersImpl;
+import org.jboss.ejb3.metamodel.*;
+import org.jboss.ejb3.service.ServiceContainer;
+import org.jboss.ejb3.stateful.StatefulContainer;
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.InjectionTarget;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.NameValuePair;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.metamodel.descriptor.RunAs;
+import org.jboss.metamodel.descriptor.SecurityRole;
+import org.jboss.wsf.spi.annotation.WebContextImpl;
+import org.jboss.wsf.spi.annotation.WebContext;
+
+/**
+ * @version <tt>$Revision: 77116 $</tt>
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @author <a href="mailto:bill at jboss.com">Bill Burke</a>
+ */
+public class Ejb3DescriptorHandler extends Ejb3AnnotationHandler
+{
+ private static final Logger log = Logger
+ .getLogger(Ejb3DescriptorHandler.class);
+
+ protected EjbJarDD dd;
+
+ protected List<EnterpriseBean> ejbs = new ArrayList<EnterpriseBean>();
+
+ public Ejb3DescriptorHandler(Ejb3Deployment deployment, ClassFile cf,
+ EjbJarDD dd)
+ {
+ super(deployment, cf);
+ this.dd = dd;
+ }
+
+ public Ejb3DescriptorHandler(Ejb3Deployment deployment, EjbJarDD dd)
+ {
+ super(deployment);
+ this.dd = dd;
+ }
+
+ public boolean isEjb()
+ {
+ if (super.isEjb())
+ return true;
+ EnterpriseBeans enterpriseBeans = dd.getEnterpriseBeans();
+
+ if (enterpriseBeans == null)
+ {
+ return false;
+ }
+ return enterpriseBeans.findEjbsByClass(cf.getName()).size() > 0;
+
+ }
+
+ protected void populateBaseInfo() throws Exception
+ {
+ if (cf != null)
+ super.populateBaseInfo();
+
+ EnterpriseBeans enterpriseBeans = (dd.getEnterpriseBeans() != null) ? dd
+ .getEnterpriseBeans() : new EnterpriseBeans();
+
+ List<EnterpriseBean> ejbsByClass;
+ if (cf == null)
+ ejbsByClass = enterpriseBeans.findEjbs();
+ else
+ ejbsByClass = enterpriseBeans.findEjbsByClass(cf.getName());
+
+ for (int i = 0; i < ejbNames.size(); ++i)
+ {
+ String ejbNameFromAnnotation = ejbNames.get(i);
+ EnterpriseBean enterpriseBean = enterpriseBeans
+ .findEjbByEjbName(ejbNameFromAnnotation);
+ ejbs.add(enterpriseBean);
+
+ int j = 0;
+ while (j < ejbsByClass.size())
+ {
+ EnterpriseBean ejbByClass = ejbsByClass.get(j);
+ if (ejbByClass.getEjbName().equals(ejbNameFromAnnotation))
+ ejbsByClass.remove(j);
+ else
+ ++j;
+ }
+ }
+
+ for (EnterpriseBean enterpriseBean : ejbsByClass)
+ {
+ String ejbName = enterpriseBean.getEjbName();
+
+ ejbs.add(enterpriseBean);
+ ejbNames.add(ejbName);
+
+ ejbType = getEjbType(enterpriseBean);
+ }
+ }
+
+ protected EJB_TYPE getEjbType(EnterpriseBean enterpriseBean)
+ {
+ if (enterpriseBean.isSessionBean())
+ {
+ if (((SessionEnterpriseBean) enterpriseBean).isStateless())
+ return EJB_TYPE.STATELESS;
+ else
+ return EJB_TYPE.STATEFUL;
+ } else if (enterpriseBean.isEntityBean())
+ return EJB_TYPE.ENTITY;
+ else if (enterpriseBean.isMessageDrivenBean())
+ return EJB_TYPE.MESSAGE_DRIVEN;
+ else if (enterpriseBean.isService())
+ return EJB_TYPE.SERVICE;
+ else //if (enterpriseBean.isConsumer())
+ return EJB_TYPE.CONSUMER;
+ }
+
+ public List getContainers(Ejb3Deployment deployment, Map<String, Container> preexistingContainers) throws Exception
+ {
+ List containers = new ArrayList();
+
+ EnterpriseBeans enterpriseBeans = (dd.getEnterpriseBeans() != null) ? dd
+ .getEnterpriseBeans() : new EnterpriseBeans();
+
+ Collection<EnterpriseBean> allXmlEjbs = enterpriseBeans.getEnterpriseBeans();
+ ejbNames = new ArrayList<String>();
+ for (EnterpriseBean ejb : allXmlEjbs)
+ {
+ String ejbName = ejb.getEjbName();
+ if (preexistingContainers.get(ejbName) == null)
+ {
+ ejbNames.add(ejbName);
+ ejbs.add(ejb);
+ }
+ }
+
+ for (int ejbIndex = 0; ejbIndex < ejbNames.size(); ++ejbIndex)
+ {
+ String ejbName = ejbNames.get(ejbIndex);
+ EnterpriseBean enterpriseBean = ejbs.get(ejbIndex);
+ ejbType = getEjbType(enterpriseBean);
+ className = enterpriseBean.getEjbClass();
+
+ if (className == null)
+ log.warn("Descriptor based bean has no ejb-class defined: " + ejbName);
+ else
+ {
+ ejbClass = di.getClassLoader().loadClass(className);
+ if (ejbType == EJB_TYPE.STATELESS)
+ {
+ EJBContainer container = getStatelessContainer(ejbIndex);
+ container.setJaccContextId(getJaccContextId());
+ containers.add(container);
+ }
+ else if (ejbType == EJB_TYPE.STATEFUL)
+ {
+ StatefulContainer container = getStatefulContainer(ejbIndex);
+ container.setJaccContextId(getJaccContextId());
+ containers.add(container);
+ }
+ else if (ejbType == EJB_TYPE.MESSAGE_DRIVEN)
+ {
+ MDB container = getMDB(ejbIndex);
+ container.setJaccContextId(getJaccContextId());
+ containers.add(container);
+ }
+ else if (ejbType == EJB_TYPE.SERVICE)
+ {
+ ServiceContainer container = getServiceContainer(ejbIndex);
+ container.setJaccContextId(getJaccContextId());
+ containers.add(container);
+ }
+ else if (ejbType == EJB_TYPE.CONSUMER)
+ {
+ ConsumerContainer container = getConsumerContainer(ejbIndex);
+ container.setJaccContextId(getJaccContextId());
+ containers.add(container);
+ }
+ log.debug("found EJB3: ejbName=" + ejbName + ", class=" + className + ", type=" + ejbType);
+ }
+ }
+
+ return containers;
+ }
+
+ protected StatefulContainer getStatefulContainer(int ejbIndex)
+ throws Exception
+ {
+ String ejbName = ejbNames.get(ejbIndex);
+
+ EnterpriseBean enterpriseBean = ejbs.get(ejbIndex);
+
+ StatefulContainer container = super.getStatefulContainer(ejbIndex);
+
+ container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
+
+ addInterfaces(container, enterpriseBean);
+
+ addDescriptorAnnotations(container, enterpriseBean, ejbName, true);
+
+ return container;
+ }
+
+ private void addHomeAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean) throws Exception
+ {
+ if (enterpriseBean.getHome() != null)
+ {
+ RemoteHome annotation = new RemoteHomeImpl(di.getClassLoader()
+ .loadClass(enterpriseBean.getHome()));
+ addClassAnnotation(container, annotation.annotationType(), annotation);
+ }
+
+ if (enterpriseBean.getLocalHome() != null)
+ {
+ LocalHome annotation = new LocalHomeImpl(di.getClassLoader()
+ .loadClass(enterpriseBean.getLocalHome()));
+ addClassAnnotation(container, annotation.annotationType(), annotation);
+ }
+ }
+
+ protected EJBContainer getStatelessContainer(int ejbIndex)
+ throws Exception
+ {
+ String ejbName = ejbNames.get(ejbIndex);
+
+ EnterpriseBean enterpriseBean = ejbs.get(ejbIndex);
+
+ EJBContainer container = super.getStatelessContainer(ejbIndex);
+
+ container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
+
+ StatelessImpl annotation = new StatelessImpl(ejbName);
+ if (enterpriseBean != null && !isAnnotatedBean())
+ {
+ addClassAnnotation(container, Stateless.class, annotation);
+ }
+
+ addInterfaces(container, enterpriseBean);
+
+ addDescriptorAnnotations(container, enterpriseBean, ejbName);
+
+ return container;
+ }
+
+ protected ServiceContainer getServiceContainer(int ejbIndex)
+ throws Exception
+ {
+ String ejbName = ejbNames.get(ejbIndex);
+
+ org.jboss.ejb3.metamodel.Service service = (org.jboss.ejb3.metamodel.Service) ejbs
+ .get(ejbIndex);
+
+ ServiceContainer container = super.getServiceContainer(ejbIndex);
+ ServiceImpl annotation = new ServiceImpl((Service) container
+ .resolveAnnotation(Service.class));
+
+ container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
+
+ if (service != null && !isAnnotatedBean())
+ {
+ if (service.getObjectName() != null)
+ annotation.setObjectName(service.getObjectName());
+ if (service.getEjbName() != null)
+ annotation.setName(service.getEjbName());
+ if (service.getXMBean() != null)
+ annotation.setXMBean(service.getXMBean());
+ addClassAnnotation(container, Service.class, annotation);
+ }
+
+ addInterfaces(container, service);
+
+ addDescriptorAnnotations(container, service, ejbName);
+
+ addServiceAnnotations(container, service);
+
+ return container;
+ }
+
+ protected ConsumerContainer getConsumerContainer(int ejbIndex)
+ throws Exception
+ {
+ String ejbName = ejbNames.get(ejbIndex);
+
+ org.jboss.ejb3.metamodel.Consumer consumer = (org.jboss.ejb3.metamodel.Consumer) ejbs
+ .get(ejbIndex);
+
+ ConsumerContainer container = super.getConsumerContainer(ejbIndex);
+ ConsumerImpl annotation = new ConsumerImpl((Consumer) container
+ .resolveAnnotation(Consumer.class));
+
+ container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
+
+ if (consumer != null && !isAnnotatedBean())
+ {
+ if (consumer.getDestination() != null)
+ {
+ ActivationConfigPropertyImpl property = new ActivationConfigPropertyImpl(
+ "destination", consumer.getDestination());
+ annotation.addActivationConfig(property);
+ }
+
+ if (consumer.getDestinationType() != null)
+ {
+ ActivationConfigPropertyImpl property = new ActivationConfigPropertyImpl(
+ "destinationType", consumer.getDestinationType());
+ annotation.addActivationConfig(property);
+ }
+
+ addClassAnnotation(container, Consumer.class, annotation);
+ }
+
+ addInterfaces(container, consumer);
+
+ addDescriptorAnnotations(container, consumer, ejbName);
+
+ addConsumerAnnotations(container, consumer);
+
+ return container;
+ }
+
+ protected String getMDBDomainName(int ejbIndex)
+ {
+ return defaultMDBDomain;
+ }
+
+ protected MDB getMDB(int ejbIndex) throws Exception
+ {
+ String ejbName = ejbNames.get(ejbIndex);
+
+ EnterpriseBean enterpriseBean = ejbs.get(ejbIndex);
+
+ MDB container = super.getMDB(ejbIndex);
+
+ container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
+
+ addMDBAnnotations(container, ejbName, enterpriseBean);
+
+ addInterfaces(container, enterpriseBean);
+
+ addDescriptorAnnotations(container, enterpriseBean, ejbName);
+
+ return container;
+ }
+
+ protected String getAspectDomain(int ejbIndex, String defaultDomain)
+ {
+ EnterpriseBean enterpriseBean = ejbs.get(ejbIndex);
+ if (enterpriseBean != null)
+ {
+ String aopDomainName = enterpriseBean.getAopDomainName();
+ if (aopDomainName != null)
+ {
+ log.debug("Found aop-domain-name element for annotation "
+ + aopDomainName + " for ejbName "
+ + enterpriseBean.getEjbName());
+
+ return aopDomainName;
+ }
+ }
+ return super.getAspectDomain(ejbIndex, defaultDomain);
+ }
+
+ protected boolean isAnnotatedBean()
+ {
+ return super.isEjb() || super.isJBossBeanType();
+ }
+
+ private boolean isStateful(EnterpriseBean enterpriseBean)
+ {
+ return ejbType == EJB_TYPE.STATEFUL;
+ }
+
+ private void addMDBAnnotations(MDB container, String ejbName,
+ EnterpriseBean enterpriseBean)
+ {
+ if (enterpriseBean != null)
+ {
+ MessageDrivenBean mdb = (MessageDrivenBean) enterpriseBean;
+
+ ArrayList properties = new ArrayList();
+ if (mdb.getAcknowledgeMode() != null)
+ properties.add(new ActivationConfigPropertyImpl("acknowledgeMode",
+ mdb.getAcknowledgeMode()));
+
+ if (mdb.getMessageDrivenDestination() != null)
+ {
+ MessageDrivenDestination destination = mdb
+ .getMessageDrivenDestination();
+ if (destination.getDestinationType() != null)
+ properties.add(new ActivationConfigPropertyImpl(
+ "destinationType", destination.getDestinationType()));
+ if (destination.getSubscriptionDurability() != null)
+ {
+ String durable = "false";
+ if (destination.getSubscriptionDurability().equals("Durable"))
+ durable = "true";
+ properties.add(new ActivationConfigPropertyImpl("subscriptionDurability",
+ durable));
+ if (destination.getSubscriptionDurability().equals("Durable"))
+ properties.add(new ActivationConfigPropertyImpl(
+ "subscriptionName", "subscriptionName"));
+
+ }
+ }
+
+ if (mdb.getResourceAdaptorName() != null)
+ {
+ ResourceAdapter adapter = new ResourceAdapterImpl(mdb
+ .getResourceAdaptorName());
+ addClassAnnotation(container, ResourceAdapter.class, adapter);
+ }
+
+ ActivationConfig activationConfig = mdb.getActivationConfig();
+ if (activationConfig != null)
+ {
+ for (Object o : activationConfig.getActivationConfigProperties())
+ {
+ NameValuePair property = (NameValuePair) o;
+ properties.add(new ActivationConfigPropertyImpl(property
+ .getName(), property.getValue()));
+ }
+ }
+
+ if (mdb.getDestinationJndiName() != null)
+ {
+ properties.add(new ActivationConfigPropertyImpl("destination", mdb
+ .getDestinationJndiName()));
+ }
+
+ if (mdb.getMdbUser() != null)
+ {
+ properties.add(new ActivationConfigPropertyImpl("user", mdb
+ .getMdbUser()));
+ }
+
+ if (mdb.getMdbPassword() != null)
+ {
+ properties.add(new ActivationConfigPropertyImpl("password", mdb
+ .getMdbPassword()));
+
+ }
+
+ if (mdb.getMdbSubscriptionId() != null)
+ {
+ properties.add(new ActivationConfigPropertyImpl("subscriptionName", mdb
+ .getMdbSubscriptionId()));
+
+ }
+
+ ActivationConfigPropertyImpl[] propsArray = new ActivationConfigPropertyImpl[properties
+ .size()];
+ properties.toArray(propsArray);
+ MessageDrivenImpl annotation = new MessageDrivenImpl(ejbName,
+ propsArray);
+ if (mdb.getMessagingType() != null)
+ {
+ try
+ {
+ annotation.setMessageListenerInterface(container
+ .getClassloader().loadClass(mdb.getMessagingType()));
+ } catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ if (isAnnotatedBean())
+ {
+ annotation.merge((MessageDriven) ejbClass
+ .getAnnotation(MessageDriven.class));
+ }
+
+ addClassAnnotation(container, MessageDriven.class, annotation);
+
+ addDefaultActivationConfig(container, mdb);
+ }
+ }
+
+ private void addDefaultActivationConfig(MDB container, MessageDrivenBean mdb)
+ {
+ ActivationConfig defaultActivationConfig = mdb.getDefaultActivationConfig();
+ if (defaultActivationConfig != null)
+ {
+ DefaultActivationSpecsImpl activationAnnotation = new DefaultActivationSpecsImpl();
+ for (Object o : defaultActivationConfig.getActivationConfigProperties())
+ {
+ NameValuePair property = (NameValuePair) o;
+ activationAnnotation.addActivationConfigProperty(new ActivationConfigPropertyImpl(property
+ .getName(), property.getValue()));
+ }
+
+ DefaultActivationSpecs existingAnnotation = (DefaultActivationSpecs)ejbClass.getAnnotation(DefaultActivationSpecs.class);
+ if (existingAnnotation != null)
+ activationAnnotation.merge(existingAnnotation);
+
+ addClassAnnotation(container, DefaultActivationSpecs.class, activationAnnotation);
+ }
+ }
+
+ private void addInterfaces(EJBContainer container,
+ EnterpriseBean enterpriseBean) throws ClassNotFoundException
+ {
+ if (enterpriseBean != null)
+ {
+ String local = enterpriseBean.getLocal();
+ String remote = enterpriseBean.getRemote();
+
+ if (remote != null)
+ {
+ StringTokenizer classes = new StringTokenizer(remote, ",");
+ ArrayList<Class> remoteClasses = new ArrayList<Class>();
+ while (classes.hasMoreTokens())
+ {
+ String token = classes.nextToken();
+ String classname = token.trim();
+ remoteClasses.add(di.getClassLoader().loadClass(classname));
+
+ }
+ Class[] intfs = new Class[remoteClasses.size()];
+ intfs = remoteClasses.toArray(intfs);
+ addClassAnnotation(container, Remote.class, new RemoteImpl(intfs));
+ }
+
+ if (local != null)
+ {
+ StringTokenizer classes = new StringTokenizer(local, ",");
+ ArrayList<Class> localClasses = new ArrayList<Class>();
+ while (classes.hasMoreTokens())
+ {
+ String token = classes.nextToken();
+ String classname = token.trim();
+ localClasses.add(di.getClassLoader().loadClass(classname));
+
+ }
+ Class[] intfs = new Class[localClasses.size()];
+ intfs = localClasses.toArray(intfs);
+ addClassAnnotation(container, Local.class, new LocalImpl(intfs));
+ }
+ }
+ }
+
+ /**
+ * Add descriptor annotations on non stateful session beans.
+ *
+ * @param container
+ * @param enterpriseBean
+ * @param ejbName
+ * @throws Exception
+ */
+ private void addDescriptorAnnotations(EJBContainer container, EnterpriseBean enterpriseBean, String ejbName) throws Exception
+ {
+ addDescriptorAnnotations(container, enterpriseBean, ejbName, false);
+ }
+
+ private void addDescriptorAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean, String ejbName, boolean isStateful) throws Exception
+ {
+ container.setXml(enterpriseBean);
+
+ addTransactionAnnotations(container, enterpriseBean, ejbName);
+
+ addAssemblyAnnotations(container, enterpriseBean, ejbName);
+
+ addSecurityAnnotations(container, enterpriseBean, ejbName);
+
+ addEjbAnnotations(container, enterpriseBean);
+
+ addEjb21Annotations(container, isStateful);
+
+ addWebServiceAnnotations(container, enterpriseBean, ejbName);
+ }
+
+ private void addWebServiceAnnotations(EJBContainer container, EnterpriseBean enterpriseBean, String ejbName)
+ {
+ if(dd.getWebservices()!=null)
+ {
+ Webservices webservices = dd.getWebservices();
+ if(webservices.getContextRoot()!=null)
+ {
+ WebContextImpl webContextImpl = new WebContextImpl();
+ webContextImpl.setContextRoot(webservices.getContextRoot());
+
+ addClassAnnotation(container, WebContext.class, webContextImpl);
+ }
+ }
+ }
+
+ /**
+ * EJB3 4.3.5
+ * On a 2.1 session bean the ejbRemove is treated as PreDestroy, ejbActivate as PostActivate,
+ * and ejbPassivate as PrePassivate. If it is a stateless session bean the ejbCreate is treated
+ * as PostConstruct, if it is stateful the ejbCreate is treated as Init.
+ *
+ * @param container
+ * @param enterpriseBean
+ * @throws Exception
+ */
+ private void addEjb21Annotations(EJBContainer container, boolean isStateful) throws Exception
+ {
+ Class[] interfaces = ejbClass.getInterfaces();
+ for (Class beanInterface : interfaces)
+ {
+ if (beanInterface.equals(javax.ejb.SessionBean.class))
+ {
+ Method method = new Method();
+ method.setEjbName(container.getEjbName());
+
+ Annotation annotation;
+ Class<? extends Annotation> annotationClass;
+ // EJB3 4.6.2: The class may implement the ejbCreate method(s).
+ if(hasMethod(ejbClass, "ejbCreate"))
+ {
+ if(isStateful)
+ {
+ annotation = new InitImpl();
+ }
+ else
+ {
+ annotation = new PostConstructImpl();
+ }
+ annotationClass = annotation.annotationType();
+ method.setMethodName("ejbCreate");
+ addAnnotations(annotationClass, annotation, container, method);
+ }
+
+ annotation = new PostActivateImpl();
+ annotationClass = javax.ejb.PostActivate.class;
+ method.setMethodName("ejbActivate");
+ addAnnotations(annotationClass, annotation, container, method);
+
+ annotation = new PrePassivateImpl();
+ annotationClass = javax.ejb.PrePassivate.class;
+ method.setMethodName("ejbPassivate");
+ addAnnotations(annotationClass, annotation, container, method);
+
+ annotation = new PreDestroyImpl();
+ annotationClass = javax.annotation.PreDestroy.class;
+ method.setMethodName("ejbRemove");
+ addAnnotations(annotationClass, annotation, container, method);
+
+ annotation = new ResourceImpl();
+ annotationClass = Resource.class;
+ method.setMethodName("setSessionContext");
+ // TODO: set param?
+ addAnnotations(annotationClass, annotation, container, method);
+ }
+ }
+ }
+
+ private void addAssemblyAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean, String ejbName) throws Exception
+ {
+ AssemblyDescriptor assembly = dd.getAssemblyDescriptor();
+ if (assembly != null)
+ {
+ addExcludeAnnotations(container, assembly.getExcludeList(), ejbName);
+
+ addInterceptorBindingAnnotations(container, enterpriseBean, ejbName);
+ }
+
+ if (enterpriseBean instanceof SessionEnterpriseBean)
+ {
+ addInitAnnotations(container, ((SessionEnterpriseBean) enterpriseBean)
+ .getInitMethods(), ejbName);
+ addRemoveAnnotations(container,
+ ((SessionEnterpriseBean) enterpriseBean).getRemoveMethods(),
+ ejbName);
+ }
+ }
+
+ private void addExcludeAnnotations(EJBContainer container, ExcludeList list,
+ String ejbName) throws ClassNotFoundException, NoSuchMethodException,
+ NoSuchFieldException
+ {
+ if (list != null)
+ {
+ for (Object o : list.getMethods())
+ {
+ Method method = (Method) o;
+ if (method.getEjbName().equals(ejbName))
+ {
+ DenyAllImpl annotation = new DenyAllImpl();
+ addAnnotations(DenyAll.class, annotation, container, method);
+ }
+ }
+ }
+ }
+
+ private void addInitAnnotations(EJBContainer container,
+ List<InitMethod> list, String ejbName) throws ClassNotFoundException,
+ NoSuchMethodException, NoSuchFieldException
+ {
+ if (list != null)
+ {
+ for (InitMethod initMethod : list)
+ {
+ Method method = initMethod.getBeanMethod();
+ InitImpl annotation = new InitImpl();
+ addAnnotations(Init.class, annotation, container, method);
+ }
+ }
+ }
+
+ private void addRemoveAnnotations(EJBContainer container,
+ List<RemoveMethod> list, String ejbName)
+ throws ClassNotFoundException, NoSuchMethodException,
+ NoSuchFieldException
+ {
+ if (list != null)
+ {
+ for (RemoveMethod removeMethod : list)
+ {
+ Method method = removeMethod.getBeanMethod();
+ RemoveImpl annotation = new RemoveImpl(removeMethod
+ .isRetainIfException());
+ addAnnotations(Remove.class, annotation, container, method);
+ }
+ }
+ }
+
+ private void addSecurityAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean, String ejbName)
+ throws ClassNotFoundException, NoSuchMethodException,
+ NoSuchFieldException
+ {
+ AssemblyDescriptor assembly = dd.getAssemblyDescriptor();
+ if (assembly != null)
+ {
+ List securityRoles = assembly.getSecurityRoles();
+
+ if (securityRoles.size() > 0)
+ {
+ ArrayList roleList = new ArrayList();
+ for (Object securityRole : securityRoles)
+ {
+ SecurityRole role = (SecurityRole) securityRole;
+ roleList.add(role.getRoleName());
+
+ }
+ DeclareRolesImpl annotation = new DeclareRolesImpl(
+ (String[]) roleList.toArray(new String[roleList.size()]));
+ addClassAnnotation(container, DeclareRoles.class, annotation);
+ }
+
+ List methodPermissions = assembly.getMethodPermissions();
+ for (Object methodPermission : methodPermissions)
+ {
+ MethodPermission permission = (MethodPermission) methodPermission;
+ for (Method method : permission.getMethods())
+ {
+ if (method.getEjbName().equals(ejbName))
+ {
+ if (permission.isUnchecked())
+ {
+ PermitAllImpl annotation = new PermitAllImpl();
+ addAnnotations(PermitAll.class, annotation, container,
+ method);
+ } else
+ {
+ RolesAllowedImpl annotation = new RolesAllowedImpl();
+
+ for (Object o : permission.getRoleNames())
+ {
+ String roleName = (String) o;
+ annotation.addValue(roleName);
+ }
+ addAnnotations(RolesAllowed.class, annotation, container,
+ method);
+ }
+ }
+ }
+ }
+ }
+
+ if (enterpriseBean != null && enterpriseBean.getSecurityDomain() != null)
+ {
+ String securityDomain = enterpriseBean.getSecurityDomain();
+
+ SecurityDomainImpl annotation = new SecurityDomainImpl(securityDomain);
+
+ if (dd.getUnauthenticatedPrincipal() != null)
+ annotation.setUnauthenticatedPrincipal(dd
+ .getUnauthenticatedPrincipal());
+
+ addClassAnnotation(container, annotation.annotationType(), annotation);
+ } else if (dd.getSecurityDomain() != null)
+ {
+ String securityDomain = dd.getSecurityDomain();
+
+ SecurityDomainImpl annotation = new SecurityDomainImpl(securityDomain);
+
+ if (dd.getUnauthenticatedPrincipal() != null)
+ annotation.setUnauthenticatedPrincipal(dd
+ .getUnauthenticatedPrincipal());
+
+ addClassAnnotation(container, annotation.annotationType(), annotation);
+ } else if (dd.getUnauthenticatedPrincipal() != null)
+ {
+ SecurityDomain annotation = (SecurityDomain) ejbClass
+ .getAnnotation(SecurityDomain.class);
+ if (annotation != null)
+ {
+ SecurityDomainImpl override = new SecurityDomainImpl(annotation
+ .value());
+ override.setUnauthenticatedPrincipal(dd
+ .getUnauthenticatedPrincipal());
+
+ addClassAnnotation(container, override.annotationType(), override);
+ }
+ }
+ }
+
+ private void addTransactionAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean, String ejbName)
+ throws ClassNotFoundException, NoSuchMethodException,
+ NoSuchFieldException
+ {
+ if (enterpriseBean != null)
+ {
+ if (enterpriseBean.getTransactionManagementType() != null)
+ {
+ TransactionManagementImpl annotation = new TransactionManagementImpl();
+ annotation.setValue(enterpriseBean.getTransactionManagementType());
+ addClassAnnotation(container, TransactionManagement.class,
+ annotation);
+ }
+
+ MethodAttributes attributes = enterpriseBean.getMethodAttributes();
+ if (attributes != null)
+ {
+ Iterator methods = attributes.getMethods().iterator();
+ while (methods.hasNext())
+ {
+ Method method = (Method) methods.next();
+ if (method.getTransactionTimeout() != null)
+ {
+ TransactionTimeout timeoutAnnotation = new TransactionTimeoutImpl(
+ Integer.parseInt(method.getTransactionTimeout()));
+ addAnnotations(TransactionTimeout.class, timeoutAnnotation,
+ container, method);
+ }
+ }
+ }
+ }
+
+ AssemblyDescriptor descriptor = dd.getAssemblyDescriptor();
+ if (descriptor != null)
+ {
+ Iterator transactions = descriptor.getContainerTransactions()
+ .iterator();
+ while (transactions.hasNext())
+ {
+ ContainerTransaction transaction = (ContainerTransaction) transactions
+ .next();
+ if (transaction.getMethod().getEjbName().equals(ejbName))
+ {
+ String transAttribute = transaction.getTransAttribute();
+ TransactionAttributeImpl annotation = new TransactionAttributeImpl();
+ if (transAttribute.equals("Mandatory"))
+ annotation.setType(TransactionAttributeType.MANDATORY);
+ else if (transAttribute.equals("Required"))
+ annotation.setType(TransactionAttributeType.REQUIRED);
+ else if (transAttribute.equals("RequiresNew"))
+ annotation.setType(TransactionAttributeType.REQUIRES_NEW);
+ else if (transAttribute.equals("Supports"))
+ annotation.setType(TransactionAttributeType.SUPPORTS);
+ else if (transAttribute.equals("NotSupported"))
+ annotation.setType(TransactionAttributeType.NOT_SUPPORTED);
+ else if (transAttribute.equals("Never"))
+ annotation.setType(TransactionAttributeType.NEVER);
+
+ addAnnotations(TransactionAttribute.class, annotation,
+ container, transaction.getMethod());
+ }
+ }
+ }
+ }
+
+ /**
+ * Interceptors are additive. What's in the annotations and in the XML is
+ * merged
+ */
+ private void addInterceptorBindingAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean, String ejbName)
+ throws ClassNotFoundException, NoSuchMethodException,
+ NoSuchFieldException
+ {
+ boolean definesInterceptors = false;
+
+ List<InterceptorBinding> interceptorBindings = dd.getAssemblyDescriptor()
+ .getInterceptorBindings();
+ for (InterceptorBinding binding : interceptorBindings)
+ {
+ // Wolf: why ignore ordered binding?
+ /*
+ if (binding.isOrdered())
+ {
+ continue;
+ }
+ */
+ if (binding.getEjbName().equals(ejbName))
+ {
+ if (binding.getMethodName() == null
+ || binding.getMethodName().trim().length() == 0)
+ {
+ addClassLevelInterceptorBindingAnnotations(container, binding);
+ definesInterceptors = true;
+ } else
+ {
+ definesInterceptors = addMethodLevelInterceptorBindingAnnotations(
+ container, binding);
+ }
+
+ }
+ }
+
+ if (!definesInterceptors
+ && di.getInterceptorInfoRepository().hasDefaultInterceptors())
+ {
+ addClassAnnotation(container, DefaultInterceptorMarker.class,
+ new DefaultInterceptorMarkerImpl());
+ }
+ }
+
+ /**
+ * Interceptors are additive. What's in the annotations and in the XML is
+ * merged
+ */
+ private void addClassLevelInterceptorBindingAnnotations(
+ EJBContainer container, InterceptorBinding binding)
+ throws ClassNotFoundException
+ {
+ Interceptors interceptors = (Interceptors) container
+ .resolveAnnotation(Interceptors.class);
+ InterceptorsImpl impl = InterceptorsImpl.getImpl(interceptors);
+ for (String name : binding.getInterceptorClasses())
+ {
+ Class clazz = di.getClassLoader().loadClass(name);
+ impl.addValue(clazz);
+ }
+
+ addClassAnnotation(container, impl.annotationType(), impl);
+
+ boolean exclude = binding.getExcludeDefaultInterceptors();
+ if (exclude
+ && container.resolveAnnotation(ExcludeDefaultInterceptors.class) == null)
+ {
+ addClassAnnotation(container, ExcludeDefaultInterceptors.class,
+ new ExcludeDefaultInterceptorsImpl());
+ }
+
+ }
+
+ /**
+ * Interceptors are additive. What's in the annotations and in the XML is
+ * merged
+ */
+ private boolean addMethodLevelInterceptorBindingAnnotations(
+ EJBContainer container, InterceptorBinding binding)
+ throws ClassNotFoundException
+ {
+ boolean addedAnnotations = false;
+ for (java.lang.reflect.Method method : container.getBeanClass()
+ .getMethods())
+ {
+ boolean matches = false;
+ if (method.getName().equals(binding.getMethodName()))
+ {
+ if (binding.getMethodParams() == null)
+ {
+ matches = true;
+ } else
+ {
+ Class[] methodParams = method.getParameterTypes();
+ List<String> bindingParams = binding.getMethodParams();
+
+ if (methodParams.length == bindingParams.size())
+ {
+ matches = true;
+ int i = 0;
+ for (String paramName : bindingParams)
+ {
+ String methodParamName = InterceptorInfoRepository
+ .simpleType(methodParams[i++]);
+ if (!paramName.equals(methodParamName))
+ {
+ matches = false;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (matches)
+ {
+ Interceptors interceptors = (Interceptors) container
+ .resolveAnnotation(method, Interceptors.class);
+ InterceptorsImpl impl = InterceptorsImpl.getImpl(interceptors);
+ for (String name : binding.getInterceptorClasses())
+ {
+ Class clazz = di.getClassLoader().loadClass(name);
+ impl.addValue(clazz);
+ }
+ log.debug("adding " + Interceptors.class.getName()
+ + " method annotation to " + ejbClass.getName() + "."
+ + method.getName() + "(" + getParameters(method) + ")");
+ container.getAnnotations().addAnnotation(method,
+ Interceptors.class, impl);
+
+ boolean excludeDefault = binding.getExcludeDefaultInterceptors();
+ if (excludeDefault
+ && container.resolveAnnotation(method,
+ ExcludeDefaultInterceptors.class) == null)
+ {
+ log.debug("adding " + ExcludeDefaultInterceptors.class.getName()
+ + " method annotation to " + ejbClass.getName() + "."
+ + method.getName() + "(" + getParameters(method) + ")");
+ container.getAnnotations().addAnnotation(method,
+ ExcludeDefaultInterceptors.class,
+ new ExcludeDefaultInterceptorsImpl());
+ }
+
+ boolean excludeClass = binding.getExcludeClassInterceptors();
+ if (excludeClass
+ && container.resolveAnnotation(method,
+ ExcludeClassInterceptors.class) == null)
+ {
+ log.debug("adding " + ExcludeClassInterceptors.class.getName()
+ + " method annotation to " + ejbClass.getName() + "."
+ + method.getName() + "(" + getParameters(method) + ")");
+ container.getAnnotations().addAnnotation(method,
+ ExcludeClassInterceptors.class,
+ new ExcludeClassInterceptorsImpl());
+ }
+ matches = false;
+ addedAnnotations = true;
+ }
+ }
+
+ return addedAnnotations;
+ }
+
+ private void addEjbAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean) throws Exception
+ {
+ if (enterpriseBean != null)
+ {
+ addHomeAnnotations(container, enterpriseBean);
+
+ addJndiAnnotations(container, enterpriseBean);
+
+ addInterceptorMethodAnnotations(container, enterpriseBean);
+
+ handleResourceRefs(container, enterpriseBean.getResourceRefs());
+
+ addMessageDestinationAnnotations(container, enterpriseBean.getMessageDestinationRefs());
+
+ addSecurityIdentityAnnotation(container, enterpriseBean
+ .getSecurityIdentity());
+
+ addDependencies(container, enterpriseBean);
+
+ addPoolAnnotations(container, enterpriseBean);
+
+ addXmlAnnotations(container, enterpriseBean);
+
+ if (enterpriseBean instanceof SessionEnterpriseBean)
+ {
+ addConcurrentAnnotations(container, (SessionEnterpriseBean)enterpriseBean);
+ addClusterAnnotations(container, (SessionEnterpriseBean)enterpriseBean);
+ addCacheAnnotations(container, (SessionEnterpriseBean)enterpriseBean);
+ }
+ }
+ }
+
+ private void addConcurrentAnnotations(EJBContainer container,
+ SessionEnterpriseBean enterpriseBean) throws Exception
+ {
+ if (enterpriseBean.getConcurrent() != null)
+ {
+ boolean concurrent = Boolean.getBoolean(enterpriseBean.getConcurrent());
+ if (concurrent)
+ {
+ SerializedConcurrentAccessImpl annotation = new SerializedConcurrentAccessImpl();
+ addClassAnnotation(container, SerializedConcurrentAccess.class, annotation);
+ }
+ else
+ {
+ container.getAnnotations().disableAnnotation(SerializedConcurrentAccess.class.getName());
+ }
+ }
+ }
+
+ private void addPoolAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean) throws Exception
+ {
+ if (enterpriseBean.getPoolConfig() != null)
+ {
+ PoolConfig config = enterpriseBean.getPoolConfig();
+
+ PoolClassImpl poolAnnotation = new PoolClassImpl();
+
+ if (config.getPoolClass() != null)
+ poolAnnotation.setValue(di.getClassLoader().loadClass(config.getPoolClass()));
+
+ if (config.getMaxSize() != null)
+ poolAnnotation.setMaxSize(Integer.parseInt(config.getMaxSize()));
+
+ if (config.getTimeout() != null)
+ poolAnnotation.setTimeout(Long.parseLong(config.getTimeout()));
+
+ addClassAnnotation(container, PoolClass.class, poolAnnotation);
+ }
+ }
+
+ private void addXmlAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean) throws Exception
+ {
+ Iterator xmlAnnotations = enterpriseBean.getXmlAnnotations().iterator();
+ while (xmlAnnotations.hasNext())
+ {
+ XmlAnnotation xmlAnnotation = (XmlAnnotation)xmlAnnotations.next();
+
+ Class annotationClass = di.getClassLoader().loadClass(xmlAnnotation.getAnnotationClass());
+ Class annotationImplementationClass = di.getClassLoader().loadClass(xmlAnnotation.getAnnotationImplementationClass());
+ Object annotation = annotationImplementationClass.newInstance();
+
+ Iterator properties = xmlAnnotation.getProperties().iterator();
+ while (properties.hasNext())
+ {
+ NameValuePair property = (NameValuePair)properties.next();
+ Field field = annotationImplementationClass.getDeclaredField(property.getName());
+ setAnnotationPropertyField(field, annotation, property.getValue());
+ }
+
+ if (xmlAnnotation.getInjectionTarget() == null)
+ {
+ addClassAnnotation(container, annotationClass, annotation);
+ }
+ else
+ {
+ Method method = new Method();
+ method.setMethodName(xmlAnnotation.getInjectionTarget().getTargetName());
+ addAnnotations(annotationClass, annotation, container, method);
+ }
+ }
+ }
+
+ protected void setAnnotationPropertyField(Field field, Object annotation, String value) throws Exception
+ {
+ if (field.getType() == String.class)
+ field.set(annotation, value);
+ else if (field.getType() == Long.class)
+ field.setLong(annotation, Long.parseLong(value));
+ else if (field.getType() == Integer.class)
+ field.setInt(annotation, Integer.parseInt(value));
+ else if (field.getType() == Class.class)
+ field.set(annotation, di.getClassLoader().loadClass(value));
+ else if (field.getType() == Boolean.class)
+ field.setBoolean(annotation, Boolean.parseBoolean(value));
+ }
+
+ private void addCacheAnnotations(EJBContainer container,
+ SessionEnterpriseBean enterpriseBean) throws Exception
+ {
+ if (enterpriseBean.getCacheConfig() != null)
+ {
+ CacheConfig config = enterpriseBean.getCacheConfig();
+ if (config.getCacheClass() != null)
+ {
+ Class cacheClass = di.getClassLoader().loadClass(config.getCacheClass());
+ CacheImpl cacheAnnotation = new CacheImpl(cacheClass);
+ addClassAnnotation(container, Cache.class, cacheAnnotation);
+
+ if (cacheClass == org.jboss.ejb3.cache.simple.SimpleStatefulCache.class)
+ {
+ if (!ejbClass.isAnnotationPresent(PersistenceManager.class))
+ {
+ PersistenceManagerImpl persistenceAnnotation = new PersistenceManagerImpl();
+ if (config.getPersistenceManager() != null)
+ persistenceAnnotation.setValue(di.getClassLoader().loadClass(config.getPersistenceManager()));
+ addClassAnnotation(container, PersistenceManager.class, persistenceAnnotation);
+ }
+ }
+ }
+
+ if (config.getName() != null)
+ {
+ org.jboss.annotation.ejb.cache.tree.CacheConfigImpl configAnnotation = new org.jboss.annotation.ejb.cache.tree.CacheConfigImpl();
+
+ configAnnotation.setName(config.getName());
+
+ if (config.getMaxSize() != null)
+ configAnnotation.setMaxSize(Integer.parseInt(config.getMaxSize()));
+
+ if (config.getIdleTimeoutSeconds() != null)
+ configAnnotation.setIdleTimeoutSeconds(Long.parseLong(config.getIdleTimeoutSeconds()));
+
+ if (config.getReplicationIsPassivation() != null)
+ configAnnotation.setReplicationIsPassivation(Boolean.parseBoolean(config.getReplicationIsPassivation()));
+
+ if (config.getRemoveTimeoutSeconds() != null)
+ configAnnotation.setRemovalTimeoutSeconds(Long.parseLong(config.getRemoveTimeoutSeconds()));
+
+ org.jboss.annotation.ejb.cache.tree.CacheConfig existingConfig = (org.jboss.annotation.ejb.cache.tree.CacheConfig)ejbClass.getAnnotation(org.jboss.annotation.ejb.cache.tree.CacheConfig.class);
+ if (existingConfig != null)
+ configAnnotation.merge(existingConfig);
+
+ addClassAnnotation(container, org.jboss.annotation.ejb.cache.tree.CacheConfig.class, configAnnotation);
+ }
+ else
+ {
+ org.jboss.annotation.ejb.cache.simple.CacheConfigImpl configAnnotation = new org.jboss.annotation.ejb.cache.simple.CacheConfigImpl();
+
+ if (config.getMaxSize() != null)
+ configAnnotation.setMaxSize(Integer.parseInt(config.getMaxSize()));
+
+ if (config.getIdleTimeoutSeconds() != null)
+ configAnnotation.setIdleTimeoutSeconds(Long.parseLong(config.getIdleTimeoutSeconds()));
+
+ if (config.getRemoveTimeoutSeconds() != null)
+ configAnnotation.setRemovalTimeoutSeconds(Long.parseLong(config.getRemoveTimeoutSeconds()));
+
+ org.jboss.annotation.ejb.cache.simple.CacheConfig existingConfig = (org.jboss.annotation.ejb.cache.simple.CacheConfig)ejbClass.getAnnotation(org.jboss.annotation.ejb.cache.simple.CacheConfig.class);
+ if (existingConfig != null)
+ configAnnotation.merge(existingConfig);
+
+ addClassAnnotation(container, org.jboss.annotation.ejb.cache.simple.CacheConfig.class, configAnnotation);
+ }
+ }
+
+ }
+
+ private void addClusterAnnotations(EJBContainer container,
+ SessionEnterpriseBean enterpriseBean) throws Exception
+ {
+ ClusteredImpl clusteredAnnotation = null;
+
+ if (enterpriseBean.getClustered() != null)
+ {
+ Clustered existingAnnotation = (Clustered)ejbClass.getAnnotation(Clustered.class);
+
+ boolean clustered = Boolean.parseBoolean(enterpriseBean.getClustered());
+ if (!clustered)
+ {
+ if (existingAnnotation != null)
+ container.getAnnotations().disableAnnotation(Clustered.class.getName());
+
+ return;
+ }
+ else
+ {
+ if (existingAnnotation == null)
+ clusteredAnnotation = new ClusteredImpl();
+ }
+ }
+
+ ClusterConfig config = enterpriseBean.getClusterConfig();
+ if (config != null)
+ {
+ if (clusteredAnnotation == null)
+ clusteredAnnotation = new ClusteredImpl();
+
+ if (config.getLoadBalancePolicy() != null)
+ {
+ Class policy = di.getClassLoader().loadClass(config.getLoadBalancePolicy());
+ clusteredAnnotation.setLoadBalancePolicy(policy);
+ }
+
+ if (config.getPartition() != null)
+ {
+ clusteredAnnotation.setPartition(config.getPartition());
+ }
+ }
+
+ if (clusteredAnnotation != null)
+ {
+ addClassAnnotation(container, Clustered.class, clusteredAnnotation);
+ }
+ }
+
+ private void addDependencies(EJBContainer container,
+ EnterpriseBean enterpriseBean) throws Exception
+ {
+ if (enterpriseBean.getDependencies().size() > 0)
+ {
+ DependsImpl annotation = new DependsImpl();
+ Iterator<String> dependencies = enterpriseBean.getDependencies()
+ .iterator();
+ while (dependencies.hasNext())
+ {
+ annotation.addDependency(dependencies.next());
+ }
+
+ addClassAnnotation(container, Depends.class, annotation);
+ }
+
+ if (enterpriseBean.getIgnoreDependencies().size() > 0)
+ {
+ Iterator<InjectionTarget> ignores = enterpriseBean.getIgnoreDependencies().iterator();
+ while (ignores.hasNext())
+ {
+ InjectionTarget ignore = ignores.next();
+ IgnoreDependencyImpl annotation = new IgnoreDependencyImpl();
+
+ Method method = new Method();
+ method.setMethodName(ignore.getTargetName());
+
+ addAnnotations(IgnoreDependency.class, annotation, container, method);
+ }
+ }
+ }
+
+ private void addServiceAnnotations(EJBContainer container, EnterpriseBean ejb)
+ throws ClassNotFoundException
+ {
+ org.jboss.ejb3.metamodel.Service service = (org.jboss.ejb3.metamodel.Service) ejb;
+
+ if (service == null)
+ return;
+
+ String management = service.getManagement();
+
+ if (management != null)
+ {
+ ManagementImpl annotation = new ManagementImpl(di.getClassLoader()
+ .loadClass(management));
+ addClassAnnotation(container, Management.class, annotation);
+ }
+ }
+
+ private void addConsumerAnnotations(EJBContainer container,
+ EnterpriseBean ejb) throws ClassNotFoundException,
+ NoSuchFieldException, NoSuchMethodException
+ {
+ org.jboss.ejb3.metamodel.Consumer consumer = (org.jboss.ejb3.metamodel.Consumer) ejb;
+
+ if (consumer == null)
+ return;
+
+ if (consumer.getProducers().size() > 0
+ || consumer.getLocalProducers().size() > 0)
+ {
+ ProducersImpl producersAnnotation = new ProducersImpl();
+
+ Iterator producers = consumer.getProducers().iterator();
+ while (producers.hasNext())
+ {
+ org.jboss.ejb3.metamodel.Producer producer = (org.jboss.ejb3.metamodel.Producer) producers
+ .next();
+ ProducerImpl annotation = new ProducerImpl(di.getClassLoader()
+ .loadClass(producer.getClassName()));
+ if (producer.getConnectionFactory() != null)
+ annotation.setConnectionFactory(producer.getConnectionFactory());
+ producersAnnotation.addProducer(annotation);
+ }
+
+ producers = consumer.getLocalProducers().iterator();
+ while (producers.hasNext())
+ {
+ org.jboss.ejb3.metamodel.Producer producer = (org.jboss.ejb3.metamodel.Producer) producers
+ .next();
+ ProducerImpl annotation = new ProducerImpl(di.getClassLoader()
+ .loadClass(producer.getClassName()));
+ if (producer.getConnectionFactory() != null)
+ annotation.setConnectionFactory(producer.getConnectionFactory());
+ producersAnnotation.addProducer(annotation);
+ }
+ addClassAnnotation(container, Producers.class, producersAnnotation);
+ }
+
+ org.jboss.ejb3.metamodel.CurrentMessage currentMessage = consumer
+ .getCurrentMessage();
+ if (currentMessage != null)
+ {
+ List methods = currentMessage.getMethods();
+ CurrentMessageImpl annotation = new CurrentMessageImpl();
+ for (int i = 0; i < methods.size(); ++i)
+ {
+ Method method = (Method) methods.get(i);
+ addAnnotations(CurrentMessage.class, annotation, container, method);
+ }
+ }
+
+ org.jboss.ejb3.metamodel.MessageProperties properties = consumer
+ .getMessageProperties();
+ if (properties != null)
+ {
+ List methods = properties.getMethods();
+
+ MessagePropertiesImpl annotation = new MessagePropertiesImpl();
+
+ String delivery = properties.getDelivery();
+ if (delivery != null && delivery.equals("Persistent"))
+ annotation.setDelivery(DeliveryMode.PERSISTENT);
+ else
+ annotation.setDelivery(DeliveryMode.NON_PERSISTENT);
+
+ String priority = properties.getPriority();
+ if (priority != null)
+ annotation.setDelivery(DeliveryMode.PERSISTENT);
+
+ String interfac = properties.getClassName();
+ if (interfac != null)
+ {
+ Class clazz = di.getClassLoader().loadClass(interfac);
+ annotation.setInterface(clazz);
+ }
+
+ for (int i = 0; i < methods.size(); ++i)
+ {
+ Method method = (Method) methods.get(i);
+ addAnnotations(MessageProperties.class, annotation, container,
+ method);
+ }
+ }
+ }
+
+ private void addJndiAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean) throws ClassNotFoundException
+ {
+ addLocalJndiAnnotations(container, enterpriseBean);
+ addRemoteJndiAnnotations(container, enterpriseBean);
+ }
+
+ private void addLocalJndiAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean) throws ClassNotFoundException
+ {
+ String localJndiName = enterpriseBean.getLocalJndiName();
+ if (localJndiName != null)
+ {
+ LocalBindingImpl localBinding = new LocalBindingImpl(localJndiName);
+ addClassAnnotation(container, LocalBinding.class, localBinding);
+ }
+
+ String localHomeJndiName = enterpriseBean.getLocalHomeJndiName();
+ if (localHomeJndiName != null)
+ {
+ LocalHomeBindingImpl localHomeBinding = new LocalHomeBindingImpl(localHomeJndiName);
+ addClassAnnotation(container, LocalHomeBinding.class, localHomeBinding);
+ }
+ }
+
+ private void addRemoteJndiAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean) throws ClassNotFoundException
+ {
+ String homeJndiName = enterpriseBean.getHomeJndiName();
+ if (homeJndiName != null)
+ {
+ RemoteHomeBindingImpl homeBinding = new RemoteHomeBindingImpl(homeJndiName);
+ addClassAnnotation(container, RemoteHomeBinding.class, homeBinding);
+ }
+
+ List<org.jboss.ejb3.metamodel.RemoteBinding> bindingsList = enterpriseBean.getRemoteBindings();
+ if (bindingsList.size() == 0)
+ {
+ addSimpleJndiAnnotations(container, enterpriseBean);
+ return;
+ }
+
+ AnnotationRepository annotations = container.getAnnotations();
+
+ annotations.disableAnnotation(RemoteBinding.class.getName());
+
+ List<RemoteBindingImpl> bindingAnnotationsList = new ArrayList();
+
+ Iterator bindings = bindingsList.iterator();
+ while(bindings.hasNext())
+ {
+ org.jboss.ejb3.metamodel.RemoteBinding binding = (org.jboss.ejb3.metamodel.RemoteBinding)bindings.next();
+ RemoteBindingImpl bindingAnnotation = new RemoteBindingImpl();
+
+ if (binding.getJndiName() != null)
+ bindingAnnotation.setJndiBinding(binding.getJndiName());
+
+ if (binding.getClientBindUrl() != null)
+ bindingAnnotation.setBindUrl(binding.getClientBindUrl());
+
+ if (binding.getInterceptorStack() != null)
+ bindingAnnotation.setStack(binding.getInterceptorStack());
+
+ if (binding.getProxyFactory() != null)
+ bindingAnnotation.setFactory(di.getClassLoader().loadClass(binding.getProxyFactory()));
+
+ bindingAnnotationsList.add(bindingAnnotation);
+
+ }
+
+ RemoteBindingsImpl bindingsAnnotation = new RemoteBindingsImpl(bindingAnnotationsList);
+ addClassAnnotation(container, RemoteBindings.class, bindingsAnnotation);
+ }
+
+ private void addSimpleJndiAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean) throws ClassNotFoundException
+ {
+ RemoteBindingImpl remoteBinding = null;
+
+ String jndiName = enterpriseBean.getJndiName();
+ if (jndiName != null)
+ {
+ remoteBinding = new RemoteBindingImpl();
+ remoteBinding.setJndiBinding(jndiName);
+ addClassAnnotation(container, RemoteBinding.class, remoteBinding);
+ }
+
+ if (remoteBinding != null)
+ {
+ RemoteBinding existingBinding = (RemoteBinding)ejbClass.getAnnotation(RemoteBinding.class);
+ if (existingBinding != null)
+ remoteBinding.merge(existingBinding);
+
+ addClassAnnotation(container, RemoteBinding.class, remoteBinding);
+ }
+ }
+
+ private void handleResourceRefs(EJBContainer container,
+ Collection<ResourceRef> resourceRefList)
+ {
+ Iterator refs = resourceRefList.iterator();
+ while (refs.hasNext())
+ {
+ ResourceRef ref = (ResourceRef) refs.next();
+
+ if (ref.getResourceName() != null)
+ {
+ // for <resource-manager>
+ ref.setJndiName(dd.resolveResourceManager(ref.getResourceName()));
+ ref.setMappedName(dd.resolveResourceManager(ref.getResourceName()));
+ }
+ }
+ }
+
+ private void addMessageDestinationAnnotations(EJBContainer container,
+ Collection destinationRefList)
+
+ {
+ Iterator refs = destinationRefList.iterator();
+ while (refs.hasNext())
+ {
+ MessageDestinationRef ref = (MessageDestinationRef) refs.next();
+
+ if (ref.getMappedName() == null || ref.getMappedName().equals(""))
+ {
+ AssemblyDescriptor descriptor = dd.getAssemblyDescriptor();
+ if (descriptor != null)
+ {
+ MessageDestination destination = descriptor
+ .findMessageDestination(ref.getMessageDestinationLink());
+ if (destination != null)
+ {
+ ref.setMappedName(destination.getJndiName());
+ }
+ }
+ }
+ }
+ }
+
+ private void addInterceptorMethodAnnotations(EJBContainer container,
+ EnterpriseBean enterpriseBean)
+ {
+ if (enterpriseBean instanceof SessionEnterpriseBean)
+ {
+ addInterceptorMethodAnnotation(container, enterpriseBean,
+ ((SessionEnterpriseBean) enterpriseBean).getAroundInvoke(),
+ AroundInvoke.class, "around-invoke-method");
+ addInterceptorMethodAnnotation(container, enterpriseBean,
+ ((SessionEnterpriseBean) enterpriseBean).getPostConstruct(),
+ PostConstruct.class, "post-construct-method");
+ addInterceptorMethodAnnotation(container, enterpriseBean,
+ ((SessionEnterpriseBean) enterpriseBean).getPostActivate(),
+ PostActivate.class, "post-activate-method");
+ addInterceptorMethodAnnotation(container, enterpriseBean,
+ ((SessionEnterpriseBean) enterpriseBean).getPrePassivate(),
+ PrePassivate.class, "pre-passivate-method");
+ addInterceptorMethodAnnotation(container, enterpriseBean,
+ ((SessionEnterpriseBean) enterpriseBean).getPreDestroy(),
+ PreDestroy.class, "pre-destroy-method");
+ } else if (enterpriseBean instanceof MessageDrivenBean)
+ {
+ addInterceptorMethodAnnotation(container, enterpriseBean,
+ ((MessageDrivenBean) enterpriseBean).getAroundInvoke(),
+ AroundInvoke.class, "around-invoke-method");
+ addInterceptorMethodAnnotation(container, enterpriseBean,
+ ((MessageDrivenBean) enterpriseBean).getPostConstruct(),
+ PostConstruct.class, "post-construct-method");
+ addInterceptorMethodAnnotation(container, enterpriseBean,
+ ((MessageDrivenBean) enterpriseBean).getPreDestroy(),
+ PreDestroy.class, "pre-destroy-method");
+ }
+ }
+
+ private void addInterceptorMethodAnnotation(EJBContainer container,
+ EnterpriseBean enterpriseBean, Method method, Class ann, String xmlName)
+ {
+ if (method == null)
+ return;
+
+ java.lang.reflect.Method found = null;
+ for (java.lang.reflect.Method rm : container.getBeanClass()
+ .getDeclaredMethods())
+ {
+ if (rm.getName().equals(method.getMethodName()))
+ {
+ if (ann == AroundInvoke.class)
+ {
+ if (InterceptorInfoRepository.checkValidBusinessSignature(rm))
+ {
+ found = rm;
+ break;
+ }
+ } else
+ {
+ if (InterceptorInfoRepository
+ .checkValidBeanLifecycleSignature(rm))
+ {
+ found = rm;
+ break;
+ }
+ }
+ }
+ }
+
+ if (found == null)
+ {
+ log.warn("No method found within " + container.getBeanClassName()
+ + " with name " + method.getMethodName()
+ + " with the right signature for " + xmlName + "was found");
+ return;
+ }
+
+ if (container.resolveAnnotation(found, ann) == null)
+ {
+ log.debug("adding " + ann.getName() + " method annotation to "
+ + ejbClass.getName() + "." + found.getName());
+
+ container.getAnnotations().addAnnotation(found, ann,
+ getInterceptorImpl(ann));
+ }
+ }
+
+ private Object getInterceptorImpl(Class ann)
+ {
+ if (ann == AroundInvoke.class)
+ {
+ return new AroundInvokeImpl();
+ } else if (ann == PostConstruct.class)
+ {
+ return new PostConstructImpl();
+ } else if (ann == PostActivate.class)
+ {
+ return new PostActivateImpl();
+ } else if (ann == PrePassivate.class)
+ {
+ return new PrePassivateImpl();
+ } else if (ann == PreDestroy.class)
+ {
+ return new PreDestroyImpl();
+ }
+
+ return null;
+ }
+
+ private void addSecurityIdentityAnnotation(EJBContainer container,
+ SecurityIdentity identity)
+ {
+ if (identity != null && !identity.isUseCallerIdentity())
+ {
+ RunAs runAs = identity.getRunAs();
+ if (runAs != null)
+ {
+ RunAsImpl annotation = new RunAsImpl(runAs.getRoleName());
+ addClassAnnotation(container, annotation.annotationType(),
+ annotation);
+
+ String runAsPrincipal = identity.getRunAsPrincipal();
+ if (runAsPrincipal != null)
+ {
+ RunAsPrincipalImpl principalAnnotation = new RunAsPrincipalImpl(
+ runAs.getRoleName());
+ addClassAnnotation(container, principalAnnotation
+ .annotationType(), principalAnnotation);
+ }
+ }
+ }
+ }
+
+ protected void overrideAnnotations(EJBContainer container, Member m,
+ String annotation, Object value)
+ {
+ AnnotationRepository annotations = container.getAnnotations();
+
+ if (value instanceof javax.annotation.security.DenyAll)
+ {
+ annotations.disableAnnotation(m,
+ javax.annotation.security.PermitAll.class.getName());
+ annotations.disableAnnotation(m,
+ javax.annotation.security.RolesAllowed.class.getName());
+ } else if (value instanceof javax.annotation.security.PermitAll)
+ {
+ annotations.disableAnnotation(m,
+ javax.annotation.security.DenyAll.class.getName());
+ annotations.disableAnnotation(m,
+ javax.annotation.security.RolesAllowed.class.getName());
+ } else if (value instanceof javax.annotation.security.RolesAllowed)
+ {
+ annotations.disableAnnotation(m,
+ javax.annotation.security.PermitAll.class.getName());
+ annotations.disableAnnotation(m,
+ javax.annotation.security.DenyAll.class.getName());
+ }
+ }
+
+ private void addClassAnnotation(EJBContainer container,
+ Class annotationClass, Object annotation)
+ {
+ log.debug("adding class annotation " + annotationClass.getName() + " to "
+ + ejbClass.getName() + " " + annotation);
+ container.getAnnotations()
+ .addClassAnnotation(annotationClass, annotation);
+ }
+
+ private void addAnnotations(Class annotationClass, Object annotation,
+ EJBContainer container, Method method)
+ {
+ String methodName = method.getMethodName();
+
+ try
+ {
+ AnnotationRepository annotations = container.getAnnotations();
+ if (methodName.equals("*"))
+ {
+ log.debug("adding " + annotationClass.getName() + " annotation to "
+ + ejbClass.getName() + "." + methodName);
+
+ for (java.lang.reflect.Method declaredMethod : ejbClass
+ .getDeclaredMethods())
+ {
+ annotations.addAnnotation(declaredMethod, annotationClass,
+ annotation);
+ overrideAnnotations(container, declaredMethod, annotationClass
+ .getName(), annotation);
+ }
+ } else
+ {
+ List params = method.getMethodParams();
+ if (params == null)
+ {
+ java.lang.reflect.Method[] methods = ejbClass.getMethods();
+ boolean foundMethod = false;
+ for (int methodIndex = 0; methodIndex < methods.length; ++methodIndex)
+ {
+ if (methods[methodIndex].getName().equals(methodName))
+ {
+ log.debug("adding " + annotationClass.getName()
+ + " method annotation to " + ejbClass.getName() + "."
+ + methodName);
+ annotations.addAnnotation(methods[methodIndex],
+ annotationClass, annotation);
+ overrideAnnotations(container, methods[methodIndex],
+ annotationClass.getName(), annotation);
+ foundMethod = true;
+
+ }
+ }
+
+ if (!foundMethod)
+ {
+ methods = ejbClass.getDeclaredMethods();
+ for (int methodIndex = 0; methodIndex < methods.length; ++methodIndex)
+ {
+ if (methods[methodIndex].getName().equals(methodName))
+ {
+ log.debug("adding " + annotationClass.getName()
+ + " method annotation to " + ejbClass.getName()
+ + "." + methodName);
+ annotations.addAnnotation(methods[methodIndex],
+ annotationClass, annotation);
+ overrideAnnotations(container, methods[methodIndex],
+ annotationClass.getName(), annotation);
+ foundMethod = true;
+
+ }
+ }
+ }
+
+ if (!foundMethod)
+ {
+ java.lang.reflect.Field member = ejbClass
+ .getDeclaredField(methodName);
+ if (member != null)
+ {
+ log.debug("adding " + annotationClass.getName()
+ + " field annotation to " + ejbClass.getName() + "."
+ + methodName);
+ annotations
+ .addAnnotation(member, annotationClass, annotation);
+ overrideAnnotations(container, member, annotationClass
+ .getName(), annotation);
+ }
+ }
+ } else
+ {
+ Class[] methodSignature = new Class[params.size()];
+ Iterator paramIterator = params.iterator();
+ int paramIndex = 0;
+ while (paramIterator.hasNext())
+ {
+ String param = (String) paramIterator.next();
+ Class paramClass = null;
+ if (param.equals("boolean"))
+ paramClass = boolean.class;
+ else if (param.equals("int"))
+ paramClass = int.class;
+ else if (param.equals("long"))
+ paramClass = long.class;
+ else if (param.equals("short"))
+ paramClass = short.class;
+ else if (param.equals("byte"))
+ paramClass = byte.class;
+ else if (param.equals("char"))
+ paramClass = char.class;
+ else
+ paramClass = di.getClassLoader().loadClass(param);
+ methodSignature[paramIndex++] = paramClass;
+ }
+ java.lang.reflect.Member member = ejbClass.getMethod(methodName,
+ methodSignature);
+ log.debug("adding " + annotationClass.getName()
+ + " method annotation to " + ejbClass.getName() + "."
+ + methodName);
+ annotations.addAnnotation(member, annotationClass, annotation);
+ overrideAnnotations(container, member, annotationClass.getName(),
+ annotation);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to create annotation from method/field " + method.getMethodName() + " for EJB " + container.getEjbName(), e);
+ }
+ }
+
+ private static String getParameters(java.lang.reflect.Method m)
+ {
+ if (m.getParameterTypes().length == 0)
+ {
+ return "";
+ }
+ StringBuffer sb = new StringBuffer();
+ boolean first = true;
+ for (Class param : m.getParameterTypes())
+ {
+ if (!first)
+ {
+ sb.append(", ");
+ } else
+ {
+ first = false;
+ }
+ sb.append(InterceptorInfoRepository.simpleType(param));
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Verify whether the class has a method with a certain name.
+ *
+ * @param cls the class to check
+ * @param methodName the method to find
+ * @return true if a method with that name exists on that class
+ */
+ private boolean hasMethod(Class<?> cls, String methodName)
+ {
+ assert cls != null : "cls is null";
+ assert methodName != null : "methodName is null";
+
+ for(java.lang.reflect.Method m : cls.getDeclaredMethods())
+ {
+ if(m.getName().equals(methodName))
+ return true;
+ }
+
+ if(cls.getSuperclass() != null)
+ return hasMethod(cls.getSuperclass(), methodName);
+
+ return false;
+ }
+}
Added: tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
===================================================================
--- tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java (rev 0)
+++ tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java 2010-03-24 16:07:27 UTC (rev 102893)
@@ -0,0 +1,1491 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.metamodel;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.EnvEntry;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.NameValuePair;
+import org.jboss.metamodel.descriptor.PersistenceContextRef;
+import org.jboss.metamodel.descriptor.PersistenceUnitRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.metamodel.descriptor.RunAs;
+import org.jboss.metamodel.descriptor.SecurityRole;
+import org.jboss.metamodel.descriptor.SecurityRoleRef;
+import org.jboss.util.StringPropertyReplacer;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * org.jboss.xb.binding.ObjectModelFactory implementation that accepts data
+ * chuncks from unmarshaller and assembles them into an EjbJarDD instance.
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @author Anil.Saldhana at jboss.org
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public class EjbJarDDObjectFactory extends DDObjectFactory
+{
+
+ private static final Logger log = Logger.getLogger(EjbJarDDObjectFactory.class);
+
+ public static EjbJarDD parse(URL ddResource) throws JBossXBException, IOException
+ {
+ ObjectModelFactory factory = null;
+ Unmarshaller unmarshaller = null;
+ EjbJarDD dd = null;
+
+ if (ddResource != null)
+ {
+ log.debug("found ejb-jar.xml " + ddResource);
+
+ factory = new EjbJarDDObjectFactory();
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setEntityResolver(new JBossEntityResolver());
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setValidation(true);
+
+ dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
+ }
+
+ return dd;
+ }
+
+ public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+
+ final EjbJarDD dd;
+ if (root == null)
+ {
+ root = dd = new EjbJarDD();
+ }
+ else
+ {
+ dd = (EjbJarDD)root;
+ }
+
+ if (attrs.getLength() > 0)
+ {
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ if (attrs.getLocalName(i).equals("version"))
+ {
+ dd.setVersion(attrs.getValue(i));
+ }
+ }
+ }
+
+ return root;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
+ {
+ return root;
+ }
+
+ // Methods discovered by introspection
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("enterprise-beans"))
+ {
+ child = new EnterpriseBeans();
+ }
+ if (localName.equals("interceptors"))
+ {
+ child = new Interceptors();
+ }
+ else if (localName.equals("relationships"))
+ {
+ child = new Relationships();
+ }
+ else if (localName.equals("assembly-descriptor"))
+ {
+ child = new AssemblyDescriptor();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("session"))
+ {
+ child = new SessionEnterpriseBean();
+ }
+ else if (localName.equals("entity"))
+ {
+ child = new EntityEnterpriseBean();
+ }
+ else if (localName.equals("message-driven"))
+ {
+ child = new MessageDrivenBean();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ private Object newEjbChild(EnterpriseBean parent, String localName)
+ {
+ Object child = null;
+
+ if ((child = super.newEnvRefGroupChild(localName)) != null)
+ return child;
+ return child;
+ }
+
+ private Object newEjbHasInterceptorsChild(EnterpriseBean parent, String localName)
+ {
+ Object child = null;
+
+ if (localName.equals("around-invoke"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("post-construct"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("post-activate"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ child = new Method();
+ }
+ return child;
+ }
+
+ public Object newChild(MessageDrivenBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = newEjbChild(parent, localName);
+ if (child != null)
+ return child;
+
+ child = newEjbHasInterceptorsChild(parent, localName);
+ if (child != null)
+ return child;
+
+ if (localName.equals("message-driven-destination"))
+ {
+ child = new MessageDrivenDestination();
+ }
+ else if (localName.equals("activation-config"))
+ {
+ child = new ActivationConfig();
+ }
+
+ return child;
+ }
+
+ public Object newChild(ActivationConfig parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("activation-config-property"))
+ {
+ child = new NameValuePair();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(SessionEnterpriseBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = newEjbChild(parent, localName);
+ if (child != null)
+ return child;
+
+ child = newEjbHasInterceptorsChild(parent, localName);
+ if (child != null)
+ return child;
+
+ if (localName.equals("security-role-ref"))
+ {
+ child = new SecurityRoleRef();
+ }
+ else if (localName.equals("security-identity"))
+ {
+ child = new SecurityIdentity();
+ }
+ else if (localName.equals("remove-method"))
+ {
+ RemoveMethod method = new RemoveMethod();
+ parent.addRemoveMethod(method);
+ child = method;
+ }
+ else if (localName.equals("init-method"))
+ {
+ InitMethod method = new InitMethod();
+ parent.addInitMethod(method);
+ child = method;
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EntityEnterpriseBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ child = newEjbChild(parent, localName);
+ if (child == null)
+ {
+ if (localName.equals("security-role-ref"))
+ {
+ child = new SecurityRoleRef();
+ }
+ else if (localName.equals("cmp-field"))
+ {
+ child = new CmpField();
+ }
+ else if (localName.equals("query"))
+ {
+ child = new Query();
+ }
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(SecurityIdentity parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("run-as"))
+ {
+ child = new RunAs();
+ }
+ else if (localName.equals("use-caller-identity"))
+ {
+ parent.setUseCallerIdentity(true);
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(RemoveMethod parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("bean-method"))
+ {
+ parent.setBeanMethod(new Method());
+ child = parent.getBeanMethod();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(InitMethod parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("bean-method"))
+ {
+ parent.setBeanMethod(new Method());
+ child = parent.getBeanMethod();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(RemoveMethod dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("retain-if-exception"))
+ {
+ dd.setRetainIfException(Boolean.parseBoolean(getValue(localName, value)));
+ }
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Relationships relationships, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("ejb-relation"))
+ {
+ child = new EjbRelation();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("ejb-relationship-role"))
+ {
+ child = new EjbRelationshipRole();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbRelationshipRole parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("cascade-delete"))
+ {
+ parent.setCascadeDelete(true);
+ }
+ else if (localName.equals("relationship-role-source"))
+ {
+ child = new RelationshipRoleSource();
+ }
+ else if (localName.equals("cmr-field"))
+ {
+ child = new CmrField();
+ }
+
+ return child;
+ }
+
+ public Object newChild(Interceptors interceptors, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("interceptor"))
+ {
+ return new Interceptor();
+ }
+
+ return child;
+ }
+
+ public Object newChild(Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ return child;
+
+ if (localName.equals("around-invoke"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("post-construct"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("post-activate"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ return new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(AssemblyDescriptor relationships, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("security-role"))
+ {
+ child = new SecurityRole();
+ }
+ else if (localName.equals("method-permission"))
+ {
+ child = new MethodPermission();
+ }
+ if (localName.equals("container-transaction"))
+ {
+ child = new ContainerTransaction();
+ }
+ else if (localName.equals("inject"))
+ {
+ child = new Inject();
+ }
+ else if (localName.equals("exclude-list"))
+ {
+ child = new ExcludeList();
+ }
+ else if (localName.equals("application-exception"))
+ {
+ child = new ApplicationException();
+ }
+ else if (localName.equals("interceptor-binding"))
+ {
+ child = new InterceptorBinding();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("unchecked"))
+ {
+ permission.setUnchecked(true);
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(ExcludeList list, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(InitList list, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ public Object newChild(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method-params"))
+ {
+ method.setHasParameters();
+ }
+
+ return child;
+ }
+
+ public Object newChild(InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("interceptor-order"))
+ {
+ child = new InterceptorOrder();
+ }
+ else if (localName.equals("exclude-default-interceptors"))
+ {
+ child = new ExcludeDefaultInterceptors();
+ }
+ else if (localName.equals("exclude-class-interceptors"))
+ {
+ child = new ExcludeClassInterceptors();
+ }
+ else if (localName.equals("method-params"))
+ {
+ binding.setHasParameters();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, ActivationConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setActivationConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnvEntry(entry);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, ResourceRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(envRef);
+ }
+
+ public void addChild(MessageDrivenBean parent, ServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(envRef);
+ }
+
+ public void addChild(MessageDrivenBean parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestinationRef(ref);
+ }
+
+ public void addChild(ActivationConfig parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addActivationConfigProperty(property);
+ }
+
+ public void addChild(EjbJarDD parent, EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setEnterpriseBeans(ejbs);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnterpriseBean(ejb);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, SecurityRoleRef roleRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addSecurityRoleRef(roleRef);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, SecurityIdentity si, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setSecurityIdentity(si);
+ }
+
+ public void addChild(SecurityIdentity parent, RunAs runAs, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setRunAs(runAs);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, PersistenceContextRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceContextRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceUnitRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestinationRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnvEntry(entry);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, ResourceRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, ServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (localName.equals("around-invoke"))
+ {
+ parent.setAroundInvoke(method);
+ }
+ else if (localName.equals("post-construct"))
+ {
+ parent.setPostConstruct(method);
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ parent.setPreDestroy(method);
+ }
+ else if (localName.equals("post-activate"))
+ {
+ parent.setPostActivate(method);
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ parent.setPrePassivate(method);
+ }
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EntityEnterpriseBean parent, CmpField field, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addCmpField(field);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EntityEnterpriseBean parent, Query query, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addQuery(query);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbJarDD parent, Relationships relationships, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setRelationships(relationships);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Relationships parent, EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRelation(relation);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbRelation parent, EjbRelationshipRole role, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRelationshipRole(role);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbRelationshipRole parent, RelationshipRoleSource source, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setRelationshipRoleSource(source);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbRelationshipRole parent, CmrField field, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setCmrField(field);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbJarDD parent, AssemblyDescriptor descriptor, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setAssemblyDescriptor(descriptor);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, SecurityRole role, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addSecurityRole(role);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethodPermission(permission);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, ExcludeList list, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setExcludeList(list);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, ApplicationException exception, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addApplicationException(exception);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, InitList list, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setInitList(list);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addInject(inject);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addInterceptorBinding(binding);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(ExcludeList parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InitList parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MethodPermission parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Inject parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ public void addChild(EjbJarDD parent, Interceptors interceptors, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setInterceptors(interceptors);
+ }
+
+ public void addChild(Interceptors parent, Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addInterceptor(interceptor);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, PersistenceContextRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceContextRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceUnitRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestinationRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnvEntry(entry);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(ref);
+ }
+
+ public void addChild(Interceptor parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (localName.equals("around-invoke"))
+ {
+ parent.setAroundInvoke(method);
+ }
+ else if (localName.equals("post-construct"))
+ {
+ parent.setPostConstruct(method);
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ parent.setPreDestroy(method);
+ }
+ else if (localName.equals("post-activate"))
+ {
+ parent.setPostActivate(method);
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ parent.setPrePassivate(method);
+ }
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InterceptorBinding parent, InterceptorOrder order, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setOrderedInterceptorClasses(order);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InterceptorBinding parent, ExcludeDefaultInterceptors exclude, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setExcludeDefaultInterceptors(true);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InterceptorBinding parent, ExcludeClassInterceptors exclude, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setExcludeClassInterceptors(true);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(ContainerTransaction parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, MessageDrivenDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMessageDrivenDestination(destination);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (localName.equals("around-invoke"))
+ {
+ parent.setAroundInvoke(method);
+ }
+ else if (localName.equals("post-construct"))
+ {
+ parent.setPostConstruct(method);
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ parent.setPreDestroy(method);
+ }
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addContainerTransaction(transaction);
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("display-name"))
+ {
+ dd.setDisplayName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("activation-config-property-name"))
+ {
+ property.setName(getValue(localName, value));
+ }
+ else if (localName.equals("activation-config-property-value"))
+ {
+ property.setValue(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ private boolean isEjbParentName(EnterpriseBean ejb, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ ejb.setEjbName(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("home"))
+ {
+ ejb.setHome(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("remote") || localName.equals("business-remote"))
+ {
+ ejb.setRemote(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("local-home"))
+ {
+ ejb.setLocalHome(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("local") || localName.equals("business-local"))
+ {
+ ejb.setLocal(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("ejb-class"))
+ {
+ ejb.setEjbClass(getValue(localName, value));
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MessageDrivenBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (!isEjbParentName(ejb, localName, value))
+ {
+ if (localName.equals("acknowledge-mode"))
+ {
+ ejb.setAcknowledgeMode(getValue(localName, value));
+ }
+ else if (localName.equals("transaction-type"))
+ {
+ ejb.setTransactionType(getValue(localName, value));
+ }
+ else if (localName.equals("messaging-type"))
+ {
+ ejb.setMessagingType(getValue(localName, value));
+ }
+ else if (localName.equals("message-destination-type"))
+ {
+ MessageDrivenDestination destination = ejb.getMessageDrivenDestination();
+ if (destination == null)
+ {
+ destination = new MessageDrivenDestination();
+ ejb.setMessageDrivenDestination(destination);
+ }
+
+ destination.setDestinationType(getValue(localName, value));
+ }
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MessageDrivenDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("destination-type"))
+ {
+ destination.setDestinationType(getValue(localName, value));
+ }
+ else if (localName.equals("subscription-durability"))
+ {
+ destination.setSubscriptionDurability(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SessionEnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (!isEjbParentName(ejb, localName, value))
+ {
+ if (localName.equals("session-type"))
+ {
+ ejb.setSessionType(getValue(localName, value));
+ }
+ else if (localName.equals("transaction-type"))
+ {
+ ejb.setTransactionManagementType(getValue(localName, value));
+ }
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(ApplicationException exception, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("exception-class"))
+ {
+ exception.setExceptionClass(getValue(localName, value));
+ }
+ else if (localName.equals("rollback"))
+ {
+ exception.setRollback(Boolean.valueOf(getValue(localName, value)));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EntityEnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (!isEjbParentName(ejb, localName, value))
+ {
+ if (localName.equals("persistence-type"))
+ {
+ ejb.setPersistenceType(getValue(localName, value));
+ }
+ }
+ }
+
+ /**
+ * <!ELEMENT security-role-ref (rolename,role-link))>
+ */
+ public void setValue(SecurityRoleRef parent, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+ parent.setRoleName(value);
+ }
+ else if (localName.equals("role-link"))
+ {
+ parent.setRoleLink(value);
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SecurityIdentity si, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("use-caller-identity"))
+ {
+ si.setUseCallerIdentity(true);
+ }
+ }
+
+ public void setValue(Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("interceptor-class"))
+ {
+ interceptor.setInterceptorClass(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-relation-name"))
+ {
+ relation.setEjbRelationName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbRelationshipRole role, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-relationship-role-name"))
+ {
+ role.setEjbRelationshipRoleName(getValue(localName, value));
+ }
+ else if (localName.equals("multiplicity"))
+ {
+ role.setMultiplicity(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(RelationshipRoleSource source, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ source.setEjbName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(CmrField field, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("cmr-field-name"))
+ {
+ field.setCmrFieldName(getValue(localName, value));
+ }
+ else if (localName.equals("cmr-field-type"))
+ {
+ field.setCmrFieldType(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SecurityRole role, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+ role.setRoleName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+ permission.addRoleName(getValue(localName, value));
+ }
+ else if (localName.equals("unchecked"))
+ {
+ permission.setUnchecked(true);
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("trans-attribute"))
+ {
+ transaction.setTransAttribute(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ method.setEjbName(getValue(localName, value));
+ }
+ else if (localName.equals("method-name"))
+ {
+ method.setMethodName(getValue(localName, value));
+ }
+ else if (localName.equals("method-param"))
+ {
+ method.addMethodParam(getValue(localName, value));
+ }
+ else if (localName.equals("lifecycle-callback-method"))
+ {
+ method.setMethodName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("jndi-name"))
+ {
+ inject.setJndiName(getValue(localName, value));
+ }
+ }
+
+ public void setValue(InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ binding.setEjbName(getValue(localName, value));
+ }
+ else if (localName.equals("interceptor-class"))
+ {
+ binding.addInterceptorClass(getValue(localName, value));
+ }
+ else if (localName.equals("method-name"))
+ {
+ binding.setMethodName(getValue(localName, value));
+ }
+ else if (localName.equals("method-param"))
+ {
+ binding.addMethodParam(getValue(localName, value));
+ }
+ else if (localName.equals("exclude-default-interceptors"))
+ {
+ binding.setExcludeDefaultInterceptors(true);
+ }
+ else if (localName.equals("exclude-class-interceptors"))
+ {
+ binding.setExcludeClassInterceptors(true);
+ }
+ }
+
+ public void setValue(InterceptorOrder order, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("interceptor-class"))
+ {
+ order.addInterceptorClass(getValue(localName, value));
+ }
+ }
+
+ // may want to run StringPropertyReplacer on the whole descriptor at once
+ protected String getValue(String name, String value)
+ {
+ if (value.contains("${"))
+ {
+ String replacement = StringPropertyReplacer.replaceProperties(value);
+ if (replacement != null)
+ value = replacement;
+ }
+ return value;
+ }
+}
Added: tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java
===================================================================
--- tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java (rev 0)
+++ tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java 2010-03-24 16:07:27 UTC (rev 102893)
@@ -0,0 +1,352 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.metamodel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.InjectionTarget;
+import org.jboss.metamodel.descriptor.JndiRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+
+/**
+ * Represents EJB elements of the ejb-jar.xml deployment descriptor for the 1.4
+ * schema
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * ejbs.setCurrentEjbName(value); } else if
+ * (localName.equals("jndi-name")){ ejbs.setJndiName(value);
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public class EnterpriseBeans
+{
+ private static final Logger log = Logger.getLogger(EnterpriseBeans.class);
+
+ private HashMap<String, EnterpriseBean> enterpriseBeans = new HashMap();
+
+ private EnterpriseBean currentEjb;
+
+ public void setPoolConfig(PoolConfig config)
+ {
+ currentEjb.setPoolConfig(config);
+ }
+
+ public void setDefaultActivationConfig(ActivationConfig config)
+ {
+ ((MessageDrivenBean)currentEjb).setDefaultActivationConfig(config);
+ }
+
+ public void setCacheConfig(CacheConfig config)
+ {
+ ((SessionEnterpriseBean)currentEjb).setCacheConfig(config);
+ }
+
+ public void setClustered(String clustered)
+ {
+ ((SessionEnterpriseBean)currentEjb).setClustered(clustered);
+ }
+
+ public void setConcurrent(String concurrent)
+ {
+ ((SessionEnterpriseBean)currentEjb).setConcurrent(concurrent);
+ }
+
+ public void addJndiRef(JndiRef ref)
+ {
+ currentEjb.addJndiRef(ref);
+ }
+
+ public void addXmlAnnotation(XmlAnnotation xmlAnnotation)
+ {
+ currentEjb.addXmlAnnotation(xmlAnnotation);
+ }
+
+ public void addRemoteBinding(RemoteBinding binding)
+ {
+ currentEjb.addRemoteBinding(binding);
+ }
+
+ public void addIgnoreDependency(InjectionTarget ignore)
+ {
+ currentEjb.addIgnoreDependency(ignore);
+ }
+
+ public void addResourceRef(ResourceRef ref)
+ {
+ currentEjb.mergeResourceRef(ref);
+ }
+
+ public void addResourceEnvRef(ResourceEnvRef ref)
+ {
+ currentEjb.mergeResourceEnvRef(ref);
+ }
+
+ public void addMessageDestinationRef(MessageDestinationRef ref)
+ {
+ currentEjb.mergeMessageDestinationRef(ref);
+ }
+
+ public void addServiceRef(ServiceRefMetaData ref)
+ {
+ currentEjb.addServiceRef(ref);
+ }
+
+ public void setMethodAttributes(MethodAttributes attributes)
+ {
+ currentEjb.setMethodAttributes(attributes);
+ }
+
+ public void setCurrentEjbName(String currentEjbName, Class ejbClass)
+ {
+ currentEjb = createEjbByEjbName(currentEjbName, ejbClass);
+ }
+
+ public void addDependency(String depends)
+ {
+ currentEjb.addDependency(depends);
+ }
+
+ public void updateEjbRef(EjbRef ref)
+ {
+ currentEjb.updateEjbRef(ref);
+ }
+
+ public void updateEjbLocalRef(EjbLocalRef ref)
+ {
+ currentEjb.updateEjbLocalRef(ref);
+ }
+
+ public void updateResourceRef(ResourceRef ref)
+ {
+ currentEjb.updateResourceRef(ref);
+ }
+
+ public void updateResourceEnvRef(ResourceEnvRef ref)
+ {
+ currentEjb.updateResourceEnvRef(ref);
+ }
+
+ public void updateMessageDestinationRef(MessageDestinationRef ref)
+ {
+ currentEjb.updateMessageDestinationRef(ref);
+ }
+
+ public void setResourceAdapterName(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setResourceAdaptorName(name);
+ }
+
+ public void setDestinationJndiName(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setDestinationJndiName(name);
+ }
+
+ public void setMdbUser(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setMdbUser(name);
+ }
+
+ public void setMdbPassword(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setMdbPassword(name);
+ }
+
+ public void setMdbSubscriptionId(String id)
+ {
+ ((MessageDrivenBean)currentEjb).setMdbSubscriptionId(id);
+ }
+
+ public void setAopDomainName(String aopDomainName)
+ {
+ currentEjb.setAopDomainName(aopDomainName);
+ }
+
+ public void setRunAsPrincipal(String principal)
+ {
+ currentEjb.setRunAsPrincipal(principal);
+ }
+
+ public void setClusterConfig(ClusterConfig config)
+ {
+ ((SessionEnterpriseBean)currentEjb).setClusterConfig(config);
+ }
+
+ public void setCallByValue(boolean callByValue)
+ {
+ currentEjb.setCallByValue(callByValue);
+ }
+
+ public void setJndiName(String jndiName)
+ {
+ currentEjb.setJndiName(jndiName);
+ }
+
+ public void setHomeJndiName(String homeJndiName)
+ {
+ currentEjb.setHomeJndiName(homeJndiName);
+ }
+
+ public void setSecurityDomain(String securityDomain)
+ {
+ currentEjb.setSecurityDomain(securityDomain);
+ }
+
+ public void setLocalJndiName(String jndiName)
+ {
+ currentEjb.setLocalJndiName(jndiName);
+ }
+
+ public void setLocalHomeJndiName(String homeJndiName)
+ {
+ currentEjb.setLocalHomeJndiName(homeJndiName);
+ }
+
+ public EnterpriseBean createEjbByEjbName(String ejbName, Class ejbClass)
+ {
+ EnterpriseBean ejb = (EnterpriseBean) enterpriseBeans.get(ejbName);
+ if (ejb != null)
+ return ejb;
+
+ try
+ {
+ ejb = (EnterpriseBean)ejbClass.newInstance();
+ ejb.setEjbName(ejbName);
+ enterpriseBeans.put(ejbName, ejb);
+ }
+ catch (Exception e){}
+
+ return ejb;
+ }
+
+ public EnterpriseBean findEjbByEjbName(String ejbName)
+ {
+ return enterpriseBeans.get(ejbName);
+ }
+
+ public List<EnterpriseBean> findEjbsByClass(String className)
+ {
+ ArrayList<EnterpriseBean> result = new ArrayList<EnterpriseBean>();
+
+ Iterator ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
+ String ejbClassName = ejb.getEjbClass();
+ if (ejbClassName != null && ejbClassName.equals(className))
+ result.add(ejb);
+ }
+ return result;
+ }
+
+ public List<EnterpriseBean> findEjbs()
+ {
+ ArrayList<EnterpriseBean> result = new ArrayList<EnterpriseBean>(enterpriseBeans.values().size());
+
+ Iterator<EnterpriseBean> ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ result.add(ejbs.next());
+ }
+ return result;
+ }
+
+ public EnterpriseBean findEjbByRemote(String remote)
+ {
+ Iterator ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
+ if (ejb.getRemote() != null && ejb.getRemote().equals(remote))
+ return ejb;
+ }
+ return null;
+ }
+
+ public EnterpriseBean findEjbByLocal(String local)
+ {
+ Iterator ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
+ if (ejb.getLocal() != null && ejb.getLocal().equals(local))
+ return ejb;
+ }
+ return null;
+ }
+
+ public Collection<EnterpriseBean> getEnterpriseBeans()
+ {
+ return enterpriseBeans.values();
+ }
+
+/* public void setEnterpriseBeans(List enterpriseBeans)
+ {
+ this.enterpriseBeans = enterpriseBeans;
+ }*/
+
+ public void addEnterpriseBean(EnterpriseBean ejb)
+ {
+ enterpriseBeans.put(ejb.getEjbName(), ejb);
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append("[");
+ sb.append("enterpriseBeans=").append(enterpriseBeans);
+ sb.append("]");
+ return sb.toString();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ return true;
+ if (!(o instanceof EnterpriseBeans))
+ return false;
+
+ final EnterpriseBeans ejbs = (EnterpriseBeans) o;
+
+ if (enterpriseBeans != null ? !enterpriseBeans
+ .equals(ejbs.enterpriseBeans) : ejbs.enterpriseBeans != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (enterpriseBeans != null ? enterpriseBeans.hashCode() : 0);
+ // result = 29 * result + (version != null ? version.hashCode() : 0);
+ return result;
+ }
+}
Added: tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java
===================================================================
--- tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java (rev 0)
+++ tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java 2010-03-24 16:07:27 UTC (rev 102893)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.metamodel;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.JndiRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.PersistenceContextRef;
+import org.jboss.metamodel.descriptor.PersistenceUnitRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 69712 $
+ */
+public interface Injectable
+{
+
+ Collection<EjbLocalRef> getEjbLocalRefs();
+
+ Collection<EjbRef> getEjbRefs();
+
+ Collection<ResourceEnvRef> getResourceEnvRefs();
+
+ Collection<ResourceRef> getResourceRefs();
+
+ Collection<ServiceRefMetaData> getServiceRefs();
+
+ Collection<MessageDestinationRef> getMessageDestinationRefs();
+
+ List<PersistenceUnitRef> getPersistenceUnitRefs();
+
+ List<PersistenceContextRef> getPersistenceContextRefs();
+
+ Collection<JndiRef> getJndiRefs();
+}
\ No newline at end of file
Added: tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
===================================================================
--- tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java (rev 0)
+++ tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java 2010-03-24 16:07:27 UTC (rev 102893)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.metamodel;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * A JBossXB object factory for parsing JBoss application client descriptor files.
+ *
+ * http://www.jboss.org/j2ee/dtd/jboss-client_5_0.dtd
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JBossClientDDObjectFactory extends DDObjectFactory
+{
+ private static final Logger log = Logger.getLogger(JBossClientDDObjectFactory.class);
+
+ private ApplicationClientDD dd;
+
+ public static ApplicationClientDD parse(URL ddResource, ApplicationClientDD dd) throws JBossXBException, IOException
+ {
+ // TODO: how to properly fix this
+ if (dd == null)
+ dd = new ApplicationClientDD();
+
+ if (ddResource == null)
+ return dd;
+
+ log.debug("found jboss-client.xml " + ddResource);
+
+ JBossClientDDObjectFactory factory = new JBossClientDDObjectFactory(dd);
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setEntityResolver(new JBossEntityResolver());
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setValidation(true);
+
+ dd = (ApplicationClientDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
+
+ return dd;
+ }
+
+ public JBossClientDDObjectFactory(ApplicationClientDD dd)
+ {
+ // JBossXB will otherwise fail later on
+ if (dd == null)
+ throw new NullPointerException("dd is null");
+
+ this.dd = dd;
+ }
+
+ public void addChild(ApplicationClientDD parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateEjbRef(ref);
+ }
+
+ public void addChild(ApplicationClientDD parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateMessageDestinationRef(ref);
+ }
+
+ public void addChild(ApplicationClientDD parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.addServiceRef(ref);
+ }
+
+ public void addChild(ApplicationClientDD dd, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateResourceEnvRef(envRef);
+ }
+
+ public void addChild(ApplicationClientDD parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateResourceRef(ref);
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext navigator, String uri, String name)
+ {
+ return root;
+ }
+
+ public Object newChild(ApplicationClientDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ child = newEnvRefGroupChild(localName);
+ if (child != null)
+ return child;
+
+ // space for more
+
+ return child;
+ }
+
+ public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ return dd;
+ }
+
+ public void setValue(ApplicationClientDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("jndi-name"))
+ dd.setJndiName(value);
+ else if (localName.equals("depends"))
+ dd.addDependency(value);
+ }
+}
Added: tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
===================================================================
--- tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java (rev 0)
+++ tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java 2010-03-24 16:07:27 UTC (rev 102893)
@@ -0,0 +1,1116 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.metamodel;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.InjectionTarget;
+import org.jboss.metamodel.descriptor.JndiRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.NameValuePair;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.security.SecurityRoleMetaData;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.jboss.util.StringPropertyReplacer;
+import org.xml.sax.Attributes;
+
+/**
+ * Represents the jboss.xml deployment descriptor for the 2.1 schema
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @author Anil.Saldhana at jboss.com
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+ public class JBossDDObjectFactory extends DDObjectFactory
+{
+ private static final Logger log = Logger.getLogger(JBossDDObjectFactory.class);
+
+ private EjbJarDD dd;
+ private Class ejbClass;
+
+ public static EjbJarDD parse(URL ddResource, EjbJarDD dd) throws JBossXBException, IOException
+ {
+ ObjectModelFactory factory = null;
+ Unmarshaller unmarshaller = null;
+
+ if (ddResource != null)
+ {
+ log.debug("found jboss.xml " + ddResource);
+
+ if (dd == null)
+ dd = new EjbJarDD();
+
+ factory = new JBossDDObjectFactory(dd);
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setEntityResolver(new JBossEntityResolver());
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setValidation(true);
+
+ dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
+ }
+
+ return dd;
+ }
+
+ public JBossDDObjectFactory(EjbJarDD dd)
+ {
+ super();
+ this.dd = dd;
+ }
+
+ /**
+ * Return the root.
+ */
+ public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ return dd;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
+ {
+ return root;
+ }
+
+ // Methods discovered by introspection
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("enterprise-beans"))
+ {
+ child = dd.getEnterpriseBeans();
+ if (child == null)
+ {
+ dd.setEnterpriseBeans(new EnterpriseBeans());
+ child = dd.getEnterpriseBeans();
+ }
+ }
+ else if (localName.equals("assembly-descriptor"))
+ {
+ child = dd.getAssemblyDescriptor();
+ if (child == null)
+ {
+ dd.setAssemblyDescriptor(new AssemblyDescriptor());
+ child = dd.getAssemblyDescriptor();
+ }
+ }
+ else if (localName.equals("resource-manager"))
+ {
+ child = new ResourceManager();
+ }
+ else if (localName.equals("webservices"))
+ {
+ dd.setWebservices(new Webservices());
+ child = dd.getWebservices();
+ }
+
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ return child;
+
+ if (localName.equals("current-message"))
+ {
+ child = new CurrentMessage();
+ }
+ else if (localName.equals("message-properties"))
+ {
+ child = new MessageProperties();
+ }
+ else if (localName.equals("producer"))
+ {
+ child = new Producer(false);
+ }
+ else if (localName.equals("local-producer"))
+ {
+ child = new Producer(true);
+ }
+ else if (localName.equals("annotation"))
+ {
+ child = new XmlAnnotation();
+ }
+ else if (localName.equals("ignore-dependency"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("remote-binding"))
+ {
+ child = new RemoteBinding();
+ }
+ else if (localName.equals("pool-config"))
+ {
+ child = new PoolConfig();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Service service, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ return child;
+
+ if (localName.equals("ignore-dependency"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("annotation"))
+ {
+ child = new XmlAnnotation();
+ }
+ else if (localName.equals("remote-binding"))
+ {
+ child = new RemoteBinding();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(CurrentMessage message, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(MessageProperties properties, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(MethodAttributes attributes, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(AssemblyDescriptor descriptor, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("message-destination"))
+ {
+ child = new MessageDestination();
+ }
+ if (localName.equals("security-role"))
+ {
+ child = new SecurityRoleMetaData("dummy_to_be_replaced_in_setValue");
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ {
+ return child;
+ }
+
+ if (localName.equals("session"))
+ {
+ ejbClass = SessionEnterpriseBean.class;
+ child = ejbs;
+ }
+ else if (localName.equals("message-driven"))
+ {
+ ejbClass = MessageDrivenBean.class;
+ child = ejbs;
+ }
+ else if (localName.equals("service"))
+ {
+ child = new Service();
+ }
+ else if (localName.equals("consumer"))
+ {
+ child = new Consumer();
+ }
+ else if (localName.equals("method-attributes"))
+ {
+ child = new MethodAttributes();
+ }
+ else if (localName.equals("annotation"))
+ {
+ child = new XmlAnnotation();
+ }
+ else if (localName.equals("ignore-dependency"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("cluster-config"))
+ {
+ child = new ClusterConfig();
+ }
+ else if (localName.equals("remote-binding"))
+ {
+ child = new RemoteBinding();
+ }
+ else if (localName.equals("cache-config"))
+ {
+ child = new CacheConfig();
+ }
+ else if (localName.equals("pool-config"))
+ {
+ child = new PoolConfig();
+ }
+ else if (localName.equals("default-activation-config"))
+ {
+ child = new ActivationConfig();
+ }
+
+ return child;
+ }
+
+ public Object newChild(ActivationConfig parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("default-activation-config-property"))
+ {
+ child = new NameValuePair();
+ }
+
+ return child;
+ }
+
+ public Object newChild(XmlAnnotation parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("injection-target"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("property"))
+ {
+ child = new NameValuePair();
+ }
+
+ return child;
+ }
+
+ public void addChild(XmlAnnotation parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addProperty(property);
+ }
+
+ public void addChild(XmlAnnotation parent, InjectionTarget injectionTarget, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setInjectionTarget(injectionTarget);
+ }
+
+ public void addChild(EnterpriseBeans parent, ActivationConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setDefaultActivationConfig(config);
+ }
+
+ public void addChild(ActivationConfig parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addActivationConfigProperty(property);
+ }
+
+ public void addChild(Consumer parent, Producer producer, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (producer.isLocal())
+ parent.addLocalProducer(producer);
+ else parent.addProducer(producer);
+ }
+
+ public void addChild(Consumer parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addRemoteBinding(binding);
+ }
+
+ public void addChild(AssemblyDescriptor parent, MessageDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestination(destination);
+ }
+
+ public void addChild(AssemblyDescriptor parent, SecurityRoleMetaData srm, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addSecurityRoleMetaData(srm);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, CacheConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setCacheConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setPoolConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, MethodAttributes attributes, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMethodAttributes(attributes);
+ }
+
+ public void addChild(EnterpriseBeans parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addRemoteBinding(binding);
+ }
+
+ public void addChild(EnterpriseBeans parent, InjectionTarget ignoreDependency, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addIgnoreDependency(ignoreDependency);
+ }
+
+ public void addChild(EnterpriseBeans parent, XmlAnnotation xmlAnnotation, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addXmlAnnotation(xmlAnnotation);
+ }
+
+ public void addChild(MethodAttributes parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ public void addChild(Consumer parent, CurrentMessage message, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setCurrentMessage(message);
+ }
+
+ public void addChild(Consumer parent, PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setPoolConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, MessageProperties message, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMessageProperties(message);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(CurrentMessage parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageProperties parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, Service service, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnterpriseBean(service);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addRemoteBinding(binding);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addJndiRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addJndiRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnterpriseBean(consumer);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addJndiRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbJarDD parent, ResourceManager manager, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceManager(manager);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ClusterConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setClusterConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateMessageDestinationRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateResourceEnvRef(ref);
+ }
+
+ public void setValue(XmlAnnotation xmlAnnotation, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("annotation-class"))
+ {
+ xmlAnnotation.setAnnotationClass(getValue(localName, value));
+ }
+ else if (localName.equals("annotation-implementation-class"))
+ {
+ xmlAnnotation.setAnnotationImplementationClass(getValue(localName, value));
+ }
+ }
+
+ public void setValue(NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("activation-config-property-name") || localName.equals("message-driven-config-property-name") || localName.equals("property-name"))
+ {
+ property.setName(getValue(localName, value));
+ }
+ else if (localName.equals("activation-config-property-value") || localName.equals("message-driven-config-property-value") || localName.equals("property-value"))
+ {
+ property.setValue(getValue(localName, value));
+ }
+ }
+
+ public void setValue(ResourceManager manager, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("res-name"))
+ {
+ manager.setResourceName(getValue(localName, value));
+ }
+ else if (localName.equals("res-jndi-name"))
+ {
+ manager.setResourceJndiName(getValue(localName, value));
+ }
+ }
+
+ public void setValue(MessageDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("message-destination-name"))
+ {
+ destination.setMessageDestinationName(getValue(localName, value));
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ destination.setJndiName(getValue(localName, value));
+ }
+ }
+
+ public void setValue(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ ejbs.setCurrentEjbName(value, ejbClass);
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ ejbs.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("home-jndi-name"))
+ {
+ ejbs.setHomeJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-jndi-name"))
+ {
+ ejbs.setLocalJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-home-jndi-name"))
+ {
+ ejbs.setLocalHomeJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("security-domain"))
+ {
+ ejbs.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("depends"))
+ {
+ ejbs.addDependency(getValue(localName, value));
+ }
+ else if (localName.equals("run-as-principal"))
+ {
+ ejbs.setRunAsPrincipal(getValue(localName, value));
+ }
+ else if (localName.equals("aop-domain-name"))
+ {
+ ejbs.setAopDomainName(getValue(localName, value));
+ }
+ else if (localName.equals("resource-adapter-name"))
+ {
+ ejbs.setResourceAdapterName(getValue(localName, value));
+ }
+ else if (localName.equals("destination-jndi-name"))
+ {
+ ejbs.setDestinationJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("mdb-user"))
+ {
+ ejbs.setMdbUser(getValue(localName, value));
+ }
+ else if (localName.equals("mdb-passwd"))
+ {
+ ejbs.setMdbPassword(getValue(localName, value));
+ }
+ else if (localName.equals("mdb-subscription-id"))
+ {
+ ejbs.setMdbSubscriptionId(getValue(localName, value));
+ }
+ else if (localName.equals("clustered"))
+ {
+ ejbs.setClustered(getValue(localName, value));
+ }
+ else if (localName.equals("concurrent"))
+ {
+ ejbs.setConcurrent(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Service service, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ service.setEjbName(getValue(localName, value));
+ }
+ if (localName.equals("object-name"))
+ {
+ service.setObjectName(getValue(localName, value));
+ }
+ else if (localName.equals("ejb-class"))
+ {
+ service.setEjbClass(getValue(localName, value));
+ }
+ if (localName.equals("xmbean"))
+ {
+ service.setXMBean(getValue(localName, value));
+ }
+ else if (localName.equals("local"))
+ {
+ service.setLocal(getValue(localName, value));
+ }
+ else if (localName.equals("remote"))
+ {
+ service.setRemote(getValue(localName, value));
+ }
+ else if (localName.equals("management"))
+ {
+ service.setManagement(getValue(localName, value));
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ service.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-jndi-name"))
+ {
+ service.setLocalJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("security-domain"))
+ {
+ service.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("aop-domain-name"))
+ {
+ service.setAopDomainName(getValue(localName, value));
+ }
+ else if (localName.equals("depends"))
+ {
+ service.addDependency(getValue(localName, value));
+ }
+ }
+
+ public void setValue(Webservices webservices, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("context-root"))
+ {
+ webservices.setContextRoot(value);
+ }
+ else if (localName.equals("webservice-description-name"))
+ {
+ webservices.setDescriptionName(value);
+ }
+ else if (localName.equals("config-name"))
+ {
+ webservices.setConfigName(value);
+ }
+ else if (localName.equals("config-file"))
+ {
+ webservices.setConfigFile(value);
+ }
+ else if(localName.equals("wsdl-publish-location"))
+ {
+ webservices.setWsdlPublishLocation(value);
+ }
+
+ }
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("message-destination"))
+ {
+ consumer.setDestination(getValue(localName, value));
+ }
+ else if (localName.equals("message-destination-type"))
+ {
+ consumer.setDestinationType(getValue(localName, value));
+ }
+ else if (localName.equals("ejb-class"))
+ {
+ consumer.setEjbClass(getValue(localName, value));
+ consumer.setEjbName(getValue(localName, value));
+ }
+ else if (localName.equals("local"))
+ {
+ consumer.setLocal(getValue(localName, value));
+ }
+ else if (localName.equals("remote"))
+ {
+ consumer.setRemote(getValue(localName, value));
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ consumer.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-jndi-name"))
+ {
+ consumer.setLocalJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("security-domain"))
+ {
+ consumer.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("run-as-principal"))
+ {
+ consumer.setRunAsPrincipal(getValue(localName, value));
+ }
+ else if (localName.equals("aop-domain-name"))
+ {
+ consumer.setAopDomainName(getValue(localName, value));
+ }
+ else if (localName.equals("depends"))
+ {
+ consumer.addDependency(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("jndi-name"))
+ {
+ binding.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("client-bind-url"))
+ {
+ binding.setClientBindUrl(getValue(localName, value));
+ }
+ else if (localName.equals("proxy-factory"))
+ {
+ binding.setProxyFactory(getValue(localName, value));
+ }
+ else if (localName.equals("interceptor-stack"))
+ {
+ binding.setInterceptorStack(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MessageProperties properties, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("delivery"))
+ {
+ properties.setDelivery(getValue(localName, value));
+ }
+ else if (localName.equals("class"))
+ {
+ properties.setClassName(getValue(localName, value));
+ }
+ else if (localName.equals("priority"))
+ {
+ properties.setPriority(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(ClusterConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("load-balance-policy"))
+ {
+ config.setLoadBalancePolicy(getValue(localName, value));
+ }
+ else if (localName.equals("partition-name"))
+ {
+ config.setPartition(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(CacheConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("cache-class"))
+ {
+ config.setCacheClass(getValue(localName, value));
+ }
+ else if (localName.equals("cache-max-size"))
+ {
+ config.setMaxSize(getValue(localName, value));
+ }
+ else if (localName.equals("idle-timeout-seconds"))
+ {
+ config.setIdleTimeoutSeconds(getValue(localName, value));
+ }
+ else if (localName.equals("remove-timeout-seconds"))
+ {
+ config.setRemoveTimeoutSeconds(getValue(localName, value));
+ }
+ else if (localName.equals("cache-name"))
+ {
+ config.setName(getValue(localName, value));
+ }
+ else if (localName.equals("persistence-manager"))
+ {
+ config.setPersistenceManager(getValue(localName, value));
+ }
+ else if (localName.equals("replication-is-passivation"))
+ {
+ config.setReplicationIsPassivation(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("pool-class"))
+ {
+ config.setPoolClass(getValue(localName, value));
+ }
+ else if (localName.equals("pool-max-size"))
+ {
+ config.setMaxSize(getValue(localName, value));
+ }
+ else if (localName.equals("pool-timeout"))
+ {
+ config.setTimeout(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("method-name"))
+ {
+ method.setMethodName(getValue(localName, value));
+ }
+ else if (localName.equals("transaction-timeout"))
+ {
+ method.setTransactionTimeout(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("security-domain"))
+ {
+ dd.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("unauthenticated-principal"))
+ {
+ dd.setUnauthenticatedPrincipal(getValue(localName, value));
+ }
+ else if (localName.equals("jmx-name"))
+ {
+ dd.setJmxName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Producer producer, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("class"))
+ {
+ producer.setClassName(getValue(localName, value));
+ }
+ else if (localName.equals("connection-factory"))
+ {
+ producer.setConnectionFactory(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SecurityRoleMetaData srm, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+// FIXME: NYI
+// srm.setRoleName(getValue(localName, value));
+ throw new RuntimeException("NYI");
+ }
+ else if (localName.equals("principal-name"))
+ {
+ srm.addPrincipalName(getValue(localName, value));
+ }
+ }
+
+ // may want to run StringPropertyReplacer on the whole descriptor at once
+ protected String getValue(String name, String value)
+ {
+ if (value.contains("${"))
+ {
+ String replacement = StringPropertyReplacer.replaceProperties(value);
+ if (replacement != null)
+ value = replacement;
+ }
+ return value;
+ }
+}
Added: tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
===================================================================
--- tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java (rev 0)
+++ tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java 2010-03-24 16:07:27 UTC (rev 102893)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.injection;
+
+// $Id: WebServiceRefHandler.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+
+/**
+ * Handle @WebServiceRef annotations
+ *
+ * @author Thomas.Diesler at jboss.com
+ */
+public class WebServiceRefHandler implements InjectionHandler
+{
+ private static final Logger log = Logger.getLogger(WebServiceRefHandler.class);
+ private Map<String, ServiceRefMetaData> srefMap = new HashMap<String, ServiceRefMetaData>();
+
+ public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ {
+ if (xml == null) return;
+ if (xml.getServiceRefs() == null) return;
+ for (ServiceRefMetaData sref : xml.getServiceRefs())
+ {
+ log.debug("@WebServiceRef override: " + sref);
+ if (srefMap.get(sref.getServiceRefName()) != null)
+ throw new IllegalStateException ("Duplicate <service-ref-name> in " + sref);
+
+ srefMap.put(sref.getServiceRefName(), sref);
+ }
+ }
+
+ public void handleClassAnnotations(Class type, InjectionContainer container)
+ {
+ WebServiceRef wsref = container.getAnnotation(WebServiceRef.class, type);
+ if (wsref != null)
+ {
+ bindRefOnType(type, container, wsref);
+ }
+
+ WebServiceRefs refs = container.getAnnotation(WebServiceRefs.class, type);
+ if (refs != null)
+ {
+ for (WebServiceRef refItem : refs.value())
+ {
+ bindRefOnType(type, container, refItem);
+ }
+ }
+ }
+
+ private void bindRefOnType(Class type, InjectionContainer container, WebServiceRef wsref)
+ {
+ String name = wsref.name();
+ if (name.equals(""))
+ name = InjectionUtil.getEncName(type).substring(4);
+
+ if (!container.getEncInjectors().containsKey(name))
+ {
+ String encName = "env/" + name;
+ ServiceRefMetaData sref = getServiceRefForName(name);
+ container.getEncInjectors().put(name, new WebServiceRefInjector(encName, type, sref));
+ }
+ }
+
+ public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ WebServiceRef wsref = method.getAnnotation(WebServiceRef.class);
+ if (wsref == null) return;
+
+ if (!method.getName().startsWith("set"))
+ throw new RuntimeException("@WebServiceRef can only be used with a set method: " + method);
+
+ String name = wsref.name();
+ if (name.equals(""))
+ name = InjectionUtil.getEncName(method).substring(4);
+
+ String encName = "env/" + name;
+ Context encCtx = container.getEnc();
+ if (!container.getEncInjectors().containsKey(name))
+ {
+ ServiceRefMetaData sref = getServiceRefForName(name);
+ container.getEncInjectors().put(name, new WebServiceRefInjector(encName, method, sref));
+ }
+
+ injectors.put(method, new JndiMethodInjector(method, encName, encCtx));
+ }
+
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ WebServiceRef wsref = field.getAnnotation(WebServiceRef.class);
+ if (wsref == null) return;
+
+ String name = wsref.name();
+ if (name.equals(""))
+ name = InjectionUtil.getEncName(field).substring(4);
+
+ String encName = "env/" + name;
+ Context encCtx = container.getEnc();
+ if (!container.getEncInjectors().containsKey(name))
+ {
+ ServiceRefMetaData sref = getServiceRefForName(name);
+ container.getEncInjectors().put(name, new WebServiceRefInjector(encName, field, sref));
+ }
+
+ injectors.put(field, new JndiFieldInjector(field, encName, encCtx));
+ }
+
+ private ServiceRefMetaData getServiceRefForName(String name)
+ {
+ ServiceRefMetaData sref = srefMap.get(name);
+ if (sref == null)
+ {
+ log.debug("No override for @WebServiceRef.name: " + name);
+ sref = new ServiceRefDelegate().newServiceRefMetaData();
+ sref.setServiceRefName(name);
+ }
+ return sref;
+ }
+}
Added: tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java
===================================================================
--- tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java (rev 0)
+++ tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java 2010-03-24 16:07:27 UTC (rev 102893)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.injection;
+
+// $Id: WebServiceRefInjector.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
+
+import javax.naming.Context;
+import javax.xml.ws.WebServiceException;
+
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.wsf.common.URLLoaderAdapter;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+
+/**
+ * Inject a jaxws web service ref.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @version $Revision: 69712 $
+ */
+public class WebServiceRefInjector implements EncInjector
+{
+ private static final Logger log = Logger.getLogger(WebServiceRefInjector.class);
+
+ private String name;
+ private ServiceRefMetaData sref;
+
+ public WebServiceRefInjector(String name, AnnotatedElement anElement, ServiceRefMetaData sref)
+ {
+ this.name = name;
+ this.sref = sref;
+ this.sref.setAnnotatedElement(anElement);
+ }
+
+ public void inject(InjectionContainer container)
+ {
+ try
+ {
+ Context encCtx = container.getEnc();
+ EJBContainer ejbContainer = (EJBContainer)container;
+ DeploymentUnit unit = ejbContainer.getDeploymentUnit();
+ URL rootURL = unit.getUrl();
+
+ ClassLoader loader = unit.getClassLoader();
+ URLLoaderAdapter vfsRoot = new URLLoaderAdapter(rootURL);
+ new ServiceRefDelegate().bindServiceRef(encCtx, name, vfsRoot, loader, sref);
+
+ log.debug("@WebServiceRef bound [env=" + name + "]");
+ }
+ catch (Exception e)
+ {
+ throw new WebServiceException("Unable to bind @WebServiceRef [enc=" + name + "]", e);
+ }
+ }
+
+ public String toString()
+ {
+ return super.toString() + "{enc=" + name + "}";
+ }
+}
Added: tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java
===================================================================
--- tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java (rev 0)
+++ tags/JBPAPP_4_3_0_GA_CP08/ejb3/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java 2010-03-24 16:07:27 UTC (rev 102893)
@@ -0,0 +1,241 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metamodel.descriptor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public abstract class EnvironmentRefGroup
+{
+ private static final Logger log = Logger.getLogger(EnvironmentRefGroup.class);
+
+ protected HashMap<String, EjbLocalRef> ejbLocalRefs = new HashMap<String, EjbLocalRef>();
+ protected HashMap<String, EjbRef> ejbRefs = new HashMap<String, EjbRef>();
+ protected HashMap<String, EnvEntry> envEntries = new HashMap<String, EnvEntry>();
+ protected HashMap<String, ResourceEnvRef> resourceEnvRefs = new HashMap<String, ResourceEnvRef>();
+ protected HashMap<String, ResourceRef> resourceRefs = new HashMap<String, ResourceRef>();
+ protected HashMap<String, MessageDestinationRef> messageDestinationRefs = new HashMap<String, MessageDestinationRef>();
+ /** An index of MessageDestinationRef keyed by message-destination-link values */
+ protected HashMap<String, MessageDestinationRef> messageDestinationRefsByLink = new HashMap<String, MessageDestinationRef>();
+ protected HashMap<String, ServiceRefMetaData> serviceRefs = new HashMap<String, ServiceRefMetaData>();
+ protected HashMap<String, JndiRef> jndiRefs = new HashMap<String, JndiRef>();
+ protected List<PersistenceContextRef> persistenceContextRefs = new ArrayList<PersistenceContextRef>();
+ protected List<PersistenceUnitRef> persistenceUnitRefs = new ArrayList<PersistenceUnitRef>();
+
+ public Collection<MessageDestinationRef> getMessageDestinationRefs()
+ {
+ return messageDestinationRefs.values();
+ }
+
+ public void addMessageDestinationRef(MessageDestinationRef ref)
+ {
+ log.debug("addMessageDestinationRef, "+ref);
+ messageDestinationRefs.put(ref.getMessageDestinationRefName(), ref);
+ String link = ref.getMessageDestinationLink();
+ if( link != null )
+ {
+ messageDestinationRefsByLink.put(link, ref);
+ }
+ }
+
+ public Collection<EjbLocalRef> getEjbLocalRefs()
+ {
+ return ejbLocalRefs.values();
+ }
+
+ public void addEjbLocalRef(EjbLocalRef ref)
+ {
+ ejbLocalRefs.put(ref.getEjbRefName(), ref);
+ }
+
+ public Collection<EjbRef> getEjbRefs()
+ {
+ return ejbRefs.values();
+ }
+
+ public void addEjbRef(EjbRef ref)
+ {
+ ejbRefs.put(ref.getEjbRefName(), ref);
+ }
+
+ public Collection<EnvEntry> getEnvEntries()
+ {
+ return envEntries.values();
+ }
+
+ public void addEnvEntry(EnvEntry entry)
+ {
+ envEntries.put(entry.getEnvEntryName(), entry);
+ }
+
+ public Collection<ResourceEnvRef> getResourceEnvRefs()
+ {
+ return resourceEnvRefs.values();
+ }
+
+ public void addResourceEnvRef(ResourceEnvRef envRef)
+ {
+ resourceEnvRefs.put(envRef.getResRefName(), envRef);
+ }
+
+ public Collection<ResourceRef> getResourceRefs()
+ {
+ return resourceRefs.values();
+ }
+
+ public void addResourceRef(ResourceRef ref)
+ {
+ resourceRefs.put(ref.getResRefName(), ref);
+ }
+
+ public Collection<JndiRef> getJndiRefs()
+ {
+ return jndiRefs.values();
+ }
+
+ public void addJndiRef(JndiRef ref)
+ {
+ jndiRefs.put(ref.getJndiRefName(), ref);
+ }
+
+ public Collection<ServiceRefMetaData> getServiceRefs()
+ {
+ return serviceRefs.values();
+ }
+
+ public void addServiceRef(ServiceRefMetaData ref)
+ {
+ serviceRefs.put(ref.getServiceRefName(), ref);
+ }
+
+ public void updateEjbRef(EjbRef updatedRef)
+ {
+ EjbRef ref = (EjbRef)ejbRefs.get(updatedRef.getEjbRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ ref.setIgnoreDependency(updatedRef.isIgnoreDependency());
+ }
+ else
+ {
+ ejbRefs.put(updatedRef.getEjbRefName(), updatedRef);
+ }
+ }
+
+ public void updateEjbLocalRef(EjbLocalRef updatedRef)
+ {
+ EjbLocalRef ref = (EjbLocalRef)ejbLocalRefs.get(updatedRef.getEjbRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ ref.setIgnoreDependency(updatedRef.isIgnoreDependency());
+ }
+ else
+ {
+ ejbLocalRefs.put(updatedRef.getEjbRefName(), updatedRef);
+ }
+ }
+
+ public void updateResourceRef(ResourceRef updatedRef)
+ {
+ ResourceRef ref = (ResourceRef)resourceRefs.get(updatedRef.getResRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ ref.setResUrl(updatedRef.getResUrl());
+ ref.setResourceName(updatedRef.getResourceName());
+ }
+ else
+ {
+ resourceRefs.put(updatedRef.getResRefName(), updatedRef);
+ }
+ }
+
+ public void updateResourceEnvRef(ResourceEnvRef updatedRef)
+ {
+ ResourceEnvRef ref = (ResourceEnvRef)resourceEnvRefs.get(updatedRef.getResRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ }
+ else
+ {
+ resourceEnvRefs.put(updatedRef.getResRefName(), updatedRef);
+ }
+ }
+
+ public void updateMessageDestinationRef(MessageDestinationRef updatedRef)
+ {
+ log.debug("updateMessageDestinationRef, "+updatedRef);
+ MessageDestinationRef ref = (MessageDestinationRef)messageDestinationRefs.get(updatedRef.getMessageDestinationRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ }
+ else
+ {
+ messageDestinationRefs.put(updatedRef.getMessageDestinationRefName(), updatedRef);
+ ref = updatedRef;
+ }
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(100);
+ return sb.toString();
+ }
+
+ public List<PersistenceContextRef> getPersistenceContextRefs()
+ {
+ return persistenceContextRefs;
+ }
+
+ public List<PersistenceUnitRef> getPersistenceUnitRefs()
+ {
+ return persistenceUnitRefs;
+ }
+
+ public void addPersistenceContextRef(PersistenceContextRef ref)
+ {
+ persistenceContextRefs.add(ref);
+ }
+
+ public void addPersistenceUnitRef(PersistenceUnitRef ref)
+ {
+ persistenceUnitRefs.add(ref);
+ }
+
+ public MessageDestinationRef getMessageDestinationRefForLink(String link)
+ {
+ MessageDestinationRef ref = messageDestinationRefsByLink.get(link);
+ return ref;
+ }
+}
More information about the jboss-cvs-commits
mailing list