Title: [2453] trunk/openejb2/modules/core/src/java/org/openejb/mdb: Former dispatch callbacks are now private static final inner-classes
Revision
2453
Author
dblevins
Date
2006-02-16 07:06:20 -0500 (Thu, 16 Feb 2006)

Log Message

Former dispatch callbacks are now private static final inner-classes
Will likely help inlining by the vm

Modified Paths

Removed Paths

  • trunk/openejb2/modules/core/src/java/org/openejb/entity/dispatch/
  • trunk/openejb2/modules/core/src/java/org/openejb/mdb/dispatch/
  • trunk/openejb2/modules/core/src/java/org/openejb/slsb/dispatch/

Diff

Modified: trunk/openejb2/modules/core/src/java/org/openejb/entity/EntityCallbackInterceptor.java (2452 => 2453)

--- trunk/openejb2/modules/core/src/java/org/openejb/entity/EntityCallbackInterceptor.java	2006-02-16 11:29:57 UTC (rev 2452)
+++ trunk/openejb2/modules/core/src/java/org/openejb/entity/EntityCallbackInterceptor.java	2006-02-16 12:06:20 UTC (rev 2453)
@@ -46,44 +46,131 @@
 
 import org.openejb.CallbackMethod;
 import org.openejb.EjbCallbackInvocation;
-import org.openejb.entity.dispatch.EJBPassivateOperation;
-import org.openejb.entity.dispatch.EJBActivateOperation;
-import org.openejb.entity.dispatch.SetEntityContextOperation;
-import org.openejb.entity.dispatch.EJBLoadOperation;
-import org.openejb.entity.dispatch.EJBStoreOperation;
-import org.openejb.entity.dispatch.UnsetEntityContextOperation;
+import org.openejb.EjbInvocation;
+import org.openejb.EJBOperation;
+import org.openejb.dispatch.AbstractCallbackOperation;
 import org.apache.geronimo.interceptor.InvocationResult;
 import org.apache.geronimo.interceptor.Invocation;
 import org.apache.geronimo.interceptor.Interceptor;
 
+import javax.ejb.EnterpriseBean;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+
 /**
  * @version $Revision$ $Date$
  */
 public class EntityCallbackInterceptor implements Interceptor {
+
+    private static final SetEntityContextOperation SET_ENTITY_CONTEXT = new SetEntityContextOperation();
+    private static final UnsetEntityContextOperation UNSET_ENTITY_CONTEXT = new UnsetEntityContextOperation();
+    private static final EJBActivateOperation EJB_ACTIVATE = new EJBActivateOperation();
+    private static final EJBPassivateOperation EJB_PASSIVATE = new EJBPassivateOperation();
+    private static final EJBLoadOperation EJB_LOAD = new EJBLoadOperation();
+    private static final EJBStoreOperation EJB_STORE = new EJBStoreOperation();
+
     public InvocationResult invoke(Invocation invocation) throws Throwable {
         EjbCallbackInvocation ejbCallbackInvocation = (EjbCallbackInvocation) invocation;
 
         CallbackMethod callbackMethod = ejbCallbackInvocation.getCallbackMethod();
         if (callbackMethod == CallbackMethod.SET_CONTEXT) {
-            InvocationResult result = SetEntityContextOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = SET_ENTITY_CONTEXT.execute(ejbCallbackInvocation);
             return result;
         } else if (callbackMethod == CallbackMethod.UNSET_CONTEXT) {
-            InvocationResult result = UnsetEntityContextOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = UNSET_ENTITY_CONTEXT.execute(ejbCallbackInvocation);
             return result;
         } else if (callbackMethod == CallbackMethod.ACTIVATE) {
-            InvocationResult result = EJBActivateOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = EJB_ACTIVATE.execute(ejbCallbackInvocation);
             return result;
         } else if (callbackMethod == CallbackMethod.PASSIVATE) {
-            InvocationResult result = EJBPassivateOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = EJB_PASSIVATE.execute(ejbCallbackInvocation);
             return result;
         } else if (callbackMethod == CallbackMethod.LOAD) {
-            InvocationResult result = EJBLoadOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = EJB_LOAD.execute(ejbCallbackInvocation);
             return result;
         } else if (callbackMethod == CallbackMethod.STORE) {
-            InvocationResult result = EJBStoreOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = EJB_STORE.execute(ejbCallbackInvocation);
             return result;
         } else {
             throw new AssertionError("Unknown callback method " + callbackMethod);
         }
     }
+
+    private static final class EJBActivateOperation extends AbstractCallbackOperation {
+
+        private EJBActivateOperation() {}
+
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.EJBACTIVATE);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((EntityBean)instance).ejbActivate();
+            return null;
+        }
+    }
+
+    private static final class EJBLoadOperation extends AbstractCallbackOperation {
+
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.EJBLOAD);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((EntityBean)instance).ejbLoad();
+            return null;
+        }
+
+    }
+
+    private static final class EJBPassivateOperation extends AbstractCallbackOperation {
+
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.EJBACTIVATE);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((EntityBean)instance).ejbPassivate();
+            return null;
+        }
+
+    }
+
+    private static final class EJBStoreOperation extends AbstractCallbackOperation {
+
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.EJBLOAD);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((EntityBean)instance).ejbStore();
+            return null;
+        }
+
+    }
+
+    private static final class SetEntityContextOperation extends AbstractCallbackOperation {
+
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.SETCONTEXT);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((EntityBean)instance).setEntityContext((EntityContext)arguments[0]);
+            return null;
+        }
+
+    }
+
+    private static final class UnsetEntityContextOperation extends AbstractCallbackOperation {
+
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.SETCONTEXT);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((EntityBean)instance).unsetEntityContext();
+            return null;
+        }
+    }
 }

