tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1291415 - in /openejb/trunk/openejb/server: openejb-client/src/main/java/org/apache/openejb/client/ openejb-client/src/test/java/org/apache/openejb/client/ openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/ openejb-ejbd/src/test/ja...
Date Mon, 20 Feb 2012 19:16:48 GMT
Author: adc
Date: Mon Feb 20 19:16:48 2012
New Revision: 1291415

URL: http://svn.apache.org/viewvc?rev=1291415&view=rev
Log:
OPENEJB-82 Added RequestMethodCode

Added:
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodCode.java
Modified:
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBHomeHandler.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBObjectHandler.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EntityEJBHomeHandler.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EntityEJBObjectHandler.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIRequest.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodConstants.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBHomeHandler.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBObjectHandler.java
    openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/EJBRequestTest.java
    openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/JndiRequestTest.java
    openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
    openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
    openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBHomeHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBHomeHandler.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBHomeHandler.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBHomeHandler.java
Mon Feb 20 19:16:48 2012
@@ -178,7 +178,7 @@ public abstract class EJBHomeHandler ext
     }
 
     public Object homeMethod(Method method, Object[] args, Object proxy) throws Throwable
{
-        EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_HOME_METHOD, ejb, method,
args, null);
+        EJBRequest req = new EJBRequest(RequestMethodCode.EJB_HOME_METHOD, ejb, method, args,
null);
 
         EJBResponse res = request(req);
 
@@ -202,7 +202,7 @@ public abstract class EJBHomeHandler ext
     /*-------------------------------------------------*/
 
     protected Object create(Method method, Object[] args, Object proxy) throws Throwable
{
-        EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_HOME_CREATE, ejb, method,
args, null);
+        EJBRequest req = new EJBRequest(RequestMethodCode.EJB_HOME_CREATE, ejb, method, args,
null);
 
         EJBResponse res = request(req);
 

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBObjectHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBObjectHandler.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBObjectHandler.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBObjectHandler.java
Mon Feb 20 19:16:48 2012
@@ -258,7 +258,7 @@ public abstract class EJBObjectHandler e
     }
 
     private Object _businessMethod(Method method, Object[] args, Object proxy, String requestId)
throws Throwable {
-        EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_OBJECT_BUSINESS_METHOD,
ejb, method, args, primaryKey);
+        EJBRequest req = new EJBRequest(RequestMethodCode.EJB_OBJECT_BUSINESS_METHOD, ejb,
method, args, primaryKey);
 
         //Currently, we only set the requestId while the asynchronous invocation is called
         req.getBody().setRequestId(requestId);
@@ -267,7 +267,7 @@ public abstract class EJBObjectHandler e
     }
 
     private Object _businessMethod(Method method, Object[] args, Object proxy, String requestId,
EJBResponse response) throws Throwable {
-        EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_OBJECT_BUSINESS_METHOD,
ejb, method, args, primaryKey);
+        EJBRequest req = new EJBRequest(RequestMethodCode.EJB_OBJECT_BUSINESS_METHOD, ejb,
method, args, primaryKey);
 
         //Currently, we only set the request while the asynchronous invocation is called
         req.getBody().setRequestId(requestId);
@@ -374,7 +374,7 @@ public abstract class EJBObjectHandler e
                     if (lastMayInterruptIfRunningValue.getAndSet(mayInterruptIfRunning) ==
mayInterruptIfRunning) {
                         return false;
                     }
