openejb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r673270 - in /openejb/trunk/openejb3/container: openejb-core/src/main/java/org/apache/openejb/ openejb-core/src/main/java/org/apache/openejb/assembler/classic/ openejb-core/src/main/java/org/apache/openejb/config/ openejb-core/src/main/java...
Date Wed, 02 Jul 2008 04:13:34 GMT
Author: dblevins
Date: Tue Jul  1 21:13:25 2008
New Revision: 673270

URL: http://svn.apache.org/viewvc?rev=673270&view=rev
Log:
OPENEJB-837: Singleton Bean-Managed Concurrency
OPENEJB-838: Singleton Container-Managed Concurrency
OPENEJB-839: ReadOnly and ReadWrite method locking


Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodConcurrencyBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodConcurrencyInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ConcurrencyAttributesTest.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AttributeBinding.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ConcurrencyAttribute.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ConcurrencyType.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ContainerConcurrency.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java   (contents, props changed)
      - copied, changed from r672456, openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodTransaction.java
Removed:
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodTransaction.java
Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonInstanceManager.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ContainerTransaction.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/SessionBean.java
    openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java Tue Jul  1 21:13:25 2008
@@ -42,6 +42,10 @@
 
     final public static byte TX_MAX = (byte) 5;
 
+    final public static byte READ_LOCK = (byte) 6;
+
+    final public static byte WRITE_LOCK = (byte) 7;
+
     final public static String AC_CREATE_EJBHOME = "create.ejbhome";
 
     public BeanType getComponentType();

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java Tue Jul  1 21:13:25 2008
@@ -501,6 +501,9 @@
                 MethodTransactionBuilder methodTransactionBuilder = new MethodTransactionBuilder();
                 methodTransactionBuilder.build(deployments, ejbJar.methodTransactions);
 
+                MethodConcurrencyBuilder methodConcurrencyBuilder = new MethodConcurrencyBuilder();
+                methodConcurrencyBuilder.build(deployments, ejbJar.methodConcurrency);
+
                 for (DeploymentInfo deploymentInfo : deployments.values()) {
                     containerSystem.addDeployment(deploymentInfo);
                 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java Tue Jul  1 21:13:25 2008
@@ -32,6 +32,7 @@
     public final List<SecurityRoleInfo> securityRoles = new ArrayList<SecurityRoleInfo>();
     public final List<MethodPermissionInfo> methodPermissions= new ArrayList<MethodPermissionInfo>();
     public final List<MethodTransactionInfo> methodTransactions = new ArrayList<MethodTransactionInfo>();
+    public final List<MethodConcurrencyInfo> methodConcurrency = new ArrayList<MethodConcurrencyInfo>();
     public final List<InterceptorInfo> interceptors = new ArrayList<InterceptorInfo>();
     public final List<InterceptorBindingInfo> interceptorBindings = new ArrayList<InterceptorBindingInfo>();
     public final List<MethodInfo> excludeList = new ArrayList<MethodInfo>();

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java Tue Jul  1 21:13:25 2008
@@ -209,6 +209,10 @@
             deployment.setBeanManagedTransaction("Bean".equalsIgnoreCase(bean.transactionType));
         }
 
