tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1291431 - in /openejb/trunk/openejb/server: openejb-client/src/main/java/org/apache/openejb/client/ openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/ openejb-server/src/main/java/org/apache/openejb/server/admin/
Date Mon, 20 Feb 2012 20:25:56 GMT
Author: adc
Date: Mon Feb 20 20:25:56 2012
New Revision: 1291431

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

Added:
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestType.java
Removed:
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestMethodConstants.java
Modified:
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/AuthenticationRequest.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ClusterRequest.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/JNDIRequest.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Request.java
    openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbDaemon.java
    openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
    openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/AdminDaemon.java
    openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/Stop.java

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/AuthenticationRequest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/AuthenticationRequest.java?rev=1291431&r1=1291430&r2=1291431&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/AuthenticationRequest.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/AuthenticationRequest.java
Mon Feb 20 20:25:56 2012
@@ -39,8 +39,8 @@ public class AuthenticationRequest imple
         this.credentials = credentials;
     }
 
-    public byte getRequestType() {
-        return RequestMethodConstants.AUTH_REQUEST;
+    public RequestType getRequestType() {
+        return RequestType.AUTH_REQUEST;
     }
 
     public String getRealm() {

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java?rev=1291431&r1=1291430&r2=1291431&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
Mon Feb 20 20:25:56 2012
@@ -165,7 +165,7 @@ public class Client {
             try {
 
                 ClusterRequest clusterRequest = new ClusterRequest(cluster);
-                objectOut.write(clusterRequest.getRequestType());
+                objectOut.write(clusterRequest.getRequestType().getCode());
                 clusterRequest.writeExternal(objectOut);
 
             } catch (Throwable e) {
@@ -177,7 +177,7 @@ public class Client {
             /*----------------------------------*/
             try {
 
-                objectOut.write(req.getRequestType());
+                objectOut.write(req.getRequestType().getCode());
 
             } catch (IOException e) {
                 throw newIOException("Cannot write the request type to the server: ", e);

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ClusterRequest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ClusterRequest.java?rev=1291431&r1=1291430&r2=1291431&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ClusterRequest.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ClusterRequest.java
Mon Feb 20 20:25:56 2012
@@ -33,8 +33,8 @@ public class ClusterRequest implements R
         clusterMetaDataVersion = clusterMetaData.getVersion();
     }
 
-    public byte getRequestType() {
-        return RequestMethodConstants.CLUSTER_REQUEST;
+    public RequestType getRequestType() {
+        return RequestType.CLUSTER_REQUEST;
     }
 
     public long getClusterMetaDataVersion() {

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=1291431&r1=1291430&r2=1291431&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 20:25:56 2012
@@ -439,8 +439,8 @@ public class EJBRequest implements Clust
         private static final int A = 9;
     }
 
-    public byte getRequestType() {
-        return RequestMethodConstants.EJB_REQUEST;
+    public RequestType getRequestType() {
+        return RequestType.EJB_REQUEST;
     }
 
     public RequestMethodCode getRequestMethod() {

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=1291431&r1=1291430&r2=1291431&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 20:25:56 2012
@@ -35,8 +35,8 @@ public class JNDIRequest implements Clus
         this.requestString = requestString;
     }
 
-    public byte getRequestType() {
-        return RequestMethodConstants.JNDI_REQUEST;
+    public RequestType getRequestType() {
+        return RequestType.JNDI_REQUEST;
     }
 
     public RequestMethodCode getRequestMethod() {

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Request.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Request.java?rev=1291431&r1=1291430&r2=1291431&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Request.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Request.java
Mon Feb 20 20:25:56 2012
@@ -23,7 +23,7 @@ import java.io.ObjectOutput;
 
 public interface Request extends Externalizable {
 
-    public byte getRequestType();
+    public RequestType getRequestType();
 
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException;
 

Added: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestType.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestType.java?rev=1291431&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestType.java
(added)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/RequestType.java
Mon Feb 20 20:25:56 2012
@@ -0,0 +1,57 @@
+/**
+ * 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 RequestType {
+    NOP_REQUEST((byte) -1),
+    EJB_REQUEST((byte) 0),
+    JNDI_REQUEST((byte) 1),
+    AUTH_REQUEST((byte) 2),
+    CLUSTER_REQUEST((byte) 3),
+    STOP_REQUEST_Quit((byte) 'Q'),
+    STOP_REQUEST_quit((byte) 'q'),
+    STOP_REQUEST_Stop((byte) 'S'),
+    STOP_REQUEST_stop((byte) 's');
+
+    private final byte code;
+    private final static Map<Byte, RequestType> ENUM_MAP = new HashMap<Byte, RequestType>();
+
+    static {
+        for (RequestType e : RequestType.values()) ENUM_MAP.put(e.code, e);
+    }
+
+    private RequestType(byte code) {
+        this.code = code;
+    }
+
+    public byte getCode() {
+        return code;
+    }
+
+    public static RequestType valueOf(byte key) {
+        RequestType result = ENUM_MAP.get(key);
+        if (result == null) throw new IllegalArgumentException();
+        return result;
+    }
+}

Modified: openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbDaemon.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbDaemon.java?rev=1291431&r1=1291430&r2=1291431&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbDaemon.java
(original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbDaemon.java
Mon Feb 20 20:25:56 2012
@@ -123,7 +123,8 @@ public class EjbDaemon implements org.ap
 
         ObjectInputStream ois = null;
         ObjectOutputStream oos = null;
-        byte requestType = -1;
+        RequestType requestType = null;
+        byte requestTypeByte = RequestType.NOP_REQUEST.getCode();
 
         try {
 
@@ -140,19 +141,21 @@ public class EjbDaemon implements org.ap
             ClientObjectFactory.serverMetaData.set(serverMetaData);
 
             // Read request type
-            requestType = (byte) ois.read();
+            requestTypeByte = (byte) ois.read();
+            requestType = RequestType.valueOf(requestTypeByte);
 
-            if (requestType == -1) {
+            if (requestType == RequestType.NOP_REQUEST) {
                 return;
             }
 
-            if (requestType == RequestMethodConstants.CLUSTER_REQUEST) {
+            if (requestType == RequestType.CLUSTER_REQUEST) {
                 processClusterRequest(ois, oos);
             }
 
-            requestType = (byte) ois.read();
+            requestTypeByte = (byte) ois.read();
+            requestType = RequestType.valueOf(requestTypeByte);
 
-            if (requestType == -1) {
+            if (requestType == RequestType.NOP_REQUEST) {
                 return;
             }
 
@@ -160,23 +163,25 @@ public class EjbDaemon implements org.ap
             // They should handle their own exceptions and clean
             // things up with the client accordingly.
             switch (requestType) {
-                case RequestMethodConstants.EJB_REQUEST:
+                case EJB_REQUEST:
                     processEjbRequest(ois, oos);
                     break;
-                case RequestMethodConstants.JNDI_REQUEST:
+                case JNDI_REQUEST:
                     processJndiRequest(ois, oos);
                     break;
-                case RequestMethodConstants.AUTH_REQUEST:
+                case AUTH_REQUEST:
                     processAuthRequest(ois, oos);
                     break;
                 default:
-                    logger.error("\"" + getTypeName(requestType) + " " + protocolMetaData.getSpec()
+ "\" FAIL \"Unknown request type " + requestType);
+                    logger.error("\"" + requestType + " " + protocolMetaData.getSpec() +
"\" FAIL \"Unknown request type " + requestType);
                     break;
             }
+        } catch (IllegalArgumentException iae) {
+            logger.error("\"" + protocolMetaData.getSpec() + "\" FAIL \"Unknown request type
" + requestTypeByte);
         } catch (SecurityException e) {
-            logger.error("\"" + getTypeName(requestType) + " " + protocolMetaData.getSpec()
+ "\" FAIL \"Security error - " + e.getMessage() + "\"", e);
+            logger.error("\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL
\"Security error - " + e.getMessage() + "\"", e);
         } catch (Throwable e) {
-            logger.error("\"" + getTypeName(requestType) + " " + protocolMetaData.getSpec()
+ "\" FAIL \"Unexpected error - " + e.getMessage() + "\"", e);
+            logger.error("\"" + requestType + " " + protocolMetaData.getSpec() + "\" FAIL
\"Unexpected error - " + e.getMessage() + "\"", e);
         } finally {
 
             ClientObjectFactory.serverMetaData.remove();
@@ -206,19 +211,6 @@ public class EjbDaemon implements org.ap
         }
     }
 
-    private static String getTypeName(final byte requestType) {
-        switch (requestType) {
-            case RequestMethodConstants.EJB_REQUEST:
-                return "EJB_REQUEST";
-            case RequestMethodConstants.JNDI_REQUEST:
-                return "JNDI_REQUEST";
-            case RequestMethodConstants.AUTH_REQUEST:
-                return "AUTH_REQUEST";
-            default:
-                return requestType + " (UNKNOWN)";
-        }
-    }
-
     private void processClusterRequest(ObjectInputStream in, ObjectOutputStream out) throws
IOException {
         clusterHandler.processRequest(in, out);
     }

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=1291431&r1=1291430&r2=1291431&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 20:25:56 2012
@@ -25,9 +25,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
-
 import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 import javax.naming.NameClassPair;
@@ -40,13 +38,12 @@ import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
 import javax.xml.namespace.QName;
 
+import org.omg.CORBA.ORB;
+import static org.apache.openejb.server.ejbd.ClientObjectFactory.convert;
+
 import org.apache.openejb.BeanContext;
 import org.apache.openejb.Injection;
 import org.apache.openejb.ProxyInfo;
-import static org.apache.openejb.server.ejbd.ClientObjectFactory.convert;
-
-import org.apache.openejb.assembler.classic.Assembler;
-import org.apache.openejb.assembler.classic.ValidationInfo;
 import org.apache.openejb.client.CallbackMetaData;
 import org.apache.openejb.client.DataSourceMetaData;
 import org.apache.openejb.client.EJBMetaDataImpl;
@@ -57,7 +54,6 @@ import org.apache.openejb.client.JNDIReq
 import org.apache.openejb.client.JNDIResponse;
 import org.apache.openejb.client.NameClassPairEnumeration;
 import org.apache.openejb.client.PortRefMetaData;
-import org.apache.openejb.client.RequestMethodConstants;
 import org.apache.openejb.client.ResponseCodes;
 import org.apache.openejb.client.ThrowableArtifact;
 import org.apache.openejb.client.WsMetaData;
@@ -74,16 +70,17 @@ import org.apache.openejb.spi.ContainerS
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.proxy.ProxyManager;
-import org.omg.CORBA.ORB;
+
 
 class JndiRequestHandler {
+
     private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_SERVER_REMOTE.createChild("jndi"),
"org.apache.openejb.server.util.resources");
 
     private final Context ejbJndiTree;
     private Context clientJndiTree;
     private final Context deploymentsJndiTree;
 
-    private Context globalJndiTree;    
+    private Context globalJndiTree;
 
     private final ClusterableRequestHandler clusterableRequestHandler;
     private Context rootContext;
@@ -93,12 +90,12 @@ class JndiRequestHandler {
         ejbJndiTree = (Context) containerSystem.getJNDIContext().lookup("openejb/remote");
         deploymentsJndiTree = (Context) containerSystem.getJNDIContext().lookup("openejb/Deployment");
 
-        globalJndiTree = (Context) containerSystem.getJNDIContext().lookup("openejb/global");

+        globalJndiTree = (Context) containerSystem.getJNDIContext().lookup("openejb/global");
 
         rootContext = containerSystem.getJNDIContext();
         try {
             clientJndiTree = (Context) containerSystem.getJNDIContext().lookup("openejb/client");
-        } catch (NamingException e) {
+        } catch (NamingException ignore) {
         }
         clusterableRequestHandler = newClusterableRequestHandler();
     }
@@ -119,10 +116,11 @@ class JndiRequestHandler {
             namingException.setRootCause(e);
             res.setResult(new ThrowableArtifact(namingException));
 
-            if (logger.isDebugEnabled()){
+            if (logger.isDebugEnabled()) {
                 try {
-                    logger.debug("JNDI REQUEST: "+req+" -- RESPONSE: " + res);
-                } catch (Exception justInCase) {}
+                    logger.debug("JNDI REQUEST: " + req + " -- RESPONSE: " + res);
+                } catch (Exception ignore) {
+                }
             }
 
             try {
@@ -138,9 +136,13 @@ class JndiRequestHandler {
             }
             String prefix = getPrefix(req);
 
-            switch(req.getRequestMethod()){
-                case JNDI_LOOKUP: doLookup(req, res, prefix); break;
-                case JNDI_LIST: doList(req, res, prefix); break;
+            switch (req.getRequestMethod()) {
+                case JNDI_LOOKUP:
+                    doLookup(req, res, prefix);
+                    break;
+                case JNDI_LIST:
+                    doList(req, res, prefix);
+                    break;
             }
 
         } catch (Throwable e) {
@@ -150,10 +152,11 @@ class JndiRequestHandler {
             res.setResult(new ThrowableArtifact(namingException));
         } finally {
 
-            if (logger.isDebugEnabled()){
+            if (logger.isDebugEnabled()) {
                 try {
-                    logger.debug("JNDI REQUEST: "+req+" -- RESPONSE: " + res);
-                } catch (Exception justInCase) {}
+                    logger.debug("JNDI REQUEST: " + req + " -- RESPONSE: " + res);
+                } catch (Exception ignore) {
+                }
             }
 
             try {
@@ -170,9 +173,9 @@ class JndiRequestHandler {
 
         if (name.startsWith("openejb/Deployment/")) {
             prefix = "";
-        } else if (req.getModuleId() != null && req.getModuleId().equals("openejb/Deployment")){
+        } else if (req.getModuleId() != null && req.getModuleId().equals("openejb/Deployment"))
{
             prefix = "openejb/Deployment/";
-        } else if (req.getModuleId() != null && req.getModuleId().equals("openejb/global")){
+        } else if (req.getModuleId() != null && req.getModuleId().equals("openejb/global"))
{
             prefix = "openejb/global/";
         } else if (req.getModuleId() != null && clientJndiTree != null) {
             prefix = "openejb/client/" + req.getModuleId() + "/";// + (Context) clientJndiTree.lookup(req.getModuleId());
@@ -207,7 +210,7 @@ class JndiRequestHandler {
                 res.setResponseCode(ResponseCodes.JNDI_CONTEXT);
                 return;
             } else if (object == null) {
-                throw new NullPointerException("lookup of '"+name+"' returned null");
+                throw new NullPointerException("lookup of '" + name + "' returned null");
             } else if (object instanceof DataSource) {
                 if (isDbcpDataSource(object)) {
                     try {
@@ -225,11 +228,11 @@ class JndiRequestHandler {
                     res.setResult(((Referenceable) object).getReference());
                     return;
                 }
-            } else if (object instanceof ConnectionFactory){
+            } else if (object instanceof ConnectionFactory) {
                 res.setResponseCode(ResponseCodes.JNDI_RESOURCE);
                 res.setResult(ConnectionFactory.class.getName());
                 return;
-            } else if (object instanceof ORB){
+            } else if (object instanceof ORB) {
                 res.setResponseCode(ResponseCodes.JNDI_RESOURCE);
                 res.setResult(ORB.class.getName());
                 return;
@@ -315,7 +318,7 @@ class JndiRequestHandler {
                 }
 
                 // add port refs
-                Map<QName,PortRefMetaData> portsByQName = new HashMap<QName,PortRefMetaData>();
+                Map<QName, PortRefMetaData> portsByQName = new HashMap<QName, PortRefMetaData>();
                 for (PortRefData portRef : serviceRef.getPortRefs()) {
                     PortRefMetaData portRefMetaData = new PortRefMetaData();
                     portRefMetaData.setQName(portRef.getQName());
@@ -370,7 +373,7 @@ class JndiRequestHandler {
                 handler = (BaseEjbProxyHandler) field.get(object);
             } catch (Exception e1) {
                 // Not a proxy.  See if it's serializable and send it
-                if (object instanceof java.io.Serializable){
+                if (object instanceof java.io.Serializable) {
                     res.setResponseCode(ResponseCodes.JNDI_OK);
                     res.setResult(object);
                     return;
@@ -389,18 +392,18 @@ class JndiRequestHandler {
 
         updateServer(req, res, proxyInfo);
 
-        switch(proxyInfo.getInterfaceType()){
+        switch (proxyInfo.getInterfaceType()) {
             case EJB_HOME: {
                 res.setResponseCode(ResponseCodes.JNDI_EJBHOME);
                 EJBMetaDataImpl metaData = new EJBMetaDataImpl(beanContext.getHomeInterface(),
-                        beanContext.getRemoteInterface(),
-                        beanContext.getPrimaryKeyClass(),
-                        beanContext.getComponentType().toString(),
-                        deploymentID,
-                        -1,
-                        convert(proxyInfo.getInterfaceType()),
-                        null,
-                        beanContext.getAsynchronousMethodSignatures());
+                                                               beanContext.getRemoteInterface(),
+                                                               beanContext.getPrimaryKeyClass(),
+                                                               beanContext.getComponentType().toString(),
+                                                               deploymentID,
+                                                               -1,
+                                                               convert(proxyInfo.getInterfaceType()),
+                                                               null,
+                                                               beanContext.getAsynchronousMethodSignatures());
                 metaData.loadProperties(beanContext.getProperties());
                 log(metaData);
                 res.setResult(metaData);
@@ -415,14 +418,14 @@ class JndiRequestHandler {
             case BUSINESS_REMOTE: {
                 res.setResponseCode(ResponseCodes.JNDI_BUSINESS_OBJECT);
                 EJBMetaDataImpl metaData = new EJBMetaDataImpl(null,
-                        null,
-                        beanContext.getPrimaryKeyClass(),
-                        beanContext.getComponentType().toString(),
-                        deploymentID,
-                        -1,
-                        convert(proxyInfo.getInterfaceType()),
-                        proxyInfo.getInterfaces(),
-                        beanContext.getAsynchronousMethodSignatures());
+                                                               null,
+                                                               beanContext.getPrimaryKeyClass(),
+                                                               beanContext.getComponentType().toString(),
+                                                               deploymentID,
+                                                               -1,
+                                                               convert(proxyInfo.getInterfaceType()),
+                                                               proxyInfo.getInterfaces(),
+                                                               beanContext.getAsynchronousMethodSignatures());
                 metaData.setPrimaryKey(proxyInfo.getPrimaryKey());
                 metaData.loadProperties(beanContext.getProperties());
 
@@ -488,14 +491,14 @@ class JndiRequestHandler {
         String name = req.getRequestString();
         try {
             NamingEnumeration<NameClassPair> namingEnumeration = rootContext.list(prefix
+ name);
-            if (namingEnumeration == null){
+            if (namingEnumeration == null) {
                 res.setResponseCode(ResponseCodes.JNDI_OK);
                 res.setResult(null);
             } else {
                 res.setResponseCode(ResponseCodes.JNDI_ENUMERATION);
                 ArrayList<NameClassPair> list = Collections.list(namingEnumeration);
                 for (NameClassPair pair : list) {
-                    if (pair.getClassName().equals(IvmContext.class.getName())){
+                    if (pair.getClassName().equals(IvmContext.class.getName())) {
                         pair.setClassName(javax.naming.Context.class.getName());
                     }
                 }
@@ -503,16 +506,15 @@ class JndiRequestHandler {
             }
         } catch (NameNotFoundException e) {
             res.setResponseCode(ResponseCodes.JNDI_NOT_FOUND);
-            return;
         } catch (NamingException e) {
             res.setResponseCode(ResponseCodes.JNDI_NAMING_EXCEPTION);
             res.setResult(new ThrowableArtifact(e));
-            return;
         }
     }
 
 
     public static class DbcpDataSource {
+
         private final Object object;
         private final Class clazz;
 
@@ -525,13 +527,15 @@ class JndiRequestHandler {
             return (String) clazz.getMethod("getDriverClassName").invoke(object);
         }
 
-        public java.lang.String getPassword() throws Exception{
+        public java.lang.String getPassword() throws Exception {
             return (String) clazz.getMethod("getPassword").invoke(object);
         }
-        public java.lang.String getUrl() throws Exception{
+
+        public java.lang.String getUrl() throws Exception {
             return (String) clazz.getMethod("getUrl").invoke(object);
         }
-        public java.lang.String getUsername() throws Exception{
+
+        public java.lang.String getUsername() throws Exception {
             return (String) clazz.getMethod("getUsername").invoke(object);
         }
     }

Modified: openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/AdminDaemon.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/AdminDaemon.java?rev=1291431&r1=1291430&r2=1291431&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/AdminDaemon.java
(original)
+++ openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/AdminDaemon.java
Mon Feb 20 20:25:56 2012
@@ -20,10 +20,10 @@ import java.io.*;
 import java.net.*;
 import java.util.*;
 
+import org.apache.openejb.client.RequestType;
 import org.apache.openejb.server.ServerService;
 import org.apache.openejb.server.ServiceException;
 import org.apache.openejb.server.Server;
-import org.apache.openejb.client.RequestMethodConstants;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
@@ -41,24 +41,29 @@ public class AdminDaemon implements Serv
         try {
             in = socket.getInputStream();
 
-            byte requestType = (byte) in.read();
-
-            switch (requestType) {
-                case -1:
-                    return;
-                case RequestMethodConstants.STOP_REQUEST_Quit:
-                case RequestMethodConstants.STOP_REQUEST_quit:
-                case RequestMethodConstants.STOP_REQUEST_Stop:
-                case RequestMethodConstants.STOP_REQUEST_stop:
-                    Server server = SystemInstance.get().getComponent(Server.class);
-                    if (null != server) {
-						server.stop();
-					}
-                    break;
-                default:
-                    //If this turns up in the logs then it is time to take action
-                    Logger.getInstance(LogCategory.OPENEJB_SERVER, AdminDaemon.class).warning("Invalid
Server Socket request: " + requestType);
-                    break;
+            byte requestTypeByte = (byte) in.read();
+            try {
+                RequestType requestType = RequestType.valueOf(requestTypeByte);
+
+                switch (requestType) {
+                    case NOP_REQUEST:
+                        return;
+                    case STOP_REQUEST_Quit:
+                    case STOP_REQUEST_quit:
+                    case STOP_REQUEST_Stop:
+                    case STOP_REQUEST_stop:
+                        Server server = SystemInstance.get().getComponent(Server.class);
+                        if (null != server) {
+                            server.stop();
+                        }
+                        break;
+                    default:
+                        //If this turns up in the logs then it is time to take action
+                        Logger.getInstance(LogCategory.OPENEJB_SERVER, AdminDaemon.class).warning("Invalid
Server Socket request: " + requestType);
+                        break;
+                }
+            } catch (IllegalArgumentException iae) {
+                Logger.getInstance(LogCategory.OPENEJB_SERVER, AdminDaemon.class).warning("Invalid
Server Socket request: " + requestTypeByte);
             }
 
         } catch (Throwable e) {

Modified: openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/Stop.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/Stop.java?rev=1291431&r1=1291430&r2=1291431&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/Stop.java
(original)
+++ openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/Stop.java
Mon Feb 20 20:25:56 2012
@@ -23,7 +23,7 @@ import java.net.Socket;
 import java.net.URL;
 import java.util.Properties;
 
-import org.apache.openejb.client.RequestMethodConstants;
+import org.apache.openejb.client.RequestType;
 
 
 public class Stop {
@@ -36,7 +36,7 @@ public class Stop {
             Socket socket = new Socket(host, port);
             OutputStream out = socket.getOutputStream();
 
-            out.write(RequestMethodConstants.STOP_REQUEST_Stop);
+            out.write(RequestType.STOP_REQUEST_Stop.getCode());
 
         } catch (ConnectException e) {
             System.out.println(":: server not running ::");



Mime
View raw message