You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ad...@apache.org on 2007/01/19 01:41:28 UTC

svn commit: r497662 - in /incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core: ./ entity/ mdb/ stateful/ stateless/

Author: adc
Date: Thu Jan 18 16:41:27 2007
New Revision: 497662

URL: http://svn.apache.org/viewvc?view=rev&rev=497662
Log:
Another context and states are final statics

Added:
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java   (with props)
Modified:
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/BaseContext.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/BaseSessionContext.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContext.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContext.java

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/BaseContext.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/BaseContext.java?view=diff&rev=497662&r1=497661&r2=497662
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/BaseContext.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/BaseContext.java Thu Jan 18 16:41:27 2007
@@ -45,26 +45,20 @@
     private final SecurityService securityService;
     private final TransactionManager transactionManager;
     private State state;
-    protected final State[] states = new State[Operation.values().length];
+    protected static State[] states = new State[Operation.values().length];
 
     public BaseContext(TransactionManager transactionManager, SecurityService securityService) {
         this.transactionManager = transactionManager;
         this.securityService = securityService;
         this.userTransaction = new CoreUserTransaction(transactionManager);
-
-        init();
     }
 
     protected BaseContext(TransactionManager transactionManager, SecurityService securityService, UserTransaction userTransaction) {
         this.transactionManager = transactionManager;
         this.securityService = securityService;
         this.userTransaction = userTransaction;
-
-        init();
     }
 
-    protected abstract void init();
-
     public void setOperation(Operation operation) {
         State state = states[operation.ordinal()];
 
@@ -98,27 +92,27 @@
     }
 
     public Principal getCallerPrincipal() {
-        return state.getCallerPrincipal();
+        return state.getCallerPrincipal(securityService);
     }
 
     public boolean isCallerInRole(Identity identity) {
         return state.isCallerInRole(identity);
     }
 