+        if (ejbType == BeanType.SINGLETON) {
+            deployment.setBeanManagedConcurrency("Bean".equalsIgnoreCase(bean.concurrencyType));
+        }
+
         if (ejbType.isEntity()) {
             EntityBeanInfo entity = (EntityBeanInfo) bean;
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanInfo.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanInfo.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanInfo.java Tue Jul  1 21:13:25 2008
@@ -49,6 +49,7 @@
     public String ejbName;
 
     public String transactionType;
+    public String concurrencyType;
     public JndiEncInfo jndiEnc;
     public NamedMethodInfo timeoutMethod;
 

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodConcurrencyBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodConcurrencyBuilder.java?rev=673270&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodConcurrencyBuilder.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodConcurrencyBuilder.java Tue Jul  1 21:13:25 2008
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.assembler.classic;
+
+import org.apache.openejb.util.Logger;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.core.CoreDeploymentInfo;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.lang.reflect.Method;
+
+/**
+ * @version $Rev: 646050 $ $Date: 2008-04-08 12:46:04 -0700 (Tue, 08 Apr 2008) $
+ */
+public class MethodConcurrencyBuilder {
+
+    public static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP, MethodConcurrencyBuilder.class);
+
+    public void build(HashMap<String, DeploymentInfo> deployments, List<MethodConcurrencyInfo> methodConcurrencys) throws OpenEJBException {
+        for (DeploymentInfo deploymentInfo : deployments.values()) {
+            MethodConcurrencyBuilder.applyConcurrencyAttributes((CoreDeploymentInfo) deploymentInfo, methodConcurrencys);
+        }
+    }
+
+    public static void applyConcurrencyAttributes(CoreDeploymentInfo deploymentInfo, List<MethodConcurrencyInfo> methodConcurrencyInfos) throws OpenEJBException {
+
+        if (deploymentInfo.isBeanManagedConcurrency()) return;
+
+        methodConcurrencyInfos = MethodConcurrencyBuilder.normalize(methodConcurrencyInfos);
+
+        Map<Method, MethodAttributeInfo> attributes = MethodInfoUtil.resolveAttributes(methodConcurrencyInfos, deploymentInfo);
+
+        Logger log = Logger.getInstance(LogCategory.OPENEJB_STARTUP.createChild("attributes"), MethodConcurrencyBuilder.class);
+        if (log.isDebugEnabled()) {
+            for (Map.Entry<Method, MethodAttributeInfo> entry : attributes.entrySet()) {
+                Method method = entry.getKey();
+                MethodConcurrencyInfo value = (MethodConcurrencyInfo) entry.getValue();
+                log.debug("Concurrency Attribute: " + method + " -- " + MethodInfoUtil.toString(value));
+            }
+        }
+
+        for (Map.Entry<Method, MethodAttributeInfo> entry : attributes.entrySet()) {
+            MethodConcurrencyInfo value = (MethodConcurrencyInfo) entry.getValue();
+
+//            logger.info(entry.getKey().toString() +"  "+ value.transAttribute);
+            deploymentInfo.setMethodConcurrencyAttribute(entry.getKey(), value.concurrencyAttribute);
+        }
+    }
+
+    /**
+     * This method splits the MethodConcurrencyInfo objects so that there is
+     * exactly one MethodInfo per MethodConcurrencyInfo.  A single MethodConcurrencyInfo
+     * with three MethodInfos would be expanded into three MethodConcurrencyInfo with
+     * one MethodInfo each.
+     *
+     * The MethodConcurrencyInfo list is then sorted from least to most specific.
+     *
+     * @param infos
+     * @return a normalized list of new MethodConcurrencyInfo objects
+     */
+    public static List<MethodConcurrencyInfo> normalize(List<MethodConcurrencyInfo> infos){
+        List<MethodConcurrencyInfo> normalized = new ArrayList<MethodConcurrencyInfo>();
+        for (MethodConcurrencyInfo oldInfo : infos) {
+            for (MethodInfo methodInfo : oldInfo.methods) {
+                MethodConcurrencyInfo newInfo = new MethodConcurrencyInfo();
+                newInfo.description = oldInfo.description;
+                newInfo.methods.add(methodInfo);
+                newInfo.concurrencyAttribute = oldInfo.concurrencyAttribute;
+
+                normalized.add(newInfo);
+            }
+        }
+
+        Collections.reverse(normalized);
+        Collections.sort(normalized, new MethodConcurrencyBuilder.MethodConcurrencyComparator());
+
+        return normalized;
+    }
+
+    public static class MethodConcurrencyComparator extends MethodInfoUtil.BaseComparator<MethodConcurrencyInfo> {
+        public int compare(MethodConcurrencyInfo a, MethodConcurrencyInfo b) {
+            return compare(a.methods.get(0), b.methods.get(0));
+        }
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodConcurrencyInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodConcurrencyInfo.java?rev=673270&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodConcurrencyInfo.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodConcurrencyInfo.java Tue Jul  1 21:13:25 2008
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.assembler.classic;
+
+public class MethodConcurrencyInfo extends MethodAttributeInfo {
+
+    public String description;
+    public String concurrencyAttribute;
+
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java Tue Jul  1 21:13:25 2008
@@ -442,4 +442,10 @@
         return s;
     }
 
+    public static String toString(MethodConcurrencyInfo i) {
+        String s = toString(i.methods.get(0));
+        s += " " + i.concurrencyAttribute;
+        return s;
+    }
+
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java Tue Jul  1 21:13:25 2008
@@ -48,7 +48,7 @@
 import org.apache.openejb.jee.MessageDrivenBean;
 import org.apache.openejb.jee.MethodParams;
 import org.apache.openejb.jee.MethodPermission;
-import org.apache.openejb.jee.MethodTransaction;
+import org.apache.openejb.jee.MethodAttribute;
 import org.apache.openejb.jee.NamedMethod;
 import org.apache.openejb.jee.PersistenceContextRef;
 import org.apache.openejb.jee.PersistenceContextType;
@@ -77,6 +77,9 @@
 import org.apache.openejb.jee.WebApp;
 import org.apache.openejb.jee.WebserviceDescription;
 import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.jee.ConcurrencyAttribute;
+import org.apache.openejb.jee.ContainerConcurrency;
+import org.apache.openejb.jee.ConcurrencyType;
 import static org.apache.openejb.util.Join.join;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
@@ -114,6 +117,8 @@
 import javax.ejb.TransactionManagement;
 import javax.ejb.TransactionManagementType;
 import javax.ejb.Singleton;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
 import javax.interceptor.ExcludeClassInterceptors;
 import javax.interceptor.ExcludeDefaultInterceptors;
 import javax.interceptor.Interceptors;
@@ -705,7 +710,7 @@
                 processApplicationExceptions(clazz, assemblyDescriptor);
 
                 if (bean.getTransactionType() == TransactionType.CONTAINER) {
-                    processTransactionAttributes(clazz, ejbName, assemblyDescriptor, inheritedClassFinder);
+                    processAttributes(new TransactionAttributeHandler(assemblyDescriptor, ejbName), clazz, inheritedClassFinder);
                 }
 
                 processSecurityAnnotations(clazz, ejbName, ejbModule, inheritedClassFinder, bean);
@@ -825,6 +830,30 @@
                         SessionBean sessionBean = (SessionBean) remoteBean;
 
                         processSessionInterfaces(sessionBean, clazz, ejbModule);
+
+                        if (sessionBean.getSessionType() == SessionType.SINGLETON) {
+
+                            if (sessionBean.getConcurrencyType() == null) {
+                                ConcurrencyManagement tx = getInheritableAnnotation(clazz, ConcurrencyManagement.class);
+                                ConcurrencyManagementType concurrencyType = ConcurrencyManagementType.CONTAINER;
+                                if (tx != null) {
+                                    concurrencyType = tx.value();
+                                }
+                                switch (concurrencyType) {
+                                    case BEAN:
+                                        sessionBean.setConcurrencyType(ConcurrencyType.BEAN);
+                                        break;
+                                    case CONTAINER:
+                                        sessionBean.setConcurrencyType(ConcurrencyType.CONTAINER);
+                                        break;
+                                }
+                            }
+
+
+                            if (sessionBean.getConcurrencyType() == ConcurrencyType.CONTAINER) {
+                                processAttributes(new ConcurrencyAttributeHandler(assemblyDescriptor, ejbName), clazz, inheritedClassFinder);
+                            }
+                        }
                     }
                 }
 