Modified: trunk/openejb2/modules/core/src/java/org/openejb/mdb/MdbCallbackInterceptor.java (2452 => 2453)

--- trunk/openejb2/modules/core/src/java/org/openejb/mdb/MdbCallbackInterceptor.java	2006-02-16 11:29:57 UTC (rev 2452)
+++ trunk/openejb2/modules/core/src/java/org/openejb/mdb/MdbCallbackInterceptor.java	2006-02-16 12:06:20 UTC (rev 2453)
@@ -49,20 +49,28 @@
 import org.apache.geronimo.interceptor.InvocationResult;
 import org.openejb.CallbackMethod;
 import org.openejb.EjbCallbackInvocation;
-import org.openejb.mdb.dispatch.SetMessageDrivenContextOperation;
+import org.openejb.EjbInvocation;
+import org.openejb.EJBOperation;
+import org.openejb.dispatch.AbstractCallbackOperation;
 import org.openejb.slsb.EjbCreateMethod;
 import org.openejb.slsb.RemoveMethod;
 
+import javax.ejb.EnterpriseBean;
+import javax.ejb.MessageDrivenBean;
+import javax.ejb.MessageDrivenContext;
+
 /**
  * @version $Revision$ $Date$
  */
 public class MdbCallbackInterceptor implements Interceptor {
+    private static final SetMessageDrivenContextOperation SET_MESSAGE_DRIVEN_CONTEXT = new SetMessageDrivenContextOperation();
+
     public InvocationResult invoke(Invocation invocation) throws Throwable {
         EjbCallbackInvocation ejbCallbackInvocation = (EjbCallbackInvocation) invocation;
 
         CallbackMethod callbackMethod = ejbCallbackInvocation.getCallbackMethod();
         if (callbackMethod == CallbackMethod.SET_CONTEXT) {
-            InvocationResult result = SetMessageDrivenContextOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = SET_MESSAGE_DRIVEN_CONTEXT.execute(ejbCallbackInvocation);
             return result;
         } else if (callbackMethod == CallbackMethod.CREATE) {
             InvocationResult result = EjbCreateMethod.INSTANCE.execute(ejbCallbackInvocation);
@@ -74,4 +82,17 @@
             throw new AssertionError("Unknown callback method " + callbackMethod);
         }
     }
+
+    private static final class SetMessageDrivenContextOperation extends AbstractCallbackOperation {
+
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.SETCONTEXT);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((MessageDrivenBean)instance).setMessageDrivenContext((MessageDrivenContext)arguments[0]);
+            return null;
+        }
+    }
+
 }

Modified: trunk/openejb2/modules/core/src/java/org/openejb/sfsb/StatefulCallbackInterceptor.java (2452 => 2453)

--- trunk/openejb2/modules/core/src/java/org/openejb/sfsb/StatefulCallbackInterceptor.java	2006-02-16 11:29:57 UTC (rev 2452)
+++ trunk/openejb2/modules/core/src/java/org/openejb/sfsb/StatefulCallbackInterceptor.java	2006-02-16 12:06:20 UTC (rev 2453)
@@ -49,26 +49,34 @@
 import org.apache.geronimo.interceptor.InvocationResult;
 import org.openejb.CallbackMethod;
 import org.openejb.EjbCallbackInvocation;
-import org.openejb.slsb.dispatch.EJBActivateOperation;
-import org.openejb.slsb.dispatch.EJBPassivateOperation;
-import org.openejb.slsb.dispatch.SetSessionContextOperation;
+import org.openejb.EjbInvocation;
+import org.openejb.EJBOperation;
+import org.openejb.dispatch.AbstractCallbackOperation;
 