-                    EJBRequest req = new EJBRequest(RequestMethodConstants.FUTURE_CANCEL,
ejb, CANCEL, new Object[] { Boolean.valueOf(mayInterruptIfRunning) }, primaryKey);
+                    EJBRequest req = new EJBRequest(RequestMethodCode.FUTURE_CANCEL, ejb,
CANCEL, new Object[] { Boolean.valueOf(mayInterruptIfRunning) }, primaryKey);
                     req.getBody().setRequestId(requestId);
                     try {
                         EJBResponse res = request(req);

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
Mon Feb 20 19:16:48 2012
@@ -21,19 +21,18 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.lang.reflect.Method;
 import java.rmi.Remote;
-import java.util.UUID;
-
 import javax.naming.Context;
 import javax.naming.InitialContext;
-import javax.rmi.PortableRemoteObject;
 import javax.rmi.CORBA.Stub;
 import javax.rmi.CORBA.Tie;
+import javax.rmi.PortableRemoteObject;
 
 import org.omg.CORBA.ORB;
 
+
 public class EJBRequest implements ClusterableRequest {
 
-    private transient int requestMethod;
+    private transient RequestMethodCode requestMethod;
     private transient int deploymentCode = 0;
     private transient Object clientIdentity;
     private transient String deploymentId;
@@ -53,7 +52,7 @@ public class EJBRequest implements Clust
         ejbMetaData = null;
     }
 
-    public EJBRequest(int requestMethod, EJBMetaDataImpl ejb, Method method, Object[] args,
Object primaryKey) {
+    public EJBRequest(RequestMethodCode requestMethod, EJBMetaDataImpl ejb, Method method,
Object[] args, Object primaryKey) {
         body = new Body(ejb);
 
         this.ejbMetaData = ejb;
@@ -114,8 +113,9 @@ public class EJBRequest implements Clust
     }
 
     public static class Body implements java.io.Externalizable {
+
         private transient EJBMetaDataImpl ejb;
-        private transient ORB orb; 
+        private transient ORB orb;
         private transient Method methodInstance;
         private transient Class interfaceClass;
         private transient String methodName;
@@ -163,21 +163,21 @@ public class EJBRequest implements Clust
             Class methodClass = methodInstance.getDeclaringClass();
 
             if (ejb.homeClass != null) {
-                if (methodClass.isAssignableFrom(ejb.homeClass)){
+                if (methodClass.isAssignableFrom(ejb.homeClass)) {
                     this.interfaceClass = ejb.homeClass;
                     return;
                 }
             }
 
             if (ejb.remoteClass != null) {
-                if (methodClass.isAssignableFrom(ejb.remoteClass)){
+                if (methodClass.isAssignableFrom(ejb.remoteClass)) {
                     this.interfaceClass = ejb.remoteClass;
                     return;
                 }
             }
 
             for (Class businessClass : ejb.businessClasses) {
-                if (methodClass.isAssignableFrom(businessClass)){
+                if (methodClass.isAssignableFrom(businessClass)) {
                     this.interfaceClass = businessClass;
                     return;
                 }
@@ -210,7 +210,7 @@ public class EJBRequest implements Clust
             methodName = null;
             methodInstance = null;
             try {
-                requestId = (String)in.readObject();
+                requestId = (String) in.readObject();
                 primaryKey = in.readObject();
                 interfaceClass = (Class) in.readObject();
 //                methodClass = (Class) in.readObject();
@@ -324,9 +324,9 @@ public class EJBRequest implements Clust
         static final Object[] noArgsO = new Object[0];
 
         /**
-         * Obtain an ORB instance for this request to activate remote 
+         * Obtain an ORB instance for this request to activate remote
          * arguments and return results.
-         * 
+         *
          * @return An ORB instance.
          */
         protected ORB getORB() throws IOException {
@@ -338,13 +338,13 @@ public class EJBRequest implements Clust
                 } catch (Throwable e) {
                     try {
                         // any orb will do if we can't get a context one. 
-                        orb = ORB.init(); 
+                        orb = ORB.init();
                     } catch (Throwable ex) {
                         throw new IOException("Unable to connect PortableRemoteObject stub
to an ORB, no ORB bound to java:comp/ORB");
                     }
                 }
             }
-            return orb; 
+            return orb;
         }
 
         protected void readMethodParameters(ObjectInput in) throws IOException, ClassNotFoundException
{
@@ -410,7 +410,7 @@ public class EJBRequest implements Clust
                         clazz = (Class) in.readObject();
                         obj = in.readObject();
                         if (obj instanceof Stub) {
-                            Stub stub = (Stub)obj;
+                            Stub stub = (Stub) obj;
                             ORB orb = getORB();
                             stub.connect(orb);
                         }
@@ -443,7 +443,7 @@ public class EJBRequest implements Clust
         return RequestMethodConstants.EJB_REQUEST;
     }
 
-    public int getRequestMethod() {
+    public RequestMethodCode getRequestMethod() {
         return requestMethod;
     }
 
@@ -459,7 +459,7 @@ public class EJBRequest implements Clust
         return deploymentCode;
     }
 
-    public void setRequestMethod(int requestMethod) {
+    public void setRequestMethod(RequestMethodCode requestMethod) {
         this.requestMethod = requestMethod;
     }
 
@@ -484,52 +484,7 @@ public class EJBRequest implements Clust
     }
 
     public String toString() {
-        StringBuilder s = null; 
-        switch (requestMethod) {
-            case RequestMethodConstants.EJB_HOME_GET_EJB_META_DATA:
-                s = new StringBuilder("EJB_HOME.GET_EJB_META_DATA");
-                break;
-            case RequestMethodConstants.EJB_HOME_GET_HOME_HANDLE:
-                s = new StringBuilder("EJB_HOME.GET_HOME_HANDLE");
-                break;
-            case RequestMethodConstants.EJB_HOME_REMOVE_BY_HANDLE:
-                s = new StringBuilder("EJB_HOME.REMOVE_BY_HANDLE");
-                break;
-            case RequestMethodConstants.EJB_HOME_REMOVE_BY_PKEY:
-                s = new StringBuilder("EJB_HOME.REMOVE_BY_PKEY");
-                break;
-            case RequestMethodConstants.EJB_HOME_FIND:
-                s = new StringBuilder("EJB_HOME.FIND");
-                break;
-            case RequestMethodConstants.EJB_HOME_CREATE:
-                s = new StringBuilder("EJB_HOME.CREATE");
-                break;
-            case RequestMethodConstants.EJB_HOME_METHOD:
-                s = new StringBuilder("EJB_HOME.HOME_METHOD");
-                break;
-            case RequestMethodConstants.EJB_OBJECT_GET_EJB_HOME:
-                s = new StringBuilder("EJB_OBJECT.GET_EJB_HOME");
-                break;
-            case RequestMethodConstants.EJB_OBJECT_GET_HANDLE:
-                s = new StringBuilder("EJB_OBJECT.GET_HANDLE");
-                break;
-            case RequestMethodConstants.EJB_OBJECT_GET_PRIMARY_KEY:
-                s = new StringBuilder("EJB_OBJECT.GET_PRIMARY_KEY");
-                break;
-            case RequestMethodConstants.EJB_OBJECT_IS_IDENTICAL:
-                s = new StringBuilder("EJB_OBJECT.IS_IDENTICAL");
-                break;
-            case RequestMethodConstants.EJB_OBJECT_REMOVE:
-                s = new StringBuilder("EJB_OBJECT.REMOVE");
-                break;
-            case RequestMethodConstants.EJB_OBJECT_BUSINESS_METHOD:
-                s = new StringBuilder("EJB_OBJECT.BUSINESS_METHOD");
-                break;
-            case RequestMethodConstants.FUTURE_CANCEL:
-                s = new StringBuilder("FUTURE.CANCEL");
-            default:
-                s = new StringBuilder("EJB_UKNOWN."+requestMethod);
-        }
+        StringBuilder s = new StringBuilder((requestMethod == null ? "null" : requestMethod.toString()));
         s.append(':').append(deploymentId);
         if (body != null) {
             s.append(':').append(body.getMethodName());
@@ -549,12 +504,16 @@ public class EJBRequest implements Clust
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         ClassNotFoundException result = null;
 
-        requestMethod = -1;
         deploymentId = null;
         deploymentCode = -1;
         clientIdentity = null;
 
-        requestMethod = in.readByte();
+        int code = in.readByte();
+        try {
+            requestMethod = RequestMethodCode.valueOf(code);
+        } catch (IllegalArgumentException iae) {
+            throw new IOException("Invalid request code " + code);
+        }
         try {
             deploymentId = (String) in.readObject();
         } catch (ClassNotFoundException cnfe) {
@@ -572,7 +531,7 @@ public class EJBRequest implements Clust
     }
 
     public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeByte(requestMethod);
+        out.writeByte(requestMethod.getCode());
 
         if (deploymentCode > 0) {
             out.writeObject(null);

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EntityEJBHomeHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EntityEJBHomeHandler.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EntityEJBHomeHandler.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EntityEJBHomeHandler.java
Mon Feb 20 19:16:48 2012
@@ -32,7 +32,7 @@ public class EntityEJBHomeHandler extend
     }
 
     protected Object findX(Method method, Object[] args, Object proxy) throws Throwable {
-        EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_HOME_FIND, ejb, method,
args, null);
+        EJBRequest req = new EJBRequest(RequestMethodCode.EJB_HOME_FIND, ejb, method, args,
null);
 
         EJBResponse res = request(req);
 
@@ -98,7 +98,7 @@ public class EntityEJBHomeHandler extend
 
         if (primKey == null) throw new NullPointerException("The primary key is null.");
 
-        EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_HOME_REMOVE_BY_PKEY, ejb,
method, args, primKey);
+        EJBRequest req = new EJBRequest(RequestMethodCode.EJB_HOME_REMOVE_BY_PKEY, ejb, method,
args, primKey);
 
         EJBResponse res = request(req);
 
@@ -128,7 +128,7 @@ public class EntityEJBHomeHandler extend
         Object primKey = ejbObject.getPrimaryKey();
         if (primKey == null) throw new NullPointerException("The handle.getEJBObject().getPrimaryKey()
is null.");
 
-        EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_HOME_REMOVE_BY_HANDLE,
ejb, method, args, primKey);
+        EJBRequest req = new EJBRequest(RequestMethodCode.EJB_HOME_REMOVE_BY_HANDLE, ejb,
method, args, primKey);
 
         EJBResponse res = request(req);
 

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EntityEJBObjectHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EntityEJBObjectHandler.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EntityEJBObjectHandler.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EntityEJBObjectHandler.java
Mon Feb 20 19:16:48 2012
@@ -58,7 +58,7 @@ public class EntityEJBObjectHandler exte
 
     protected Object remove(Method method, Object[] args, Object proxy) throws Throwable
{
 
-        EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_OBJECT_REMOVE, ejb, method,
args, primaryKey);
+        EJBRequest req = new EJBRequest(RequestMethodCode.EJB_OBJECT_REMOVE, ejb, method,
args, primaryKey);
 
         EJBResponse res = request(req);
 

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
Mon Feb 20 19:16:48 2012
@@ -211,7 +211,7 @@ public class JNDIContext implements Init
         }
 
         JNDIRequest req = new JNDIRequest();
-        req.setRequestMethod(RequestMethodConstants.JNDI_LOOKUP);
+        req.setRequestMethod(RequestMethodCode.JNDI_LOOKUP);
         req.setRequestString(name);
         req.setModuleId(moduleId);
 
@@ -355,7 +355,7 @@ public class JNDIContext implements Init
         else if (name.startsWith("java:")) name = name.replaceFirst("^java:", "");
         else if (!name.startsWith("/")) name = tail + name;
 
-        JNDIRequest req = new JNDIRequest(RequestMethodConstants.JNDI_LIST, name);
+        JNDIRequest req = new JNDIRequest(RequestMethodCode.JNDI_LIST, name);
         req.setModuleId(moduleId);
 
         JNDIResponse res = null;

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIRequest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIRequest.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIRequest.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIRequest.java
Mon Feb 20 19:16:48 2012
@@ -22,7 +22,7 @@ import java.io.ObjectOutput;
 
 public class JNDIRequest implements ClusterableRequest {
 
-    private transient int requestMethod = -1;
+    private transient RequestMethodCode requestMethod;
     private transient String requestString;
     private transient String moduleId;
     private transient int serverHash;
@@ -30,7 +30,7 @@ public class JNDIRequest implements Clus
     public JNDIRequest() {
     }
 
-    public JNDIRequest(int requestMethod, String requestString) {
+    public JNDIRequest(RequestMethodCode requestMethod, String requestString) {
         this.requestMethod = requestMethod;
         this.requestString = requestString;
     }
@@ -39,7 +39,7 @@ public class JNDIRequest implements Clus
         return RequestMethodConstants.JNDI_REQUEST;
     }
 
-    public int getRequestMethod() {
+    public RequestMethodCode getRequestMethod() {
         return requestMethod;
     }
 
@@ -55,7 +55,7 @@ public class JNDIRequest implements Clus
         this.moduleId = moduleId;
     }
 
-    public void setRequestMethod(int requestMethod) {
+    public void setRequestMethod(RequestMethodCode requestMethod) {
         this.requestMethod = requestMethod;
     }
 
@@ -74,7 +74,12 @@ public class JNDIRequest implements Clus
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         byte version = in.readByte(); // future use
 
-        requestMethod = in.readByte();
+        int code = in.readByte();
+        try {
+            requestMethod = RequestMethodCode.valueOf(code);
+        } catch (IllegalArgumentException iae) {
+            throw new IOException("Invalid request code " + code);
+        }
         requestString = in.readUTF();
         moduleId = (String) in.readObject();
         serverHash = in.readInt();
@@ -84,7 +89,7 @@ public class JNDIRequest implements Clus
         // write out the version of the serialized data for future use
         out.writeByte(1);
 
-        out.writeByte((byte) requestMethod);
+        out.writeByte((byte) requestMethod.getCode());
         out.writeUTF(requestString);
         out.writeObject(moduleId);
         out.writeInt(serverHash);
@@ -93,11 +98,7 @@ public class JNDIRequest implements Clus
     public String toString() {
         StringBuilder sb = new StringBuilder(100);
 
-        switch(requestMethod){
-            case RequestMethodConstants.JNDI_LOOKUP: sb.append("JNDI_LOOKUP:"); break;
-            case RequestMethodConstants.JNDI_LIST: sb.append("JNDI_LIST:"); break;
-            case RequestMethodConstants.JNDI_LIST_BINDINGS: sb.append("JNDI_LIST_BINDINGS:");
break;
-        }
+        sb.append(requestMethod);
         sb.append(this.moduleId).append(":");
         sb.append(this.requestString);
         return sb.toString();

Added: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodCode.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodCode.java?rev=1291415&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodCode.java
(added)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodCode.java
Mon Feb 20 19:16:48 2012
@@ -0,0 +1,70 @@
+/**
+ * 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.client;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ *
+ */
+public enum RequestMethodCode {
+    EJB_HOME_GET_EJB_META_DATA(1),
+    EJB_HOME_GET_HOME_HANDLE(2),
+    EJB_HOME_REMOVE_BY_HANDLE(3),
+    EJB_HOME_REMOVE_BY_PKEY(4),
+
+    EJB_HOME_FIND(9),
+    EJB_HOME_CREATE(10),
+
+    EJB_OBJECT_GET_EJB_HOME(14),
+    EJB_OBJECT_GET_HANDLE(15),
+    EJB_OBJECT_GET_PRIMARY_KEY(16),
+    EJB_OBJECT_IS_IDENTICAL(17),
+    EJB_OBJECT_REMOVE(18),
+
+    EJB_OBJECT_BUSINESS_METHOD(23),
+    EJB_HOME_METHOD(24),
+
+    JNDI_LOOKUP(27),
+    JNDI_LIST(28),
+    JNDI_LIST_BINDINGS(29),
+
+    FUTURE_CANCEL(35);
+
+    private final int code;
+    private final static Map<Integer, RequestMethodCode> ENUM_MAP = new HashMap<Integer,
RequestMethodCode>();
+
+    static {
+        for (RequestMethodCode e : RequestMethodCode.values()) ENUM_MAP.put(e.code, e);
+    }
+
+    private RequestMethodCode(int code) {
+        this.code = code;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public static RequestMethodCode valueOf(int key) {
+        RequestMethodCode result = ENUM_MAP.get(key);
+        if (result == null) throw new IllegalArgumentException();
+        return result;
+    }
+}

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodConstants.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodConstants.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodConstants.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodConstants.java
Mon Feb 20 19:16:48 2012
@@ -28,29 +28,5 @@ public class RequestMethodConstants {
     public static final byte STOP_REQUEST_quit = (byte) 'q';
     public static final byte STOP_REQUEST_Stop = (byte) 'S';
     public static final byte STOP_REQUEST_stop = (byte) 's';
-
-    public static final int EJB_HOME_GET_EJB_META_DATA = 1;
-    public static final int EJB_HOME_GET_HOME_HANDLE = 2;
-    public static final int EJB_HOME_REMOVE_BY_HANDLE = 3;
-    public static final int EJB_HOME_REMOVE_BY_PKEY = 4;
-
-    public static final int EJB_HOME_FIND = 9;
-    public static final int EJB_HOME_CREATE = 10;
-
-    public static final int EJB_OBJECT_GET_EJB_HOME = 14;
-    public static final int EJB_OBJECT_GET_HANDLE = 15;
-    public static final int EJB_OBJECT_GET_PRIMARY_KEY = 16;
-    public static final int EJB_OBJECT_IS_IDENTICAL = 17;
-    public static final int EJB_OBJECT_REMOVE = 18;
-
-    public static final int EJB_OBJECT_BUSINESS_METHOD = 23;
-    public static final int EJB_HOME_METHOD = 24;
-
-    public static final int JNDI_LOOKUP = 27;
-    public static final int JNDI_LIST = 28;
-    public static final int JNDI_LIST_BINDINGS = 29;
-
-    public static final int FUTURE_CANCEL = 35;
-
 }
 

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBHomeHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBHomeHandler.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBHomeHandler.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBHomeHandler.java
Mon Feb 20 19:16:48 2012
@@ -51,7 +51,7 @@ public class StatefulEJBHomeHandler exte
             throw new SystemException(new IllegalArgumentException("The handle is not from
the same deployment"));
         }
 
-        EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_HOME_REMOVE_BY_HANDLE,
ejb, method, args, primKey);
+        EJBRequest req = new EJBRequest(RequestMethodCode.EJB_HOME_REMOVE_BY_HANDLE, ejb,
method, args, primKey);
 
         EJBResponse res = request(req);
 

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBObjectHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBObjectHandler.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBObjectHandler.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/StatefulEJBObjectHandler.java
Mon Feb 20 19:16:48 2012
@@ -56,7 +56,7 @@ public class StatefulEJBObjectHandler ex
     
     protected Object remove(Method method, Object[] args, Object proxy) throws Throwable
{
 
-        EJBRequest req = new EJBRequest(RequestMethodConstants.EJB_OBJECT_REMOVE, ejb, method,
args, primaryKey);
+        EJBRequest req = new EJBRequest(RequestMethodCode.EJB_OBJECT_REMOVE, ejb, method,
args, primaryKey);
 
         EJBResponse res = request(req);
 

Modified: openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/EJBRequestTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/EJBRequestTest.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/EJBRequestTest.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/EJBRequestTest.java
Mon Feb 20 19:16:48 2012
@@ -42,7 +42,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testEJBHomeCreate() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_HOME_CREATE;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_HOME_CREATE;
         Method method = FooHome.class.getMethod("create", new Class[]{});
         Object[] args = new Object[]{};
 
@@ -50,7 +50,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testEJBHomeFind() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_HOME_FIND;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_HOME_FIND;
         Method method = FooHome.class.getMethod("findByPrimaryKey", new Class[]{Integer.class});
         Object[] args = new Object[]{new Integer(4)};
 
@@ -58,7 +58,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testEJBHomeRemove1() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_HOME_REMOVE_BY_HANDLE;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_HOME_REMOVE_BY_HANDLE;
         Method method = FooHome.class.getMethod("remove", new Class[]{Handle.class});
         Object[] args = new Object[]{null};
 
@@ -66,7 +66,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testEJBHomeRemove2() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_HOME_REMOVE_BY_PKEY;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_HOME_REMOVE_BY_PKEY;
         Method method = FooHome.class.getMethod("remove", new Class[]{Object.class});
         Object[] args = new Object[]{new Integer(4)};
 
@@ -74,7 +74,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testGetMetaData() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_HOME_GET_EJB_META_DATA;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_HOME_GET_EJB_META_DATA;
         Method method = FooHome.class.getMethod("getEJBMetaData", new Class[]{});
         Object[] args = new Object[]{};
 
@@ -82,7 +82,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testGetHomeHandle() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_HOME_GET_HOME_HANDLE;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_HOME_GET_HOME_HANDLE;
         Method method = FooHome.class.getMethod("getHomeHandle", new Class[]{});
         Object[] args = new Object[]{};
 
@@ -90,7 +90,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testBusinessMethod() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_OBJECT_BUSINESS_METHOD;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_OBJECT_BUSINESS_METHOD;
         Method method = FooObject.class.getMethod("businessMethod", new Class[]{String.class});
         Object[] args = new Object[]{"hola mundo"};
 
@@ -98,7 +98,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testGetEJBHome() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_OBJECT_GET_EJB_HOME;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_OBJECT_GET_EJB_HOME;
         Method method = FooObject.class.getMethod("getEJBHome", new Class[]{});
         Object[] args = new Object[]{};
 
@@ -106,7 +106,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testGetHandle() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_OBJECT_GET_HANDLE;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_OBJECT_GET_HANDLE;
         Method method = FooObject.class.getMethod("getHandle", new Class[]{});
         Object[] args = new Object[]{};
 
@@ -114,7 +114,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testGetPrimaryKey() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_OBJECT_GET_PRIMARY_KEY;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_OBJECT_GET_PRIMARY_KEY;
         Method method = FooObject.class.getMethod("getPrimaryKey", new Class[]{});
         Object[] args = new Object[]{};
 
@@ -122,7 +122,7 @@ public class EJBRequestTest extends Test
     }
 
     public void testIsIdentical() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_OBJECT_IS_IDENTICAL;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_OBJECT_IS_IDENTICAL;
         Method method = FooObject.class.getMethod("isIdentical", new Class[]{EJBObject.class});
         Object[] args = new Object[]{null};
 
@@ -130,14 +130,14 @@ public class EJBRequestTest extends Test
     }
 
     public void testEJBObjectRemove() throws Exception {
-        int requestMethod = RequestMethodConstants.EJB_OBJECT_REMOVE;
+        RequestMethodCode requestMethod = RequestMethodCode.EJB_OBJECT_REMOVE;
         Method method = FooObject.class.getMethod("remove", new Class[]{});
         Object[] args = new Object[]{};
 
         invoke(requestMethod, method, args);
     }
 
-    private void invoke(int requestMethod, Method method, Object[] args) throws IOException,
ClassNotFoundException {
+    private void invoke(RequestMethodCode requestMethod, Method method, Object[] args) throws
IOException, ClassNotFoundException {
         EJBRequest expected = new EJBRequest(requestMethod, ejb, method, args, null);
 
         EJBRequest actual = new EJBRequest();

Modified: openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/JndiRequestTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/JndiRequestTest.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/JndiRequestTest.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/test/java/org/apache/openejb/client/JndiRequestTest.java
Mon Feb 20 19:16:48 2012
@@ -31,7 +31,7 @@ import java.io.ObjectOutputStream;
 public class JndiRequestTest extends TestCase {
 
     public void testExternalize() throws Exception {
-        JNDIRequest expected = new JNDIRequest(RequestMethodConstants.JNDI_LOOKUP, "this/is/a/jndi/name");
+        JNDIRequest expected = new JNDIRequest(RequestMethodCode.JNDI_LOOKUP, "this/is/a/jndi/name");
         JNDIRequest actual = new JNDIRequest();
 
         externalize(expected, actual);
@@ -43,7 +43,7 @@ public class JndiRequestTest extends Tes
 
 
     public void testExternalize2() throws Exception {
-        JNDIRequest expected = new JNDIRequest(RequestMethodConstants.JNDI_LOOKUP, "this/is/a/jndi/name");
+        JNDIRequest expected = new JNDIRequest(RequestMethodCode.JNDI_LOOKUP, "this/is/a/jndi/name");
         expected.setModuleId("foobar");
         JNDIRequest actual = new JNDIRequest();
 

Modified: openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
(original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
Mon Feb 20 19:16:48 2012
@@ -124,73 +124,73 @@ class EjbRequestHandler {
         try {
             switch (req.getRequestMethod()) {
                 // Remote interface methods
-                case RequestMethodConstants.EJB_OBJECT_BUSINESS_METHOD:
+                case EJB_OBJECT_BUSINESS_METHOD:
                     doEjbObject_BUSINESS_METHOD(req, res);
                     updateServer(req, res);
                     break;
 
                 // Home interface methods
-                case RequestMethodConstants.EJB_HOME_CREATE:
+                case EJB_HOME_CREATE:
                     doEjbHome_CREATE(req, res);
                     updateServer(req, res);
                     break;
 
                 // Home interface methods
-                case RequestMethodConstants.EJB_HOME_METHOD:
+                case EJB_HOME_METHOD:
                     doEjbHome_METHOD(req, res);
                     updateServer(req, res);
                     break;
 
-                case RequestMethodConstants.EJB_HOME_FIND:
+                case EJB_HOME_FIND:
                     doEjbHome_FIND(req, res);
                     updateServer(req, res);
                     break;
 
                 // javax.ejb.EJBObject methods
-                case RequestMethodConstants.EJB_OBJECT_GET_EJB_HOME:
+                case EJB_OBJECT_GET_EJB_HOME:
                     doEjbObject_GET_EJB_HOME(req, res);
                     updateServer(req, res);
                     break;
 
-                case RequestMethodConstants.EJB_OBJECT_GET_HANDLE:
+                case EJB_OBJECT_GET_HANDLE:
                     doEjbObject_GET_HANDLE(req, res);
                     updateServer(req, res);
                     break;
 
-                case RequestMethodConstants.EJB_OBJECT_GET_PRIMARY_KEY:
+                case EJB_OBJECT_GET_PRIMARY_KEY:
                     doEjbObject_GET_PRIMARY_KEY(req, res);
                     updateServer(req, res);
                     break;
 
-                case RequestMethodConstants.EJB_OBJECT_IS_IDENTICAL:
+                case EJB_OBJECT_IS_IDENTICAL:
                     doEjbObject_IS_IDENTICAL(req, res);
                     updateServer(req, res);
                     break;
 
-                case RequestMethodConstants.EJB_OBJECT_REMOVE:
+                case EJB_OBJECT_REMOVE:
                     doEjbObject_REMOVE(req, res);
                     break;
 
                 // javax.ejb.EJBHome methods
-                case RequestMethodConstants.EJB_HOME_GET_EJB_META_DATA:
+                case EJB_HOME_GET_EJB_META_DATA:
                     doEjbHome_GET_EJB_META_DATA(req, res);
                     updateServer(req, res);
                     break;
 
-                case RequestMethodConstants.EJB_HOME_GET_HOME_HANDLE:
+                case EJB_HOME_GET_HOME_HANDLE:
                     doEjbHome_GET_HOME_HANDLE(req, res);
                     updateServer(req, res);
                     break;
 
-                case RequestMethodConstants.EJB_HOME_REMOVE_BY_HANDLE:
+                case EJB_HOME_REMOVE_BY_HANDLE:
                     doEjbHome_REMOVE_BY_HANDLE(req, res);
                     break;
 
-                case RequestMethodConstants.EJB_HOME_REMOVE_BY_PKEY:
+                case EJB_HOME_REMOVE_BY_PKEY:
                     doEjbHome_REMOVE_BY_PKEY(req, res);
                     break;
 
-                case RequestMethodConstants.FUTURE_CANCEL:
+                case FUTURE_CANCEL:
                     doFUTURE_CANCEL_METHOD(req, res);
                     break;
             }

Modified: openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
(original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
Mon Feb 20 19:16:48 2012
@@ -139,8 +139,8 @@ class JndiRequestHandler {
             String prefix = getPrefix(req);
 
             switch(req.getRequestMethod()){
-                case RequestMethodConstants.JNDI_LOOKUP: doLookup(req, res, prefix); break;
-                case RequestMethodConstants.JNDI_LIST: doList(req, res, prefix); break;
+                case JNDI_LOOKUP: doLookup(req, res, prefix); break;
+                case JNDI_LIST: doList(req, res, prefix); break;
             }
 
         } catch (Throwable e) {

Modified: openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java?rev=1291415&r1=1291414&r2=1291415&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java
(original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java
Mon Feb 20 19:16:48 2012
@@ -46,7 +46,7 @@ public class DeploymentIndexTest {
     @Test
     public void testGetDeploymentEJBRequest() throws RemoteException {
         EJBMetaDataImpl ejbMetadataWithId = new EJBMetaDataImpl(null, null, null, null, null,
1, InterfaceType.BUSINESS_REMOTE, null, null);
-        EJBRequest request = new EJBRequest(0, ejbMetadataWithId, method, null, null);
+        EJBRequest request = new EJBRequest(null, ejbMetadataWithId, method, null, null);
         BeanContext info = deploymentIndex.getDeployment(request);
         assert beanContext.equals(info);
         assert request.getDeploymentId().equals(info.getDeploymentID());
@@ -56,7 +56,7 @@ public class DeploymentIndexTest {
     public void testGetDeploymentEJBRequestRemoteException() throws RemoteException {
         // 0 causes DeploymentIndex to move further
         EJBMetaDataImpl ejbMetadata = new EJBMetaDataImpl(null, null, null, null, null, 0,
InterfaceType.BUSINESS_REMOTE, null, null);
-        EJBRequest request = new EJBRequest(0, ejbMetadata, method, null, null);
+        EJBRequest request = new EJBRequest(null, ejbMetadata, method, null, null);
         deploymentIndex.getDeployment(request);
     }
 



Mime
View raw message