-    public boolean isCallerInRole(String transOID) {
-        return state.isCallerInRole(transOID);
+    public boolean isCallerInRole(String roleName) {
+        return state.isCallerInRole(securityService, roleName);
     }
 
     public UserTransaction getUserTransaction() throws IllegalStateException {
-        return state.getUserTransaction();
+        return state.getUserTransaction(userTransaction);
     }
 
     public void setRollbackOnly() throws IllegalStateException {
-        state.setRollbackOnly();
+        state.setRollbackOnly(transactionManager);
     }
 
     public boolean getRollbackOnly() throws IllegalStateException {
-        return state.getRollbackOnly();
+        return state.getRollbackOnly(transactionManager);
     }
 
     public TimerService getTimerService() throws IllegalStateException {
@@ -161,7 +155,7 @@
         return state.isTimerAccessAllowed();
     }
 
-    protected class State implements EJBContext {
+    protected static class State {
 
         public EJBHome getEJBHome() {
             ThreadContext threadContext = ThreadContext.getThreadContext();
@@ -177,24 +171,24 @@
             return di.getEJBLocalHome();
         }
 
-        public Properties getEnvironment() {
+        public final Properties getEnvironment() {
             throw new UnsupportedOperationException();
         }
 
-        public Identity getCallerIdentity() {
+        public final Identity getCallerIdentity() {
             throw new UnsupportedOperationException();
         }
 
-        public Principal getCallerPrincipal() {
+        public Principal getCallerPrincipal(SecurityService securityService) {
             Object securityIdentity = ThreadContext.getThreadContext().getSecurityIdentity();
             return (Principal) securityService.translateTo(securityIdentity, Principal.class);
         }
 
-        public boolean isCallerInRole(Identity identity) {
+        public final boolean isCallerInRole(Identity identity) {
             throw new UnsupportedOperationException();
         }
 
-        public boolean isCallerInRole(String roleName) {
+        public boolean isCallerInRole(SecurityService securityService, String roleName) {
             ThreadContext threadContext = ThreadContext.getThreadContext();
             CoreDeploymentInfo di = threadContext.getDeploymentInfo();
             List<String> physicalRoles = di.getPhysicalRole(roleName);
@@ -203,7 +197,7 @@
             return securityService.isCallerAuthorized(caller, physicalRoles);
         }
 
-        public UserTransaction getUserTransaction() throws IllegalStateException {
+        public UserTransaction getUserTransaction(UserTransaction userTransaction) throws IllegalStateException {
             ThreadContext threadContext = ThreadContext.getThreadContext();
             DeploymentInfo di = threadContext.getDeploymentInfo();
 
@@ -214,7 +208,7 @@
             }
         }
 
-        public void setRollbackOnly() throws IllegalStateException {
+        public void setRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
             ThreadContext threadContext = ThreadContext.getThreadContext();
             DeploymentInfo di = threadContext.getDeploymentInfo();
 
@@ -229,7 +223,7 @@
             }
         }
 
-        public boolean getRollbackOnly() throws IllegalStateException {
+        public boolean getRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
             ThreadContext threadContext = ThreadContext.getThreadContext();
             DeploymentInfo di = threadContext.getDeploymentInfo();
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/BaseSessionContext.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/BaseSessionContext.java?view=diff&rev=497662&r1=497661&r2=497662
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/BaseSessionContext.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/BaseSessionContext.java Thu Jan 18 16:41:27 2007
@@ -42,7 +42,6 @@
  */
 public abstract class BaseSessionContext extends BaseContext implements SessionContext {
 
-
     public BaseSessionContext(TransactionManager transactionManager, SecurityService securityService) {
         super(transactionManager, securityService);
     }
@@ -71,7 +70,7 @@
         return ((StatelessState) getState()).getInvokedBusinessInterface();
     }
 
-    protected class StatelessState extends State implements SessionContext {
+    protected static class StatelessState extends State {
 
         public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
             ThreadContext threadContext = ThreadContext.getThreadContext();
@@ -80,7 +79,7 @@
             EjbObjectProxyHandler handler = new StatelessEjbObjectHandler((RpcContainer) di.getContainer(), threadContext.getPrimaryKey(), di.getDeploymentID(), InterfaceType.EJB_LOCAL);
             handler.setLocal(true);
             try {
-                Class[] interfaces = new Class[]{di.getLocalInterface(), org.apache.openejb.core.ivm.IntraVmProxy.class};
+                Class[] interfaces = new Class[]{di.getLocalInterface(), IntraVmProxy.class};
                 return (EJBLocalObject) ProxyManager.newProxyInstance(interfaces, handler);
             } catch (IllegalAccessException iae) {
                 throw new InternalErrorException("Could not create IVM proxy for " + di.getLocalInterface() + " interface", iae);
@@ -93,7 +92,7 @@
 
             EjbObjectProxyHandler handler = new StatelessEjbObjectHandler((RpcContainer) di.getContainer(), threadContext.getPrimaryKey(), di.getDeploymentID(), InterfaceType.EJB_OBJECT);
             try {
-                Class[] interfaces = new Class[]{di.getRemoteInterface(), org.apache.openejb.core.ivm.IntraVmProxy.class};
+                Class[] interfaces = new Class[]{di.getRemoteInterface(), IntraVmProxy.class};
                 return (EJBObject) ProxyManager.newProxyInstance(interfaces, handler);
             } catch (IllegalAccessException iae) {
                 throw new InternalErrorException("Could not create IVM proxy for " + di.getLocalInterface() + " interface", iae);
@@ -140,7 +139,8 @@
     /**
      * Dependency injection methods (e.g., setSessionContext)
      */
-    protected final StatelessState INJECTION = new StatelessState() {
+    protected final static StatelessState INJECTION = new StatelessState() {
+
         public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
             throw new IllegalStateException();
         }
@@ -161,23 +161,23 @@
             throw new IllegalStateException();
         }
 
-        public Principal getCallerPrincipal() {
+        public Principal getCallerPrincipal(SecurityService securityService) {
             throw new IllegalStateException();
         }
 
-        public boolean isCallerInRole(String roleName) {
+        public boolean isCallerInRole(SecurityService securityService, String roleName) {
             throw new IllegalStateException();
         }
 
-        public UserTransaction getUserTransaction() throws IllegalStateException {
+        public UserTransaction getUserTransaction(UserTransaction userTransaction) throws IllegalStateException {
             throw new IllegalStateException();
         }
 
-        public void setRollbackOnly() throws IllegalStateException {
+        public void setRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
             throw new IllegalStateException();
         }
 
-        public boolean getRollbackOnly() throws IllegalStateException {
+        public boolean getRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
             throw new IllegalStateException();
         }
 
@@ -217,7 +217,8 @@
     /**
      * PostConstruct, Pre-Destroy lifecycle callback interceptor methods
      */
-    protected final StatelessState LIFECYCLE = new StatelessState() {
+    protected final static StatelessState LIFECYCLE = new StatelessState() {
+
         public MessageContext getMessageContext() throws IllegalStateException {
             throw new IllegalStateException();
         }
@@ -226,19 +227,19 @@
             throw new IllegalStateException();
         }
 
-        public Principal getCallerPrincipal() {
+        public Principal getCallerPrincipal(SecurityService securityService) {
             throw new IllegalStateException();
         }
 
-        public boolean isCallerInRole(String roleName) {
+        public boolean isCallerInRole(SecurityService securityService, String roleName) {
             throw new IllegalStateException();
         }
 
-        public void setRollbackOnly() throws IllegalStateException {
+        public void setRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
             throw new IllegalStateException();
         }
 
-        public boolean getRollbackOnly() throws IllegalStateException {
+        public boolean getRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
             throw new IllegalStateException();
         }
 
@@ -279,7 +280,8 @@
      * Business method from business interface or component interface; business
      * method interceptor method
      */
-    protected final StatelessState BUSINESS = new StatelessState() {
+    protected final static StatelessState BUSINESS = new StatelessState() {
+
         public MessageContext getMessageContext() throws IllegalStateException {
             throw new IllegalStateException();
         }
@@ -292,7 +294,8 @@
     /**
      * Timeout callback method
      */
-    protected final StatelessState TIMEOUT = new StatelessState() {
+    protected final static StatelessState TIMEOUT = new StatelessState() {
+
         public Class getInvokedBusinessInterface() {
             throw new IllegalStateException();
         }

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java?view=diff&rev=497662&r1=497661&r2=497662
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContext.java Thu Jan 18 16:41:27 2007
@@ -170,7 +170,7 @@
 
     public Object getPrimaryKey() {
         /*
-        * This method is only declared in the OldEntityContext interface and is therefor
+        * This method is only declared in the EntityContext interface and is therefor
         * unavailable in the SessionContext and doesn't not require a check for bean kind (Entity vs Session).
         */
         checkBeanState(EJBOBJECT_METHOD);

Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java?view=auto&rev=497662
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java Thu Jan 18 16:41:27 2007
@@ -0,0 +1,344 @@
+/**
+ * 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.core.entity;
+
+import java.security.Principal;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+import javax.ejb.TimerService;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.InterfaceType;
+import org.apache.openejb.InternalErrorException;
+import org.apache.openejb.RpcContainer;
+import org.apache.openejb.core.BaseContext;
+import org.apache.openejb.core.Operation;
+import org.apache.openejb.core.ThreadContext;
+import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
+import org.apache.openejb.core.ivm.IntraVmProxy;
+import org.apache.openejb.spi.SecurityService;
+import org.apache.openejb.util.proxy.ProxyManager;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EntityContext extends BaseContext implements javax.ejb.EntityContext {
+
+    public EntityContext(TransactionManager transactionManager, SecurityService securityService) {
+        super(transactionManager, securityService);
+    }
+
+    protected EntityContext(TransactionManager transactionManager, SecurityService securityService, UserTransaction userTransaction) {
+        super(transactionManager, securityService, userTransaction);
+    }
+
+    public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
+        return ((javax.ejb.EntityContext) getState()).getEJBLocalObject();
+    }
+
+    public EJBObject getEJBObject() throws IllegalStateException {
+        return ((javax.ejb.EntityContext) getState()).getEJBObject();
+    }
+
+    public Object getPrimaryKey() throws IllegalStateException {
+        return ((javax.ejb.EntityContext) getState()).getPrimaryKey();
+    }
+
+    private static class EntityState extends State {
+
+        public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
+            ThreadContext threadContext = ThreadContext.getThreadContext();
+            DeploymentInfo di = threadContext.getDeploymentInfo();
+
+            EjbObjectProxyHandler handler = new EntityEjbObjectHandler((RpcContainer) di.getContainer(), threadContext.getPrimaryKey(), di.getDeploymentID(), InterfaceType.EJB_LOCAL);
+            handler.setLocal(true);
+            try {
+                Class[] interfaces = new Class[]{di.getLocalInterface(), IntraVmProxy.class};
+                return (EJBLocalObject) ProxyManager.newProxyInstance(interfaces, handler);
+            } catch (IllegalAccessException iae) {
+                throw new InternalErrorException("Could not create IVM proxy for " + di.getLocalInterface() + " interface", iae);
+            }
+        }
+
+        public EJBObject getEJBObject() throws IllegalStateException {
+            ThreadContext threadContext = ThreadContext.getThreadContext();
+            DeploymentInfo di = threadContext.getDeploymentInfo();
+
+            EjbObjectProxyHandler handler = new EntityEjbObjectHandler((RpcContainer) di.getContainer(), threadContext.getPrimaryKey(), di.getDeploymentID(), InterfaceType.EJB_OBJECT);
+            try {
+                Class[] interfaces = new Class[]{di.getRemoteInterface(), IntraVmProxy.class};
+                return (EJBObject) ProxyManager.newProxyInstance(interfaces, handler);
+            } catch (IllegalAccessException iae) {
+                throw new InternalErrorException("Could not create IVM proxy for " + di.getLocalInterface() + " interface", iae);
+            }
+        }
+
+        public Object getPrimaryKey() throws IllegalStateException {
+            ThreadContext threadContext = ThreadContext.getThreadContext();
+            return threadContext.getPrimaryKey();
+        }
+    }
+
+    protected final static EntityState CONTEXT = new EntityState() {
+
+        public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public EJBObject getEJBObject() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public Object getPrimaryKey() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public Principal getCallerPrincipal(SecurityService securityService) {
+            throw new IllegalStateException();
+        }
+
+        public boolean isCallerInRole(SecurityService securityService, String roleName) {
+            throw new IllegalStateException();
+        }
+
+        public UserTransaction getUserTransaction(UserTransaction userTransaction) throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public void setRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public boolean getRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public TimerService getTimerService() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public boolean isUserTransactionAccessAllowed() {
+            return false;
+        }
+
+        public boolean isMessageContextAccessAllowed() {
+            return false;
+        }
+
+        public boolean isResourceManagerAccessAllowed() {
+            return false;
+        }
+
+        public boolean isEnterpriseBeanAccessAllowed() {
+            return false;
+        }
+
+        public boolean isEntityManagerFactoryAccessAllowed() {
+            return false;
+        }
+
+        public boolean isEntityManagerAccessAllowed() {
+            return false;
+        }
+
+        public boolean isTimerAccessAllowed() {
+            return false;
+        }
+    };
+
+    protected final static EntityState CREATE = new EntityState() {
+
+        public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public EJBObject getEJBObject() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public Object getPrimaryKey() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public UserTransaction getUserTransaction(UserTransaction userTransaction) throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public boolean isUserTransactionAccessAllowed() {
+            return false;
+        }
+
+        public boolean isMessageContextAccessAllowed() {
+            return false;
+        }
+
+        public boolean isTimerAccessAllowed() {
+            return false;
+        }
+    };
+
+    protected final static EntityState LIFECYCLE_BUSINESS_TIMEOUT = new EntityState() {
+
+        public UserTransaction getUserTransaction(UserTransaction userTransaction) throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public boolean isUserTransactionAccessAllowed() {
+            return false;
+        }
+
+        public boolean isMessageContextAccessAllowed() {
+            return false;
+        }
+    };
+
+    protected final static EntityState FIND = new EntityState() {
+
+        public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public EJBObject getEJBObject() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public Object getPrimaryKey() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public UserTransaction getUserTransaction(UserTransaction userTransaction) throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public TimerService getTimerService() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public boolean isUserTransactionAccessAllowed() {
+            return false;
+        }
+
+        public boolean isMessageContextAccessAllowed() {
+            return false;
+        }
+
+        public boolean isTimerAccessAllowed() {
+            return false;
+        }
+    };
+
+    protected final static EntityState HOME = new EntityState() {
+
+        public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public EJBObject getEJBObject() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public Object getPrimaryKey() throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public UserTransaction getUserTransaction(UserTransaction userTransaction) throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public boolean isUserTransactionAccessAllowed() {
+            return false;
+        }
+
+        public boolean isMessageContextAccessAllowed() {
+            return false;
+        }
+
+        public boolean isTimerAccessAllowed() {
+            return false;
+        }
+    };
+
+    protected final static EntityState ACTIVATE_PASSIVATE = new EntityState() {
+
+        public Principal getCallerPrincipal(SecurityService securityService) {
+            throw new IllegalStateException();
+        }
+
+        public boolean isCallerInRole(SecurityService securityService, String roleName) {
+            throw new IllegalStateException();
+        }
+
+        public UserTransaction getUserTransaction(UserTransaction userTransaction) throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public void setRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public boolean getRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+            throw new IllegalStateException();
+        }
+
+        public boolean isUserTransactionAccessAllowed() {
+            return false;
+        }
+
+        public boolean isMessageContextAccessAllowed() {
+            return false;
+        }
+
+        public boolean isResourceManagerAccessAllowed() {
+            return false;
+        }
+
+        public boolean isEnterpriseBeanAccessAllowed() {
+            return false;
+        }
+
+        public boolean isEntityManagerFactoryAccessAllowed() {
+            return false;
+        }
+
+        public boolean isEntityManagerAccessAllowed() {
+            return false;
+        }
+
+        public boolean isTimerAccessAllowed() {
+            return false;
+        }
+    };
+
+    static {
+        states[Operation.SET_CONTEXT.ordinal()] = CONTEXT;
+        states[Operation.UNSET_CONTEXT.ordinal()] = CONTEXT;
+        states[Operation.CREATE.ordinal()] = CREATE;
+        states[Operation.POST_CREATE.ordinal()] = LIFECYCLE_BUSINESS_TIMEOUT;
+        states[Operation.REMOVE.ordinal()] = LIFECYCLE_BUSINESS_TIMEOUT;
+        states[Operation.FIND.ordinal()] = FIND;
+        states[Operation.HOME.ordinal()] = HOME;
+        states[Operation.ACTIVATE.ordinal()] = ACTIVATE_PASSIVATE;
+        states[Operation.PASSIVATE.ordinal()] = ACTIVATE_PASSIVATE;
+        states[Operation.LOAD.ordinal()] = LIFECYCLE_BUSINESS_TIMEOUT;
+        states[Operation.STORE.ordinal()] = LIFECYCLE_BUSINESS_TIMEOUT;
+        states[Operation.BUSINESS.ordinal()] = LIFECYCLE_BUSINESS_TIMEOUT;
+        states[Operation.TIMEOUT.ordinal()] = LIFECYCLE_BUSINESS_TIMEOUT;
+    }
+}

Propchange: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Id Author

Propchange: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java?view=diff&rev=497662&r1=497661&r2=497662
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java Thu Jan 18 16:41:27 2007
@@ -42,17 +42,10 @@
         super(transactionManager, securityService, userTransaction);
     }
 
-    protected void init() {
-        states[Operation.INJECTION.ordinal()] = INJECTION;
-        states[Operation.LIFECYCLE.ordinal()] = LIFECYCLE;
-        states[Operation.BUSINESS.ordinal()] = BUSINESS_TIMEOUT;
-        states[Operation.TIMEOUT.ordinal()] = BUSINESS_TIMEOUT;
-    }
-
     /**
      * Dependency injection methods (e.g., setMessageDrivenContext)
      */
-    protected final State INJECTION = new State() {
+    protected final static State INJECTION = new State() {
         public EJBHome getEJBHome() {
             throw new IllegalStateException();
         }
@@ -117,7 +110,7 @@
     /**
      * PostConstruct, Pre-Destroy lifecycle callback interceptor methods
      */
-    protected final State LIFECYCLE = new State() {
+    protected final static State LIFECYCLE = new State() {
         public EJBHome getEJBHome() {
             throw new IllegalStateException();
         }
@@ -175,7 +168,7 @@
      * Message listener method, business method interceptor method
      * and imeout callback method
      */
-    protected final State BUSINESS_TIMEOUT = new State() {
+    protected final static State BUSINESS_TIMEOUT = new State() {
         public EJBHome getEJBHome() {
             throw new IllegalStateException();
         }
@@ -196,4 +189,12 @@
             return false;
         }
     };
+
+    static {
+        states[Operation.INJECTION.ordinal()] = INJECTION;
+        states[Operation.LIFECYCLE.ordinal()] = LIFECYCLE;
+        states[Operation.BUSINESS.ordinal()] = BUSINESS_TIMEOUT;
+        states[Operation.TIMEOUT.ordinal()] = BUSINESS_TIMEOUT;
+    }
+
 }

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContext.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContext.java?view=diff&rev=497662&r1=497661&r2=497662
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContext.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContext.java Thu Jan 18 16:41:27 2007
@@ -37,7 +37,7 @@
         super(transactionManager, securityService, userTransaction);
     }
 
-    protected void init() {
+    static {
         states[Operation.INJECTION.ordinal()] = INJECTION;
         states[Operation.LIFECYCLE.ordinal()] = LIFECYCLE;
         states[Operation.BUSINESS.ordinal()] = BUSINESS;

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContext.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContext.java?view=diff&rev=497662&r1=497661&r2=497662
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContext.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContext.java Thu Jan 18 16:41:27 2007
@@ -37,21 +37,21 @@
         super(transactionManager, securityService, userTransaction);
     }
 
-    protected void init() {
-        states[Operation.INJECTION.ordinal()] = INJECTION;
-        states[Operation.LIFECYCLE.ordinal()] = LIFECYCLE;
-        states[Operation.BUSINESS.ordinal()] = BUSINESS;
-        states[Operation.BUSINESS_WS.ordinal()] = BUSINESS_WS;
-        states[Operation.TIMEOUT.ordinal()] = TIMEOUT;
-    }
-
     /**
      * Business method from web service endpoint
      */
-    private final StatelessState BUSINESS_WS = new StatelessState() {
+    private final static StatelessState BUSINESS_WS = new StatelessState() {
         public Class getInvokedBusinessInterface() {
             throw new IllegalStateException();
         }
     };
+
+    static {
+        states[Operation.INJECTION.ordinal()] = INJECTION;
+        states[Operation.LIFECYCLE.ordinal()] = LIFECYCLE;
+        states[Operation.BUSINESS.ordinal()] = BUSINESS;
+        states[Operation.BUSINESS_WS.ordinal()] = BUSINESS_WS;
+        states[Operation.TIMEOUT.ordinal()] = TIMEOUT;
+    }
 
 }



Re: svn commit: r497662 - in /incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core: ./ entity/ mdb/ stateful/ stateless/

Posted by Dain Sundstrom <da...@iq80.com>.
On Jan 18, 2007, at 4:41 PM, adc@apache.org wrote:

> Author: adc
> Date: Thu Jan 18 16:41:27 2007
> New Revision: 497662
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=497662
> Log:
> Another context and states are final statics
>
> --- incubator/openejb/trunk/openejb3/container/openejb-core/src/ 
> main/java/org/apache/openejb/core/BaseContext.java (original)
> +++ incubator/openejb/trunk/openejb3/container/openejb-core/src/ 
> main/java/org/apache/openejb/core/BaseContext.java Thu Jan 18  
> 16:41:27 2007
> @@ -45,26 +45,20 @@
>      private final SecurityService securityService;
>      private final TransactionManager transactionManager;
>      private State state;
> -    protected final State[] states = new State[Operation.values 
> ().length];
> +    protected static State[] states = new State[Operation.values 
> ().length];

I think you missed the final modifier.

-dain