@@ -1203,52 +1232,127 @@
             return classPermissions;
         }
 
-        private void processTransactionAttributes(Class<?> clazz, String ejbName, AssemblyDescriptor assemblyDescriptor, ClassFinder classFinder) {
+        public interface AnnotationHandler<A extends Annotation> {
+            public Class<A> getAnnotationClass();
 
-            Map<String, List<MethodTransaction>> methodTransactions = assemblyDescriptor.getMethodTransactions(ejbName);
+            public Map<String, List<MethodAttribute>> getExistingDeclarations();
+
+            public void addClassLevelDeclaration(A annotation, Class clazz);
+
+            public void addMethodLevelDeclaration(A annotation, Method method);
+        }
+
+        public static class TransactionAttributeHandler implements AnnotationHandler<TransactionAttribute> {
+
+            private final AssemblyDescriptor assemblyDescriptor;
+            private final String ejbName;
+
+            public TransactionAttributeHandler(AssemblyDescriptor assemblyDescriptor, String ejbName) {
+                this.assemblyDescriptor = assemblyDescriptor;
+                this.ejbName = ejbName;
+            }
+
+            public Map<String, List<MethodAttribute>> getExistingDeclarations(){
+                return assemblyDescriptor.getMethodTransactionMap(ejbName);
+            }
+
+            public void addClassLevelDeclaration(TransactionAttribute attribute, Class type) {
+                ContainerTransaction ctx = new ContainerTransaction(cast(attribute.value()), type.getName(), ejbName, "*");
+                assemblyDescriptor.getContainerTransaction().add(ctx);
+            }
+
+            public void addMethodLevelDeclaration(TransactionAttribute attribute, Method method) {
+                ContainerTransaction ctx = new ContainerTransaction(cast(attribute.value()), ejbName, method);
+                assemblyDescriptor.getContainerTransaction().add(ctx);
+            }
+
+            public Class<TransactionAttribute> getAnnotationClass() {
+                return TransactionAttribute.class;
+            }
+
+            private TransAttribute cast(TransactionAttributeType transactionAttributeType) {
+                return TransAttribute.valueOf(transactionAttributeType.toString());
+            }
+        }
+
+        public static class ConcurrencyAttributeHandler implements AnnotationHandler<javax.ejb.Lock> {
+
+            private final AssemblyDescriptor assemblyDescriptor;
+            private final String ejbName;
+
+            public ConcurrencyAttributeHandler(AssemblyDescriptor assemblyDescriptor, String ejbName) {
+                this.assemblyDescriptor = assemblyDescriptor;
+                this.ejbName = ejbName;
+            }
+
+            public Map<String, List<MethodAttribute>> getExistingDeclarations(){
+                return assemblyDescriptor.getMethodConcurrencyMap(ejbName);
+            }
+
+            public void addClassLevelDeclaration(javax.ejb.Lock attribute, Class type) {
+                ContainerConcurrency ctx = new ContainerConcurrency(cast(attribute.value()), type.getName(), ejbName, "*");
+                assemblyDescriptor.getContainerConcurrency().add(ctx);
+            }
+
+            public void addMethodLevelDeclaration(javax.ejb.Lock attribute, Method method) {
+                ContainerConcurrency ctx = new ContainerConcurrency(cast(attribute.value()), ejbName, method);
+                assemblyDescriptor.getContainerConcurrency().add(ctx);
+            }
+
+            public Class<javax.ejb.Lock> getAnnotationClass() {
+                return javax.ejb.Lock.class;
+            }
+
+            private ConcurrencyAttribute cast(javax.ejb.LockType lockType) {
+                return ConcurrencyAttribute.valueOf(lockType.toString());
+            }
+        }
+
+        private <A extends Annotation> void processAttributes(AnnotationHandler<A> handler, Class<?> clazz, ClassFinder classFinder) {
+            Map<String, List<MethodAttribute>> existingDeclarations = handler.getExistingDeclarations();
 
             // SET THE DEFAULT
-            if (!hasMethodTransaction("*", null, methodTransactions)) {
+            final Class<A> annotationClass = handler.getAnnotationClass();
+
+            if (!hasMethodAttribute("*", null, existingDeclarations)) {
                 for (Class<?> type : ancestors(clazz)) {
-                    if (!hasMethodTransaction("*", type, methodTransactions)){
-                        TransactionAttribute attribute = type.getAnnotation(TransactionAttribute.class);
+                    if (!hasMethodAttribute("*", type, existingDeclarations)){
+                        A attribute = type.getAnnotation(annotationClass);
                         if (attribute != null) {
-                            ContainerTransaction ctx = new ContainerTransaction(cast(attribute.value()), type.getName(), ejbName, "*");
-                            assemblyDescriptor.getContainerTransaction().add(ctx);
+                            handler.addClassLevelDeclaration(attribute, type);
                         }
                     }
                 }
-
             }
 
 
-            List<Method> methods = classFinder.findAnnotatedMethods(TransactionAttribute.class);
+            List<Method> methods = classFinder.findAnnotatedMethods(annotationClass);
             for (Method method : methods) {
-                TransactionAttribute attribute = method.getAnnotation(TransactionAttribute.class);
-                if (!methodTransactions.containsKey(method.getName())) {
+                A attribute = method.getAnnotation(annotationClass);
+                if (!existingDeclarations.containsKey(method.getName())) {
                     // no method with this name in descriptor
-                    addContainerTransaction(attribute, ejbName, method, assemblyDescriptor);
+                    handler.addMethodLevelDeclaration(attribute, method);
                 } else {
                     // method name already declared
-                    List<MethodTransaction> list = methodTransactions.get(method.getName());
-                    for (MethodTransaction mtx : list) {
+                    List<MethodAttribute> list = existingDeclarations.get(method.getName());
+                    for (MethodAttribute mtx : list) {
                         MethodParams methodParams = mtx.getMethodParams();
                         if (methodParams == null) {
                             // params not specified, so this is more specific
-                            addContainerTransaction(attribute, ejbName, method, assemblyDescriptor);
+                            handler.addMethodLevelDeclaration(attribute, method);
                         } else {
                             List<String> params1 = methodParams.getMethodParam();
                             String[] params2 = asStrings(method.getParameterTypes());
                             if (params1.size() != params2.length) {
                                 // params not the same
-                                addContainerTransaction(attribute, ejbName, method, assemblyDescriptor);
+                                handler.addMethodLevelDeclaration(attribute, method);
                             } else {
                                 for (int i = 0; i < params1.size(); i++) {
                                     String a = params1.get(i);
                                     String b = params2[i];
                                     if (!a.equals(b)) {
                                         // params not the same
-                                        addContainerTransaction(attribute, ejbName, method, assemblyDescriptor);
+                                        handler.addMethodLevelDeclaration(attribute, method);
                                         break;
                                     }
                                 }
@@ -1259,23 +1363,19 @@
             }
         }
 
-        public static void main(String[] args) {
-            System.out.println(null + "");
+        private boolean hasMethodAttribute(String methodName, Class clazz, Map<String, List<MethodAttribute>> map){
+            return getMethodAttribute(methodName, clazz, map) != null;
         }
 
-        private boolean hasMethodTransaction(String methodName, Class clazz, Map<String, List<MethodTransaction>> map){
-            return getMethodTransaction(methodName, clazz, map) != null;
-        }
-
-        private MethodTransaction getMethodTransaction(String methodName, Class clazz, Map<String, List<MethodTransaction>> map) {
-            List<MethodTransaction> methodTransactions = map.get(methodName);
-            if (methodTransactions == null) return null;
+        private MethodAttribute getMethodAttribute(String methodName, Class clazz, Map<String, List<MethodAttribute>> map) {
+            List<MethodAttribute> methodAttributes = map.get(methodName);
+            if (methodAttributes == null) return null;
 
-            for (MethodTransaction methodTransaction : methodTransactions) {
+            for (MethodAttribute methodAttribute : methodAttributes) {
                 String className = (clazz != null) ? clazz.getName() : null + "";
 
-                if (className.equals(methodTransaction.getClassName() + "")) {
-                    return methodTransaction;
+                if (className.equals(methodAttribute.getClassName() + "")) {
+                    return methodAttribute;
                 }
             }
             return null;
@@ -2057,11 +2157,6 @@
             return new ArrayList<Class<?>>(classes);
         }
 
-        private void addContainerTransaction(TransactionAttribute attribute, String ejbName, Method method, AssemblyDescriptor assemblyDescriptor) {
-            ContainerTransaction ctx = new ContainerTransaction(cast(attribute.value()), ejbName, method);
-            assemblyDescriptor.getContainerTransaction().add(ctx);
-        }
-
         private String[] asStrings(Class[] types) {
             List<String> names = new ArrayList<String>();
             for (Class clazz : types) {
@@ -2070,10 +2165,6 @@
             return names.toArray(new String[names.size()]);
         }
 
-        private TransAttribute cast(TransactionAttributeType transactionAttributeType) {
-            return TransAttribute.valueOf(transactionAttributeType.toString());
-        }
-
         private <T> T getFirst(List<T> list) {
             if (list.size() > 0) {
                 return list.get(0);

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java Tue Jul  1 21:13:25 2008
@@ -40,6 +40,7 @@
 import org.apache.openejb.assembler.classic.ApplicationExceptionInfo;
 import org.apache.openejb.assembler.classic.JndiNameInfo;
 import org.apache.openejb.assembler.classic.SingletonBeanInfo;
+import org.apache.openejb.assembler.classic.MethodConcurrencyInfo;
 import org.apache.openejb.jee.ActivationConfig;
 import org.apache.openejb.jee.ActivationConfigProperty;
 import org.apache.openejb.jee.CallbackMethod;
@@ -74,6 +75,8 @@
 import org.apache.openejb.jee.ExcludeList;
 import org.apache.openejb.jee.ResultTypeMapping;
 import org.apache.openejb.jee.ApplicationException;
+import org.apache.openejb.jee.ConcurrencyType;
+import org.apache.openejb.jee.ContainerConcurrency;
 import org.apache.openejb.jee.oejb3.EjbDeployment;
 import org.apache.openejb.jee.oejb3.ResourceLink;
 import org.apache.openejb.jee.oejb3.Jndi;
@@ -172,6 +175,7 @@
             initMethodPermissions(jar, ejbds, ejbJar);
             initExcludesList(jar, ejbds, ejbJar);
             initMethodTransactions(jar, ejbds, ejbJar);
+            initMethodConcurrency(jar, ejbds, ejbJar);
             initApplicationExceptions(jar, ejbJar);
 
             for (EnterpriseBeanInfo bean : ejbJar.enterpriseBeans) {
@@ -315,6 +319,19 @@
         }
     }
 
+    private void initMethodConcurrency(EjbModule jar, Map ejbds, EjbJarInfo ejbJarInfo) {
+
+        List<ContainerConcurrency> containerConcurrency = jar.getEjbJar().getAssemblyDescriptor().getContainerConcurrency();
+        for (ContainerConcurrency att : containerConcurrency) {
+            MethodConcurrencyInfo info = new MethodConcurrencyInfo();
+
+            info.description = att.getDescription();
+            info.concurrencyAttribute = att.getConcurrencyAttribute().toString();
+            info.methods.addAll(getMethodInfos(att.getMethod(), ejbds));
+            ejbJarInfo.methodConcurrency.add(info);
+        }
+    }
+
     private void initApplicationExceptions(EjbModule jar, EjbJarInfo ejbJarInfo) {
         for (ApplicationException applicationException : jar.getEjbJar().getAssemblyDescriptor().getApplicationException()) {
             ApplicationExceptionInfo info = new ApplicationExceptionInfo();
@@ -453,6 +470,8 @@
 
         } else if (s.getSessionType() == SessionType.SINGLETON) {
             bean = new SingletonBeanInfo();
+            ConcurrencyType type = s.getConcurrencyType();
+            bean.concurrencyType = (type != null) ? type.toString() : ConcurrencyType.CONTAINER.toString();
         } else {
             bean = new StatelessBeanInfo();
         }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java Tue Jul  1 21:13:25 2008
@@ -96,6 +96,7 @@
     private EjbTimerService ejbTimerService;
 
     private boolean isBeanManagedTransaction;
+    private boolean isBeanManagedConcurrency;
     private boolean isReentrant;
     private Container container;
     private EJBHome ejbHomeRef;
@@ -120,6 +121,7 @@
 
     private final Map<Method, Collection<String>> methodPermissions = new HashMap<Method, Collection<String>>();
     private final Map<Method, Byte> methodTransactionAttributes = new HashMap<Method, Byte>();
+    private final Map<Method, Byte> methodConcurrencyAttributes = new HashMap<Method, Byte>();
     private final Map<Method, TransactionPolicy> methodTransactionPolicies = new HashMap<Method, TransactionPolicy>();
     private final Map<Method, List<InterceptorData>> methodInterceptors = new HashMap<Method, List<InterceptorData>>();
     private final List<InterceptorData> callbackInterceptors = new ArrayList<InterceptorData>();
@@ -367,6 +369,21 @@
         }
     }
 
+    public byte getConcurrencyAttribute(Method method) {
+        Byte byteWrapper = methodConcurrencyAttributes.get(method);
+
+        if (byteWrapper == null){
+            Method beanMethod = getMatchingBeanMethod(method);
+            byteWrapper = methodConcurrencyAttributes.get(beanMethod);
+        }
+
+        if (byteWrapper == null) {
+            return WRITE_LOCK;
+        } else {
+            return byteWrapper;
+        }
+    }
+
     public TransactionPolicy getTransactionPolicy(Method method) {
         TransactionPolicy policy = methodTransactionPolicies.get(method);
         if (policy == null && !isBeanManagedTransaction) {
@@ -433,6 +450,10 @@
         return isBeanManagedTransaction;
     }
 
+    public boolean isBeanManagedConcurrency() {
+        return isBeanManagedConcurrency;
+    }
+
     public Class getHomeInterface() {
         return homeInterface;
     }
@@ -563,6 +584,10 @@
         isBeanManagedTransaction = value;
     }
 
+    public void setBeanManagedConcurrency(boolean beanManagedConcurrency) {
+        isBeanManagedConcurrency = beanManagedConcurrency;
+    }
+
     public Context getJndiEnc() {
         return context.getJndiContext();
     }
@@ -603,6 +628,17 @@
         securityRoleReferenceMap.put(securityRoleReference, linkedRoleName);
     }
 
+    public void setMethodConcurrencyAttribute(Method method, String concurrencyAttribute) {
+        if ("Read".equals(concurrencyAttribute)){
+            this.methodConcurrencyAttributes.put(method, READ_LOCK);
+        } else if ("Write".equals(concurrencyAttribute)){
+            this.methodConcurrencyAttributes.put(method, WRITE_LOCK);
+        } else {
+            throw new IllegalArgumentException("Unsupported MethodConcurrencyAttribute '"+concurrencyAttribute+"'");
+        }
+    }
+
+
     public void setMethodTransactionAttribute(Method method, String transAttribute) throws OpenEJBException {
         Byte byteValue = null;
         TransactionPolicy policy = null;

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java Tue Jul  1 21:13:25 2008
@@ -208,7 +208,8 @@
         txContext.callContext = callContext;
 
 
-        boolean read = false; // TODO: get meta data from DeploymentInfo
+        boolean read = deploymentInfo.getConcurrencyAttribute(runMethod) == DeploymentInfo.READ_LOCK;
+        
         final Lock lock = aquireLock(read, instance);
 
         Object returnValue;

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonInstanceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonInstanceManager.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonInstanceManager.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonInstanceManager.java Tue Jul  1 21:13:25 2008
@@ -186,7 +186,7 @@
                 }
 
                 ReadWriteLock lock;
-                if (false){ // TODO: Get metadata from DeploymentInfo
+                if (deploymentInfo.isBeanManagedConcurrency()){
                     // Bean-Managed Concurrency
                     lock = new BeanManagedLock();
                 } else {

Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ConcurrencyAttributesTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ConcurrencyAttributesTest.java?rev=673270&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ConcurrencyAttributesTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/ConcurrencyAttributesTest.java Tue Jul  1 21:13:25 2008
@@ -0,0 +1,206 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.assembler.classic;
+
+import junit.framework.TestCase;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.core.CoreDeploymentInfo;
+import org.apache.openejb.jee.ConcurrencyAttribute;
+import org.apache.openejb.jee.ContainerConcurrency;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
+
+import javax.ejb.Local;
+import javax.ejb.Lock;
+import static javax.ejb.LockType.READ;
+import static javax.ejb.LockType.WRITE;
+import javax.ejb.Remote;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConcurrencyAttributesTest extends TestCase {
+    private Map<Method, MethodAttributeInfo> attributes;
+
+    public void test() throws Exception {
+        Assembler assembler = new Assembler();
+        ConfigurationFactory config = new ConfigurationFactory();
+
+        assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
+        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
+        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
+
+        EjbJar ejbJar = new EjbJar();
+        ejbJar.addEnterpriseBean(new SingletonBean(Color.class));
+        ejbJar.addEnterpriseBean(new SingletonBean(Red.class));
+        ejbJar.addEnterpriseBean(new SingletonBean(Crimson.class));
+        ejbJar.addEnterpriseBean(new SingletonBean(Scarlet.class));
+        List<ContainerConcurrency> declared = ejbJar.getAssemblyDescriptor().getContainerConcurrency();
+
+        declared.add(new ContainerConcurrency(ConcurrencyAttribute.WRITE, "*", "*", "*"));
+        declared.add(new ContainerConcurrency(ConcurrencyAttribute.READ, "*", "Crimson", "*"));
+        declared.add(new ContainerConcurrency(ConcurrencyAttribute.READ, Color.class.getName(), "Scarlet", "*"));
+        declared.add(new ContainerConcurrency(ConcurrencyAttribute.READ, Red.class.getName(), "Scarlet", "red"));
+        declared.add(new ContainerConcurrency(ConcurrencyAttribute.WRITE, "Scarlet", Scarlet.class.getMethod("scarlet")));
+
+        EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
+        assembler.createApplication(ejbJarInfo);
+
+        loadAttributes(ejbJarInfo, "Color");
+
+        assertAttribute("Read", Color.class.getMethod("color"));
+        assertAttribute("Write", Color.class.getMethod("color", Object.class));
+        assertAttribute("Write", Color.class.getMethod("color", String.class));
+        assertAttribute("Write", Color.class.getMethod("color", Boolean.class));
+        assertAttribute("Write", Color.class.getMethod("color", Integer.class));
+
+        loadAttributes(ejbJarInfo, "Red");
+
+        assertAttribute("Read", Red.class.getMethod("color"));
+        assertAttribute("Write", Red.class.getMethod("color", Object.class));
+        assertAttribute("Write", Red.class.getMethod("color", String.class));
+        assertAttribute("Write", Red.class.getMethod("color", Boolean.class));
+        assertAttribute("Write", Red.class.getMethod("color", Integer.class));
+        assertAttribute("Write", Red.class.getMethod("red"));
+        assertAttribute("Write", Red.class.getMethod("red", Object.class));
+        assertAttribute("Write", Red.class.getMethod("red", String.class));
+
+        loadAttributes(ejbJarInfo, "Crimson");
+
+        assertAttribute("Read", Crimson.class.getMethod("color"));
+        assertAttribute("Read", Crimson.class.getMethod("color", Object.class));
+        assertAttribute("Read", Crimson.class.getMethod("color", String.class));
+        assertAttribute("Read", Crimson.class.getMethod("color", Boolean.class));
+        assertAttribute("Read", Crimson.class.getMethod("color", Integer.class));
+        assertAttribute("Write", Crimson.class.getMethod("red"));
+        assertAttribute("Read", Crimson.class.getMethod("red", Object.class));
+        assertAttribute("Read", Crimson.class.getMethod("red", String.class));
+        assertAttribute("Write", Crimson.class.getMethod("crimson"));
+        assertAttribute("Read", Crimson.class.getMethod("crimson", String.class));
+
+        loadAttributes(ejbJarInfo, "Scarlet");
+
+        assertAttribute("Read", Scarlet.class.getMethod("color"));
+        assertAttribute("Write", Scarlet.class.getMethod("color", Object.class));
+        assertAttribute("Read", Scarlet.class.getMethod("color", String.class));
+        assertAttribute("Read", Scarlet.class.getMethod("color", Boolean.class));
+        assertAttribute("Read", Scarlet.class.getMethod("color", Integer.class));
+        assertAttribute("Write", Scarlet.class.getMethod("red"));
+        assertAttribute("Read", Scarlet.class.getMethod("red", Object.class));
+        assertAttribute("Read", Scarlet.class.getMethod("red", String.class));
+        assertAttribute("Write", Scarlet.class.getMethod("scarlet"));
+        assertAttribute("Read", Scarlet.class.getMethod("scarlet", String.class));
+
+    }
+
+    private void loadAttributes(EjbJarInfo ejbJarInfo, String deploymentId) {
+        ContainerSystem system = SystemInstance.get().getComponent(ContainerSystem.class);
+        CoreDeploymentInfo deploymentInfo = (CoreDeploymentInfo) system.getDeploymentInfo(deploymentId);
+        List<MethodConcurrencyInfo> infos = MethodConcurrencyBuilder.normalize(ejbJarInfo.methodConcurrency);
+        attributes = MethodInfoUtil.resolveAttributes(infos, deploymentInfo);
+    }
+
+    private void assertAttribute(String attribute, Method method) {
+        MethodConcurrencyInfo info = (MethodConcurrencyInfo) attributes.get(method);
+        assertEquals(method.toString(), attribute, info.concurrencyAttribute);
+    }
+
+    @Local
+    public static interface ColorLocal {
+    }
+
+    @Remote
+    public static interface ColorRemote {
+    }
+
+    @Lock(WRITE)
+    public static class Color implements ColorLocal, ColorRemote {
+
+
+        @Lock(READ)
+        public void color() {
+        }
+
+
+        @Lock(WRITE)
+        public void color(Object o) {
+        }
+
+        public void color(String s) {
+        }
+
+        public void color(Boolean b) {
+        }
+
+        public void color(Integer i) {
+        }
+    }
+
+
+    public static class Red extends Color {
+
+        public void color(Object o) {
+            super.color(o);
+        }
+
+        @Lock(WRITE)
+        public void red() {
+        }
+
+        public void red(Object o) {
+        }
+
+        public void red(String s) {
+        }
+
+    }
+
+    @Lock(READ)
+    public static class Crimson extends Red {
+
+
+        public void color() {
+        }
+
+        public void color(String s) {
+        }
+
+        @Lock(WRITE)
+        public void crimson() {
+        }
+
+        public void crimson(String s) {
+        }
+    }
+
+    @Lock(READ)
+    public static class Scarlet extends Red {
+
+        @Lock(WRITE)
+        public void scarlet() {
+        }
+
+        public void scarlet(String s) {
+        }
+    }
+
+}

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java Tue Jul  1 21:13:25 2008
@@ -57,6 +57,7 @@
         "securityRole",
         "methodPermission",
         "containerTransaction",
+        "containerConcurrency",
         "interceptorBinding",
         "messageDestination",
         "excludeList",
@@ -70,6 +71,8 @@
     protected List<MethodPermission> methodPermission;
     @XmlElement(name = "container-transaction", required = true)
     protected List<ContainerTransaction> containerTransaction;
+    @XmlElement(name = "container-concurrency", required = true)
+    protected List<ContainerConcurrency> containerConcurrency;
     @XmlElement(name = "interceptor-binding", required = true)
     protected List<InterceptorBinding> interceptorBinding;
     @XmlElement(name = "message-destination", required = true)
@@ -104,19 +107,36 @@
         return this.containerTransaction;
     }
 
-    public Map<String,List<MethodTransaction>> getMethodTransactions(String ejbName) {
-        Map<String,List<MethodTransaction>> methods = new LinkedHashMap<String,List<MethodTransaction>>();
-        for (ContainerTransaction transaction : getContainerTransaction()) {
+    public List<ContainerConcurrency> getContainerConcurrency() {
+        if (containerConcurrency == null) {
+            containerConcurrency = new ArrayList<ContainerConcurrency>();
+        }
+        return this.containerConcurrency;
+    }
+
+    public Map<String,List<MethodAttribute>> getMethodTransactionMap(String ejbName) {
+        return getMethodAttributes(ejbName, getContainerTransaction());
+    }
+
+    public Map<String,List<MethodAttribute>> getMethodConcurrencyMap(String ejbName) {
+        return getMethodAttributes(ejbName, getContainerConcurrency());
+    }
+
+    private Map<String, List<MethodAttribute>> getMethodAttributes(String ejbName, List<? extends AttributeBinding> bindings) {
+
+        Map<String,List<MethodAttribute>> methods = new LinkedHashMap<String,List<MethodAttribute>>();
+
+        for (AttributeBinding<?> binding : bindings) {
 
-            for (Method method : transaction.getMethod()) {
+            for (Method method : binding.getMethod()) {
                 if (method.getEjbName().equals(ejbName)){
                     String methodName = method.getMethodName();
-                    List<MethodTransaction> list = methods.get(methodName);
+                    List<MethodAttribute> list = methods.get(methodName);
                     if (list == null){
-                        list = new ArrayList<MethodTransaction>();
+                        list = new ArrayList<MethodAttribute>();
                         methods.put(methodName, list);
                     }
-                    list.add(new MethodTransaction(transaction.getTransAttribute(), method));
+                    list.add(new MethodAttribute(binding.getAttribute(), method));
                 }
             }
         }

Added: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AttributeBinding.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AttributeBinding.java?rev=673270&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AttributeBinding.java (added)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AttributeBinding.java Tue Jul  1 21:13:25 2008
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.jee;
+
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface AttributeBinding<A> {
+
+    public A getAttribute();
+
+    public List<Method> getMethod();
+
+}

Added: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ConcurrencyAttribute.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ConcurrencyAttribute.java?rev=673270&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ConcurrencyAttribute.java (added)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ConcurrencyAttribute.java Tue Jul  1 21:13:25 2008
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.jee;
+
+import javax.xml.bind.annotation.XmlEnumValue;
+
+public enum ConcurrencyAttribute {
+    @XmlEnumValue("Read") READ("Read"),
+    @XmlEnumValue("Write") WRITE("Write");
+
+    private final String name;
+
+    ConcurrencyAttribute(String name) {
+       this.name = name;
+   }
+
+    public String toString() {
+        return name;
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ConcurrencyType.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ConcurrencyType.java?rev=673270&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ConcurrencyType.java (added)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ConcurrencyType.java Tue Jul  1 21:13:25 2008
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.jee;
+
+import javax.xml.bind.annotation.XmlEnumValue;
+
+/**
+ * The concurrency-typeType specifies an enterprise bean's
+ * concurrency management type.
+ * <p/>
+ * The concurrency-type must be one of the two following:
+ * <p/>
+ * Bean
+ * Container
+ */
+public enum ConcurrencyType {
+    @XmlEnumValue("Bean") BEAN,
+    @XmlEnumValue("Container") CONTAINER;
+}

Added: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ContainerConcurrency.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ContainerConcurrency.java?rev=673270&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ContainerConcurrency.java (added)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ContainerConcurrency.java Tue Jul  1 21:13:25 2008
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.jee;
+
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import java.util.List;
+import java.util.ArrayList;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "container-concurrencyType", propOrder = {
+        "descriptions",
+        "method",
+        "concurrencyAttribute"
+        })
+public class ContainerConcurrency implements AttributeBinding<ConcurrencyAttribute>{
+
+    @XmlElement(required = true)
+    protected List<Method> method;
+    @XmlElement(name = "concurrency-attribute", required = true)
+    protected ConcurrencyAttribute concurrencyAttribute;
+    @XmlAttribute
+    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+    @XmlID
+    protected String id;
+
+    @XmlTransient
+    protected TextMap description = new TextMap();
+
+    @XmlElement(name = "description", required = true)
+    public Text[] getDescriptions() {
+        return description.toArray();
+    }
+
+    public ContainerConcurrency() {
+    }
+
+    public ContainerConcurrency(ConcurrencyAttribute concurrencyAttribute, String className, String ejbName, String methodName) {
+        this(concurrencyAttribute, new Method(ejbName, className, methodName));
+    }
+
+    public ContainerConcurrency(ConcurrencyAttribute concurrencyAttribute, String ejbName, java.lang.reflect.Method method) {
+        this(concurrencyAttribute, new Method(ejbName, method));
+    }
+
+    public ContainerConcurrency(ConcurrencyAttribute concurrencyAttribute, Method method) {
+        this.concurrencyAttribute = concurrencyAttribute;
+        getMethod().add(method);
+    }
+
+    public void setDescriptions(Text[] text) {
+        description.set(text);
+    }
+
+    public String getDescription() {
+        return description.get();
+    }
+
+    public List<Method> getMethod() {
+        if (method == null) {
+            method = new ArrayList<Method>();
+        }
+        return this.method;
+    }
+
+    public ConcurrencyAttribute getAttribute() {
+        return concurrencyAttribute;
+    }
+
+    public ConcurrencyAttribute getConcurrencyAttribute() {
+        return concurrencyAttribute;
+    }
+
+    public void setConcurrencyAttribute(ConcurrencyAttribute value) {
+        this.concurrencyAttribute = value;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String value) {
+        this.id = value;
+    }
+}

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ContainerTransaction.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ContainerTransaction.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ContainerTransaction.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ContainerTransaction.java Tue Jul  1 21:13:25 2008
@@ -45,7 +45,7 @@
         "method",
         "transAttribute"
         })
-public class ContainerTransaction {
+public class ContainerTransaction implements AttributeBinding<TransAttribute> {
 
     @XmlElement(required = true)
     protected List<Method> method;
@@ -95,6 +95,10 @@
         return this.method;
     }
 
+    public TransAttribute getAttribute() {
+        return transAttribute;
+    }
+
     public TransAttribute getTransAttribute() {
         return transAttribute;
     }

Copied: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java (from r672456, openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodTransaction.java)
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java?p2=openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java&p1=openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodTransaction.java&r1=672456&r2=673270&rev=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodTransaction.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java Tue Jul  1 21:13:25 2008
@@ -19,16 +19,16 @@
 /**
  * @version $Rev$ $Date$
  */
-public class MethodTransaction {
+public class MethodAttribute<A> {
     private final Method method;
-    private final TransAttribute attribute;
+    private final A attribute;
 
-    public MethodTransaction(TransAttribute attribute, Method method) {
+    public MethodAttribute(A attribute, Method method) {
         this.attribute = attribute;
         this.method = method;
     }
 
-    public TransAttribute getAttribute() {
+    public A getAttribute() {
         return attribute;
     }
 

Propchange: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author Id Revision HeadURL

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/SessionBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/SessionBean.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/SessionBean.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/SessionBean.java Tue Jul  1 21:13:25 2008
@@ -113,6 +113,7 @@
         "initMethod",
         "removeMethod",
         "transactionType",
+        "concurrencyType",
         "aroundInvoke",
         "envEntry",
         "ejbRef",
@@ -165,6 +166,8 @@
     protected List<RemoveMethod> removeMethod;
     @XmlElement(name = "transaction-type")
     protected TransactionType transactionType;
+    @XmlElement(name = "concurrency-type")
+    protected ConcurrencyType concurrencyType;
     @XmlElement(name = "around-invoke", required = true)
     protected List<AroundInvoke> aroundInvoke;
     @XmlElement(name = "env-entry", required = true)
@@ -420,10 +423,18 @@
         return transactionType;
     }
 
+    public ConcurrencyType getConcurrencyType() {
+        return concurrencyType;
+    }
+
     public void setTransactionType(TransactionType value) {
         this.transactionType = value;
     }
 
+    public void setConcurrencyType(ConcurrencyType value) {
+        this.concurrencyType = value;
+    }
+
     public List<AroundInvoke> getAroundInvoke() {
         if (aroundInvoke == null) {
             aroundInvoke = new ArrayList<AroundInvoke>();

Modified: openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java?rev=673270&r1=673269&r2=673270&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java Tue Jul  1 21:13:25 2008
@@ -45,7 +45,7 @@
  * @version $Revision$ $Date$
  */
 public class JeeTest extends TestCase {
-    public void XtestEjbJar() throws Exception {
+    public void testEjbJar() throws Exception {
         String fileName = "ejb-jar-example1.xml";
 //        String fileName = "ejb-jar-empty.xml";
 



Mime
View raw message