[jboss-cvs] JBossAS SVN: r102058 - in projects/metadata/ejb/trunk: src/main/java/org/jboss/metadata/annotation/creator/ejb and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 8 07:29:20 EST 2010
Author: jaikiran
Date: 2010-03-08 07:29:19 -0500 (Mon, 08 Mar 2010)
New Revision: 102058
Added:
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ConcurrencyManagementProcessor.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/ConcurrencyManagementProcessor.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ConcurrencyManagementTypeAdapter.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/BMCSingletonBean.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/CMCSingletonBean.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/CMCStatefulBean.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/DefaultConcurrencySingletonBean.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/DefaultConcurrencyStatefulBean.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/unit/
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/unit/ConcurrencyManagementTestCase.java
projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/concurrency/
projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/concurrency/ejb-jar-concurrency.xml
Modified:
projects/metadata/ejb/trunk/pom.xml
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/SingletonProcessor.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatefulProcessor.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/StatefulProcessor.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java
Log:
JBMETA-263 Added support for ConcurrencyManagement annotation and its xml equivalent
Modified: projects/metadata/ejb/trunk/pom.xml
===================================================================
--- projects/metadata/ejb/trunk/pom.xml 2010-03-08 11:01:07 UTC (rev 102057)
+++ projects/metadata/ejb/trunk/pom.xml 2010-03-08 12:29:19 UTC (rev 102058)
@@ -50,8 +50,9 @@
<rules>
<bannedDependencies>
<excludes>
- <!-- JBMETA-246 Use org.jboss.javaee:jboss-ejb-api_3.1-->
+ <!-- JBMETA-262 Use org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec -->
<exclude>org.jboss.ejb3:jboss-ejb3-api</exclude>
+ <exclude>org.jboss.javaee:jboss-ejb-api_3.1</exclude>
</excludes>
</bannedDependencies>
</rules>
@@ -138,9 +139,9 @@
<dependencies>
<dependency>
- <groupId>org.jboss.javaee</groupId>
- <artifactId>jboss-ejb-api_3.1</artifactId>
- <version>1.0-alpha-1</version>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ConcurrencyManagementProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ConcurrencyManagementProcessor.java (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ConcurrencyManagementProcessor.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -0,0 +1,78 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.metadata.annotation.creator.ejb;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+
+import javax.ejb.ConcurrencyManagement;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.creator.ProcessorUtils;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.SessionBean31MetaData;
+
+/**
+ * Responsible for setting up {@link SessionBean31MetaData} metadata with the
+ * correct concurrency management metadata by processing the {@link ConcurrencyManagement} annotation
+ * on the bean class
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ConcurrencyManagementProcessor extends AbstractFinderUser implements Processor<SessionBean31MetaData, Class<?>>
+{
+
+ /**
+ * @param finder
+ */
+ public ConcurrencyManagementProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ /**
+ * @see org.jboss.metadata.annotation.creator.Processor#getAnnotationTypes()
+ */
+ @Override
+ public Collection<Class<? extends Annotation>> getAnnotationTypes()
+ {
+ return ProcessorUtils.createAnnotationSet(ConcurrencyManagement.class);
+ }
+
+ /**
+ * @see org.jboss.metadata.annotation.creator.Processor#process(java.lang.Object, java.lang.reflect.AnnotatedElement)
+ */
+ @Override
+ public void process(SessionBean31MetaData sessionBean, Class<?> type)
+ {
+ ConcurrencyManagement concurrencyManagement = this.finder.getAnnotation(type, ConcurrencyManagement.class);
+ if (concurrencyManagement == null)
+ {
+ return;
+ }
+ sessionBean.setConcurrencyManagementType(concurrencyManagement.value());
+ }
+
+}
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/SingletonProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/SingletonProcessor.java 2010-03-08 11:01:07 UTC (rev 102057)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/SingletonProcessor.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -29,6 +29,7 @@
import org.jboss.metadata.annotation.creator.ProcessorUtils;
import org.jboss.metadata.annotation.creator.ejb.jboss.AbstractSessionBeanProcessor;
+import org.jboss.metadata.annotation.creator.ejb.jboss.ConcurrencyManagementProcessor;
import org.jboss.metadata.annotation.finder.AnnotationFinder;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
import org.jboss.metadata.ejb.spec.SessionType;
@@ -45,6 +46,7 @@
public SingletonProcessor(AnnotationFinder<AnnotatedElement> finder)
{
super(finder);
+ addTypeProcessor(new ConcurrencyManagementProcessor(finder));
}
@Override
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatefulProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatefulProcessor.java 2010-03-08 11:01:07 UTC (rev 102057)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatefulProcessor.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -47,6 +47,8 @@
addMethodProcessor(new RemoveProcessor(finder));
addMethodProcessor(new PostActivateMethodProcessor(finder));
addMethodProcessor(new PrePassivateMethodProcessor(finder));
+ // concurrency management annotation is applicable for stateful bean
+ addTypeProcessor(new ConcurrencyManagementProcessor(finder));
}
public SessionBeanMetaData create(Class<?> beanClass)
Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/ConcurrencyManagementProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/ConcurrencyManagementProcessor.java (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/ConcurrencyManagementProcessor.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -0,0 +1,78 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.metadata.annotation.creator.ejb.jboss;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+
+import javax.ejb.ConcurrencyManagement;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.creator.ProcessorUtils;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+
+/**
+ * Responsible for setting up {@link JBossSessionBean31MetaData} metadata with the
+ * correct concurrency management metadata by processing the {@link ConcurrencyManagement} annotation
+ * on the bean class
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ConcurrencyManagementProcessor extends AbstractFinderUser implements Processor<JBossSessionBean31MetaData, Class<?>>
+{
+
+ /**
+ * @param finder
+ */
+ public ConcurrencyManagementProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ /**
+ * @see org.jboss.metadata.annotation.creator.Processor#getAnnotationTypes()
+ */
+ @Override
+ public Collection<Class<? extends Annotation>> getAnnotationTypes()
+ {
+ return ProcessorUtils.createAnnotationSet(ConcurrencyManagement.class);
+ }
+
+ /**
+ * @see org.jboss.metadata.annotation.creator.Processor#process(java.lang.Object, java.lang.reflect.AnnotatedElement)
+ */
+ @Override
+ public void process(JBossSessionBean31MetaData sessionBean, Class<?> type)
+ {
+ ConcurrencyManagement concurrencyManagement = this.finder.getAnnotation(type, ConcurrencyManagement.class);
+ if (concurrencyManagement == null)
+ {
+ return;
+ }
+ sessionBean.setConcurrencyManagementType(concurrencyManagement.value());
+ }
+
+}
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/StatefulProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/StatefulProcessor.java 2010-03-08 11:01:07 UTC (rev 102057)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/StatefulProcessor.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -53,6 +53,10 @@
addMethodProcessor(new RemoveProcessor(finder));
addMethodProcessor(new PostActivateMethodProcessor(finder));
addMethodProcessor(new PrePassivateMethodProcessor(finder));
+
+ // concurrency management annotation is applicable for stateful bean
+ addTypeProcessor(new ConcurrencyManagementProcessor(finder));
+
}
@Override
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java 2010-03-08 11:01:07 UTC (rev 102057)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -21,10 +21,13 @@
*/
package org.jboss.metadata.ejb.jboss;
+import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Startup;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.jboss.metadata.common.ejb.ITimeoutTarget;
import org.jboss.metadata.ejb.spec.AsyncMethodsMetaData;
+import org.jboss.metadata.ejb.spec.ConcurrencyManagementTypeAdapter;
import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
import org.jboss.metadata.ejb.spec.SessionBean31MetaData;
import org.jboss.metadata.ejb.spec.SessionType;
@@ -43,12 +46,17 @@
* Flag indicating whether this bean has a no-interface view
*/
private boolean noInterfaceBean;
-
+
/**
* Flag indicating if a singleton bean is set for init-on-startup
*/
private Boolean initOnStartup;
+ /**
+ * Concurrency management type of the bean
+ */
+ private ConcurrencyManagementType concurrencyManagementType;
+
public AsyncMethodsMetaData getAsyncMethods()
{
return asyncMethods;
@@ -105,9 +113,7 @@
}
return SessionType.Singleton == type;
}
-
-
-
+
/**
* @return Returns true if a singleton bean is marked for init-on-startup ({@link Startup})
*
@@ -125,11 +131,34 @@
*/
public void setInitOnStartup(boolean initOnStartup)
{
-
+
this.initOnStartup = initOnStartup;
}
+ /**
+ * Sets the concurrency management type of this bean
+ * @param concurrencyManagementType The concurrency management type
+ * @throws If the passed <code>concurrencyManagementType</code> is null
+ */
+ @XmlJavaTypeAdapter(ConcurrencyManagementTypeAdapter.class)
+ public void setConcurrencyManagementType(ConcurrencyManagementType concurrencyManagementType)
+ {
+ if (concurrencyManagementType == null)
+ {
+ throw new IllegalArgumentException("Concurrency management type cannot be null");
+ }
+ this.concurrencyManagementType = concurrencyManagementType;
+ }
+ /**
+ * Returns the concurrency management type of this bean
+ * @return
+ */
+ public ConcurrencyManagementType getConcurrencyManagementType()
+ {
+ return this.concurrencyManagementType;
+ }
+
@Override
public void merge(JBossEnterpriseBeanMetaData override, JBossEnterpriseBeanMetaData original)
{
@@ -153,7 +182,7 @@
{
this.noInterfaceBean = soriginal.isNoInterfaceBean();
}
-
+
// merge the init-on-startup information
if (joverride != null)
{
@@ -177,24 +206,25 @@
merge(joverride != null ? joverride.asyncMethods : null, soriginal != null ? soriginal.getAsyncMethods() : null);
- // merge the no-interface information
+ // merge rest of the metadata
if (joverride != null)
{
this.noInterfaceBean = joverride.isNoInterfaceBean();
+ this.initOnStartup = joverride.isInitOnStartup();
+ if (joverride.concurrencyManagementType != null)
+ {
+ this.concurrencyManagementType = joverride.concurrencyManagementType;
+ }
}
else if (soriginal != null)
{
this.noInterfaceBean = soriginal.isNoInterfaceBean();
- }
-
- // merge the init-on-startup information
- if (joverride != null)
- {
- this.initOnStartup = joverride.isInitOnStartup();
- }
- else if (soriginal != null)
- {
this.initOnStartup = soriginal.isInitOnStartup();
+ if (soriginal.getConcurrencyManagementType() != null)
+ {
+ this.concurrencyManagementType = soriginal.getConcurrencyManagementType();
+ }
}
+
}
}
Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ConcurrencyManagementTypeAdapter.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ConcurrencyManagementTypeAdapter.java (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ConcurrencyManagementTypeAdapter.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.metadata.ejb.spec;
+
+import javax.ejb.ConcurrencyManagementType;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * Responsible for converting the String value of {@link ConcurrencyManagementType} to
+ * the corresponding {@link ConcurrencyManagementType}
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ConcurrencyManagementTypeAdapter extends XmlAdapter<String, ConcurrencyManagementType>
+{
+
+ /**
+ * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
+ */
+ @Override
+ public String marshal(ConcurrencyManagementType cmType) throws Exception
+ {
+ switch (cmType)
+ {
+ case BEAN :
+ return "Bean";
+ case CONTAINER :
+ return "Container";
+ default :
+ return null;
+ }
+ }
+
+ /**
+ * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
+ */
+ @Override
+ public ConcurrencyManagementType unmarshal(String cmType) throws Exception
+ {
+ String concurrencyManagementType = cmType.toUpperCase();
+ return ConcurrencyManagementType.valueOf(concurrencyManagementType);
+ }
+
+}
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java 2010-03-08 11:01:07 UTC (rev 102057)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -21,8 +21,10 @@
*/
package org.jboss.metadata.ejb.spec;
+import javax.ejb.ConcurrencyManagementType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.jboss.metadata.common.ejb.ITimeoutTarget;
import org.jboss.metadata.javaee.spec.EmptyMetaData;
@@ -33,29 +35,34 @@
* @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
* @version $Revision: $
*/
- at XmlType(name="session-beanType", propOrder={"descriptionGroup", "ejbName", "mappedName", "home", "remote", "localHome", "local",
- "businessLocals", "businessRemotes", "localBean", "serviceEndpoint", "ejbClass", "sessionType", "timeoutMethod",
- "initOnStartup", "initMethods", "removeMethods", "asyncMethods",
- "transactionType", "aroundInvokes", "environmentRefsGroup", "postActivates", "prePassivates", "securityRoleRefs", "securityIdentity"})
- at JBossXmlType(modelGroup=JBossXmlConstants.MODEL_GROUP_UNORDERED_SEQUENCE)
-public class SessionBean31MetaData extends SessionBeanMetaData
- implements ITimeoutTarget // FIXME: AbstractProcessor.processClass doesn't take super interfaces into account
+ at XmlType(name = "session-beanType", propOrder =
+{"descriptionGroup", "ejbName", "mappedName", "home", "remote", "localHome", "local", "businessLocals",
+ "businessRemotes", "localBean", "serviceEndpoint", "ejbClass", "sessionType", "timeoutMethod", "initOnStartup",
+ "concurrencyManagementType", "initMethods", "removeMethods", "asyncMethods", "transactionType", "aroundInvokes",
+ "environmentRefsGroup", "postActivates", "prePassivates", "securityRoleRefs", "securityIdentity"})
+ at JBossXmlType(modelGroup = JBossXmlConstants.MODEL_GROUP_UNORDERED_SEQUENCE)
+public class SessionBean31MetaData extends SessionBeanMetaData implements ITimeoutTarget // FIXME: AbstractProcessor.processClass doesn't take super interfaces into account
{
private static final long serialVersionUID = 1L;
-
+
private AsyncMethodsMetaData asyncMethods;
-
+
/**
* For <local-bean>
*/
private EmptyMetaData localBean;
-
+
/**
* init-on-startup
*/
private Boolean initOnStartup;
-
+
/**
+ * Concurrency management type of the bean
+ */
+ private ConcurrencyManagementType concurrencyManagementType;
+
+ /**
* Returns the init-on-startup value of the session bean metadata.
* Returns null if none is defined.
* @return
@@ -65,7 +72,7 @@
return initOnStartup;
}
- @XmlElement(name="init-on-startup", required=false)
+ @XmlElement(name = "init-on-startup", required = false)
public void setInitOnStartup(Boolean initOnStartup)
{
this.initOnStartup = initOnStartup;
@@ -75,16 +82,16 @@
{
return asyncMethods;
}
-
- @XmlElement(name="async-method", required=false)
+
+ @XmlElement(name = "async-method", required = false)
public void setAsyncMethods(AsyncMethodsMetaData asyncMethods)
{
- if(asyncMethods == null)
+ if (asyncMethods == null)
throw new IllegalArgumentException("asyncMethods is null");
-
+
this.asyncMethods = asyncMethods;
}
-
+
/**
*
* @return Returns {@link EmptyMetaData} if the bean represents a no-interface
@@ -97,19 +104,19 @@
{
return this.localBean;
}
-
+
/**
* Set the metadata to represent whether this bean
* exposes an no-interface view
* @param isNoInterfaceBean True if the bean exposes a no-interface
* view. Else set to false.
*/
- @XmlElement(name="local-bean", required=false)
+ @XmlElement(name = "local-bean", required = false)
public void setLocalBean(EmptyMetaData localBean)
{
this.localBean = localBean;
}
-
+
/**
* @return Returns true if this bean exposes a no-interface view.
* Else returns false. This is similar to {@link #getLocalBean()}, but
@@ -120,7 +127,7 @@
{
return this.localBean == null ? false : true;
}
-
+
/**
* Sets the no-interface information in the metadata
* @param isNoInterfaceBean True if this is a no-interface bean, false otherwise
@@ -129,7 +136,7 @@
{
this.localBean = isNoInterfaceBean ? new EmptyMetaData() : null;
}
-
+
/**
* Returns true if this is a singleton session bean. Else returns false
*/
@@ -139,8 +146,32 @@
return false;
return this.getSessionType() == SessionType.Singleton;
}
-
+
/**
+ * Sets the concurrency management type of this bean
+ * @param concurrencyManagementType The concurrency management type
+ * @throws If the passed <code>concurrencyManagementType</code> is null
+ */
+ @XmlJavaTypeAdapter(ConcurrencyManagementTypeAdapter.class)
+ public void setConcurrencyManagementType(ConcurrencyManagementType concurrencyManagementType)
+ {
+ if (concurrencyManagementType == null)
+ {
+ throw new IllegalArgumentException("Concurrency management type cannot be null");
+ }
+ this.concurrencyManagementType = concurrencyManagementType;
+ }
+
+ /**
+ * Returns the concurrency management type of this bean
+ * @return
+ */
+ public ConcurrencyManagementType getConcurrencyManagementType()
+ {
+ return this.concurrencyManagementType;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -149,29 +180,44 @@
super.merge(eoverride, eoriginal);
SessionBean31MetaData override = (SessionBean31MetaData) eoverride;
SessionBean31MetaData original = (SessionBean31MetaData) eoriginal;
- if(asyncMethods == null)
+ if (asyncMethods == null)
asyncMethods = new AsyncMethodsMetaData();
- if(override != null && override.asyncMethods != null)
+ if (override != null && override.asyncMethods != null)
asyncMethods.addAll(override.asyncMethods);
- if(original != null && original.asyncMethods != null)
+ if (original != null && original.asyncMethods != null)
asyncMethods.addAll(original.asyncMethods);
- // merge the no-interface information
- if (original != null && original.getLocalBean() != null)
+
+ // merge rest of the metadata
+
+ if (override != null)
{
- this.localBean = original.getLocalBean();
+ if (override.localBean != null)
+ {
+ this.localBean = override.localBean;
+ }
+ if (override.initOnStartup != null)
+ {
+ this.initOnStartup = override.initOnStartup;
+ }
+ if (override.concurrencyManagementType != null)
+ {
+ this.concurrencyManagementType = override.concurrencyManagementType;
+ }
}
- if (override != null && override.getLocalBean() != null)
+ else if (original != null)
{
- this.localBean = override.getLocalBean();
+ if (original.localBean != null)
+ {
+ this.localBean = original.localBean;
+ }
+ if (original.initOnStartup != null)
+ {
+ this.initOnStartup = original.initOnStartup;
+ }
+ if (original.concurrencyManagementType != null)
+ {
+ this.concurrencyManagementType = original.concurrencyManagementType;
+ }
}
- // init-on-startup
- if (original != null && original.initOnStartup != null)
- {
- this.initOnStartup = original.initOnStartup;
- }
- if (override != null && override.initOnStartup != null)
- {
- this.initOnStartup = override.initOnStartup;
- }
}
}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/BMCSingletonBean.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/BMCSingletonBean.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/BMCSingletonBean.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.metadata.ejb.test.concurrency;
+
+import javax.ejb.ConcurrencyManagementType;
+
+import javax.ejb.ConcurrencyManagement;
+
+import javax.ejb.Singleton;
+
+/**
+ * SingletonBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Singleton
+ at ConcurrencyManagement (ConcurrencyManagementType.BEAN)
+public class BMCSingletonBean
+{
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/CMCSingletonBean.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/CMCSingletonBean.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/CMCSingletonBean.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.metadata.ejb.test.concurrency;
+
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.Singleton;
+
+/**
+ * CMCSingletonBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Singleton
+ at ConcurrencyManagement (ConcurrencyManagementType.CONTAINER)
+public class CMCSingletonBean
+{
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/CMCStatefulBean.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/CMCStatefulBean.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/CMCStatefulBean.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.metadata.ejb.test.concurrency;
+
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.Stateful;
+
+/**
+ * CMCStatefulBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateful
+ at ConcurrencyManagement (ConcurrencyManagementType.CONTAINER)
+public class CMCStatefulBean
+{
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/DefaultConcurrencySingletonBean.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/DefaultConcurrencySingletonBean.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/DefaultConcurrencySingletonBean.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.metadata.ejb.test.concurrency;
+
+import javax.ejb.Singleton;
+
+/**
+ * DefaultConcurrencySingletonBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Singleton
+public class DefaultConcurrencySingletonBean
+{
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/DefaultConcurrencyStatefulBean.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/DefaultConcurrencyStatefulBean.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/DefaultConcurrencyStatefulBean.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.metadata.ejb.test.concurrency;
+
+import javax.ejb.Stateful;
+
+/**
+ * DefaultConcurrencyStatefulBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateful
+public class DefaultConcurrencyStatefulBean
+{
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/unit/ConcurrencyManagementTestCase.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/unit/ConcurrencyManagementTestCase.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/concurrency/unit/ConcurrencyManagementTestCase.java 2010-03-08 12:29:19 UTC (rev 102058)
@@ -0,0 +1,254 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.metadata.ejb.test.concurrency.unit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
+import java.util.Collection;
+
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+import org.jboss.metadata.ejb.spec.EjbJar31MetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.SessionBean31MetaData;
+import org.jboss.metadata.ejb.test.concurrency.BMCSingletonBean;
+import org.jboss.metadata.ejb.test.concurrency.CMCSingletonBean;
+import org.jboss.metadata.ejb.test.concurrency.CMCStatefulBean;
+import org.jboss.metadata.ejb.test.concurrency.DefaultConcurrencySingletonBean;
+import org.jboss.metadata.ejb.test.concurrency.DefaultConcurrencyStatefulBean;
+import org.jboss.test.metadata.common.PackageScanner;
+import org.jboss.test.metadata.common.ScanPackage;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.resolver.MultiClassSchemaResolver;
+import org.jboss.xb.binding.resolver.MutableSchemaResolver;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test that the metadata for concurrency management annotation and
+ * it's equivalent xml element is processed correctly
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ConcurrencyManagementTestCase
+{
+
+ private static UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+
+ private static MutableSchemaResolver schemaBindingResolver;
+
+ @BeforeClass
+ public static void beforeClass()
+ {
+ schemaBindingResolver = new MultiClassSchemaResolver();
+ schemaBindingResolver.mapLocationToClass("ejb-jar_3_1.xsd", EjbJar31MetaData.class);
+ }
+
+ /**
+ * Tests that the {@link ConcurrencyManagement} annotation is processed correctly
+ *
+ * @throws Exception
+ */
+ @Test
+ @ScanPackage("org.jboss.metadata.ejb.test.concurrency")
+ public void testConcurrencyManagementAnnotationProcessing() throws Exception
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ Collection<Class<?>> classes = PackageScanner.loadClasses();
+ JBossMetaData metaData = creator.create(classes);
+ assertNotNull("Metadata created for singleton bean was null", metaData);
+
+ this.assertNullConcurrencyManagement(metaData, DefaultConcurrencySingletonBean.class.getSimpleName());
+ this.assertNullConcurrencyManagement(metaData, DefaultConcurrencyStatefulBean.class.getSimpleName());
+
+ this.assertBeanConcurrencyManagement(metaData, BMCSingletonBean.class.getSimpleName());
+
+ this.assertContainerConcurrencyManagement(metaData, CMCSingletonBean.class.getSimpleName());
+ this.assertContainerConcurrencyManagement(metaData, CMCStatefulBean.class.getSimpleName());
+
+ }
+
+ /**
+ * Test that the concurrency management in ejb-jar.xml is processed correctly
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testConcurrencyManagementXMLProcessing() throws Exception
+ {
+ EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class,
+ "/org/jboss/metadata/ejb/test/concurrency/ejb-jar-concurrency.xml");
+ assertNotNull(jarMetaData);
+
+ this.assertBeanConcurrencyManagement(jarMetaData, "BMCSingletonBean");
+
+ this.assertContainerConcurrencyManagement(jarMetaData, "CMCSingletonBean");
+ this.assertContainerConcurrencyManagement(jarMetaData, "CMCStatefulBean");
+
+ this.assertNullConcurrencyManagement(jarMetaData, "DefaultConcurrencySingletonBean");
+ this.assertNullConcurrencyManagement(jarMetaData, "DefaultConcurrencyStatefulBean");
+ }
+
+ /**
+ * Utility method
+ * @param <T>
+ * @param type
+ * @param resource
+ * @return
+ * @throws JBossXBException
+ */
+ private static <T> T unmarshal(Class<T> type, String resource) throws JBossXBException
+ {
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setValidation(false);
+ URL url = type.getResource(resource);
+ if (url == null)
+ throw new IllegalArgumentException("Failed to find resource " + resource);
+ return type.cast(unmarshaller.unmarshal(url.toString(), schemaBindingResolver));
+ }
+
+ /**
+ * Utility method to assert that the bean is a session bean
+ *
+ * @param enterpriseBean
+ */
+ private void assertSessionBean(JBossEnterpriseBeanMetaData enterpriseBean)
+ {
+ assertTrue("Bean " + enterpriseBean.getName() + " is not a session bean", enterpriseBean.isSession());
+ }
+
+ /**
+ * Utility method to assert that the bean is a session bean
+ *
+ * @param enterpriseBean
+ */
+ private void assertSessionBean(EnterpriseBeanMetaData enterpriseBean)
+ {
+ assertTrue("Bean " + enterpriseBean.getName() + " is not a session bean", enterpriseBean.isSession());
+ }
+
+ /**
+ * Utility method to assert that the bean does not have any concurrency management set
+ * @param metaData
+ * @param beanName
+ */
+ private void assertNullConcurrencyManagement(JBossMetaData metaData, String beanName)
+ {
+ JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(beanName);
+ this.assertSessionBean(enterpriseBean);
+ JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
+ assertNull("Bean " + beanName + " unexpectedly has concurrency management set", sessionBean
+ .getConcurrencyManagementType());
+
+ }
+
+ /**
+ * Utility method to assert that the bean has container managed concurrency
+ * @param metaData
+ * @param beanName
+ */
+ private void assertContainerConcurrencyManagement(JBossMetaData metaData, String beanName)
+ {
+ JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(beanName);
+ this.assertSessionBean(enterpriseBean);
+ JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
+ assertEquals("Bean " + beanName + " does not have container managed concurrency",
+ ConcurrencyManagementType.CONTAINER, sessionBean.getConcurrencyManagementType());
+
+ }
+
+ /**
+ * Utility method to assert that the bean has bean managed concurrency
+ * @param metaData
+ * @param beanName
+ */
+ private void assertBeanConcurrencyManagement(JBossMetaData metaData, String beanName)
+ {
+ JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(beanName);
+ this.assertSessionBean(enterpriseBean);
+ JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
+ assertEquals("Bean " + beanName + " does not have bean managed concurrency", ConcurrencyManagementType.BEAN,
+ sessionBean.getConcurrencyManagementType());
+ }
+
+
+ /**
+ * Utility method to assert that the bean does not have any concurrency management set
+ * @param metaData
+ * @param beanName
+ */
+ private void assertNullConcurrencyManagement(EjbJarMetaData metaData, String beanName)
+ {
+ EnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(beanName);
+ this.assertSessionBean(enterpriseBean);
+ SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
+ assertNull("Bean " + beanName + " unexpectedly has concurrency management set", sessionBean
+ .getConcurrencyManagementType());
+
+ }
+
+ /**
+ * Utility method to assert that the bean has container managed concurrency
+ * @param metaData
+ * @param beanName
+ */
+ private void assertContainerConcurrencyManagement(EjbJarMetaData metaData, String beanName)
+ {
+ EnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(beanName);
+ this.assertSessionBean(enterpriseBean);
+ SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
+ assertEquals("Bean " + beanName + " does not have container managed concurrency",
+ ConcurrencyManagementType.CONTAINER, sessionBean.getConcurrencyManagementType());
+
+ }
+
+ /**
+ * Utility method to assert that the bean has bean managed concurrency
+ * @param metaData
+ * @param beanName
+ */
+ private void assertBeanConcurrencyManagement(EjbJarMetaData metaData, String beanName)
+ {
+ EnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(beanName);
+ this.assertSessionBean(enterpriseBean);
+ SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
+ assertEquals("Bean " + beanName + " does not have bean managed concurrency", ConcurrencyManagementType.BEAN,
+ sessionBean.getConcurrencyManagementType());
+ }
+}
Added: projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/concurrency/ejb-jar-concurrency.xml
===================================================================
--- projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/concurrency/ejb-jar-concurrency.xml (rev 0)
+++ projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/concurrency/ejb-jar-concurrency.xml 2010-03-08 12:29:19 UTC (rev 102058)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
+ version="3.1">
+
+ <enterprise-beans>
+ <session>
+ <ejb-name>CMCSingletonBean</ejb-name>
+ <session-type>Singleton</session-type>
+ <concurrency-management-type>Container</concurrency-management-type>
+ </session>
+ <session>
+ <ejb-name>CMCStatefulBean</ejb-name>
+ <session-type>Stateful</session-type>
+ <concurrency-management-type>Container</concurrency-management-type>
+ </session>
+ <session>
+ <ejb-name>BMCSingletonBean</ejb-name>
+ <session-type>Singleton</session-type>
+ <concurrency-management-type>Bean</concurrency-management-type>
+ </session>
+ <session>
+ <ejb-name>DefaultConcurrencySingletonBean</ejb-name>
+ <session-type>Singleton</session-type>
+ </session>
+ <session>
+ <ejb-name>DefaultConcurrencyStatefulBean</ejb-name>
+ <session-type>Stateful</session-type>
+ </session>
+ </enterprise-beans>
+</ejb-jar>
More information about the jboss-cvs-commits
mailing list