+import javax.ejb.EnterpriseBean;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
 /**
  * @version $Revision$ $Date$
  */
 public class StatefulCallbackInterceptor implements Interceptor {
+    private static final SetSessionContextOperation SET_SESSION_CONTEXT = new SetSessionContextOperation();
+    private static final EJBActivateOperation EJB_ACTIVATE = new EJBActivateOperation();
+    private static final EJBPassivateOperation EJB_PASSIVATE = new EJBPassivateOperation();
+
     public InvocationResult invoke(Invocation invocation) throws Throwable {
         EjbCallbackInvocation ejbCallbackInvocation = (EjbCallbackInvocation) invocation;
 
         CallbackMethod callbackMethod = ejbCallbackInvocation.getCallbackMethod();
         if (callbackMethod == CallbackMethod.SET_CONTEXT) {
-            InvocationResult result = SetSessionContextOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = SET_SESSION_CONTEXT.execute(ejbCallbackInvocation);
             return result;
         } else if (callbackMethod == CallbackMethod.ACTIVATE) {
-            InvocationResult result = EJBActivateOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = EJB_ACTIVATE.execute(ejbCallbackInvocation);
             return result;
         } else if (callbackMethod == CallbackMethod.PASSIVATE) {
-            InvocationResult result = EJBPassivateOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = EJB_PASSIVATE.execute(ejbCallbackInvocation);
             return result;
         } else if (callbackMethod == CallbackMethod.AFTER_BEGIN) {
             InvocationResult result = AfterBegin.INSTANCE.execute(ejbCallbackInvocation);
@@ -83,4 +91,38 @@
             throw new AssertionError("Unknown callback method " + callbackMethod);
         }
     }
+
+    private static final class SetSessionContextOperation extends AbstractCallbackOperation {
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.SETCONTEXT);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((SessionBean)instance).setSessionContext((SessionContext)arguments[0]);
+            return null;
+        }
+    }
+
+    private static final class EJBActivateOperation extends AbstractCallbackOperation {
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.EJBACTIVATE);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((SessionBean)instance).ejbActivate();
+            return null;
+        }
+    }
+
+    private static final class EJBPassivateOperation extends AbstractCallbackOperation {
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.EJBACTIVATE);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((SessionBean)instance).ejbPassivate();
+            return null;
+        }
+    }
+
 }

Modified: trunk/openejb2/modules/core/src/java/org/openejb/slsb/StatelessCallbackInterceptor.java (2452 => 2453)

--- trunk/openejb2/modules/core/src/java/org/openejb/slsb/StatelessCallbackInterceptor.java	2006-02-16 11:29:57 UTC (rev 2452)
+++ trunk/openejb2/modules/core/src/java/org/openejb/slsb/StatelessCallbackInterceptor.java	2006-02-16 12:06:20 UTC (rev 2453)
@@ -49,18 +49,26 @@
 import org.apache.geronimo.interceptor.Interceptor;
 import org.openejb.CallbackMethod;
 import org.openejb.EjbCallbackInvocation;
-import org.openejb.slsb.dispatch.SetSessionContextOperation;
+import org.openejb.EjbInvocation;
+import org.openejb.EJBOperation;
+import org.openejb.dispatch.AbstractCallbackOperation;
 
+import javax.ejb.EnterpriseBean;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
 /**
  * @version $Revision$ $Date$
  */
 public class StatelessCallbackInterceptor implements Interceptor {
+    private static final SetSessionContextOperation SET_SESSION_CONTEXT = new SetSessionContextOperation();
+
     public InvocationResult invoke(Invocation invocation) throws Throwable {
         EjbCallbackInvocation ejbCallbackInvocation = (EjbCallbackInvocation) invocation;
 
         CallbackMethod callbackMethod = ejbCallbackInvocation.getCallbackMethod();
         if (callbackMethod == CallbackMethod.SET_CONTEXT) {
-            InvocationResult result = SetSessionContextOperation.INSTANCE.execute(ejbCallbackInvocation);
+            InvocationResult result = SET_SESSION_CONTEXT.execute(ejbCallbackInvocation);
             return result;
         } else if (callbackMethod == CallbackMethod.CREATE) {
             InvocationResult result = EjbCreateMethod.INSTANCE.execute(ejbCallbackInvocation);
@@ -72,4 +80,16 @@
             throw new AssertionError("Unknown callback method " + callbackMethod);
         }
     }
+
+    private static final class SetSessionContextOperation extends AbstractCallbackOperation {
+        public InvocationResult execute(EjbInvocation invocation) throws Throwable {
+            return invoke(invocation, EJBOperation.SETCONTEXT);
+        }
+
+        protected Object doOperation(EnterpriseBean instance, Object[] arguments) throws Throwable {
+            ((SessionBean)instance).setSessionContext((SessionContext)arguments[0]);
+            return null;
+        }
+    }
+
 }

Reply via email to