[jboss-cvs] JBoss Messaging SVN: r2022 - in trunk/src/main/org/jboss: jms/client/remoting and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 23 04:46:32 EST 2007


Author: ovidiu.feodorov at jboss.com
Date: 2007-01-23 04:46:32 -0500 (Tue, 23 Jan 2007)
New Revision: 2022

Modified:
   trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java
   trunk/src/main/org/jboss/jms/client/remoting/ClientSocketWrapper.java
   trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java
   trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java
   trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java
   trunk/src/main/org/jboss/messaging/core/SimpleDelivery.java
Log:
minor reformatting and logging improvments

Modified: trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java	2007-01-23 09:43:51 UTC (rev 2021)
+++ trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java	2007-01-23 09:46:32 UTC (rev 2022)
@@ -118,22 +118,23 @@
       // select invocations ought to be sent "one way" for increased performance
       if ("changeRate".equals(methodName))
       {
-         if (trace) { log.trace(this + " invoking " + methodName + " asynchronously on server"); }
+         if (trace) { log.trace(this + " invoking " + methodName + "(..) asynchronously on server"); }
 
          client.invokeOneway(request);
 
-         if (trace) { log.trace(this + " asynchronously invoked " + methodName + " on server, no response expected"); }
+         if (trace) { log.trace(this + " asynchronously invoked " + methodName + "(..) on server, no response expected"); }
 
          return null;
       }
       else
       {
-         if (trace) { log.trace(this + " invoking " + methodName + " synchronously on server"); }
+         if (trace) { log.trace(this + " invoking " + methodName + "(..) synchronously on server"); }
 
-         MessagingMarshallable response = (MessagingMarshallable)client.invoke(request, null);
+         Object o = client.invoke(request, null);
 
-         if (trace) { log.trace(this + " got server response for " + methodName); }
+         if (trace) { log.trace(this + " got server response for " + methodName + "(..): " + o); }
 
+         MessagingMarshallable response = (MessagingMarshallable)o;
          return response.getLoad();
       }
    }

Modified: trunk/src/main/org/jboss/jms/client/remoting/ClientSocketWrapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/ClientSocketWrapper.java	2007-01-23 09:43:51 UTC (rev 2021)
+++ trunk/src/main/org/jboss/jms/client/remoting/ClientSocketWrapper.java	2007-01-23 09:46:32 UTC (rev 2022)
@@ -33,8 +33,6 @@
 import java.net.Socket;
 import java.util.Map;
 
-import org.jboss.jms.server.remoting.ServerSocketWrapper;
-import org.jboss.logging.Logger;
 import org.jboss.remoting.transport.socket.SocketWrapper;
 
 /**
@@ -45,19 +43,16 @@
  */
 public class ClientSocketWrapper extends SocketWrapper
 {
-   // Constants -----------------------------------------------------
+   // Constants ------------------------------------------------------------------------------------
    
-   final static private Logger log = Logger.getLogger(ClientSocketWrapper.class);
+   // Static ---------------------------------------------------------------------------------------
 
+   // Attributes -----------------------------------------------------------------------------------
 
-   // Static --------------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
    private DataInputStream in;
    private DataOutputStream out;
 
-   // Constructors --------------------------------------------------
+   // Constructors ---------------------------------------------------------------------------------
 
    public ClientSocketWrapper(Socket socket) throws IOException
    {
@@ -71,7 +66,7 @@
       createStreams(socket, metadata);
    }
 
-   // Public --------------------------------------------------------
+   // SocketWrapper overrides ----------------------------------------------------------------------
 
    public OutputStream getOutputStream()
    {
@@ -93,10 +88,17 @@
       in.readByte();
    }
 
-   // Package protected ---------------------------------------------
+   // Public ---------------------------------------------------------------------------------------
 
-   // Protected -----------------------------------------------------
+   public String toString()
+   {
+      return "ClientSocketWrapper[" + getSocket() + "]";
+   }
 
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
    protected void createStreams(Socket socket, Map metadata) throws IOException
    {
       out = createOutputStream(socket);
@@ -119,8 +121,8 @@
       return new DataOutputStream(bout);
    }
 
-   // Private -------------------------------------------------------
+   // Private --------------------------------------------------------------------------------------
 
-   // Inner classes -------------------------------------------------
+   // Inner classes --------------------------------------------------------------------------------
 
 }

Modified: trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java	2007-01-23 09:43:51 UTC (rev 2021)
+++ trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java	2007-01-23 09:46:32 UTC (rev 2022)
@@ -48,13 +48,13 @@
  */
 public class JMSServerInvocationHandler implements ServerInvocationHandler
 {
-   // Constants -----------------------------------------------------
+   // Constants ------------------------------------------------------------------------------------
 
    private static final Logger log = Logger.getLogger(JMSServerInvocationHandler.class);
    
-   // Static --------------------------------------------------------
+   // Static ---------------------------------------------------------------------------------------
    
-   // Attributes ----------------------------------------------------
+   // Attributes -----------------------------------------------------------------------------------
 
    private ServerInvoker invoker;
    private MBeanServer server;
@@ -63,7 +63,7 @@
    
    private boolean trace;
    
-   // Constructors --------------------------------------------------
+   // Constructors ---------------------------------------------------------------------------------
 
    public JMSServerInvocationHandler()
    {
@@ -71,7 +71,7 @@
       trace = log.isTraceEnabled();
    }
 
-   // ServerInvocationHandler ---------------------------------------
+   // ServerInvocationHandler ----------------------------------------------------------------------
 
    public void setMBeanServer(MBeanServer server)
    {
@@ -130,7 +130,6 @@
       }
       
       InvocationResponse resp = JMSDispatcher.instance.invoke(i);
-      
       byte version = mm.getVersion();
       
       return new MessagingMarshallable(version, resp.getResponse());
@@ -191,18 +190,18 @@
       }
    }
 
-   // Public --------------------------------------------------------
+   // Public ---------------------------------------------------------------------------------------
 
    public String toString()
    {
       return "JMSServerInvocationHandler[" + invoker + ", " + server + "]";
    }
    
-   // Package protected ---------------------------------------------
+   // Package protected ----------------------------------------------------------------------------
    
-   // Protected -----------------------------------------------------
+   // Protected ------------------------------------------------------------------------------------
    
-   // Private -------------------------------------------------------
+   // Private --------------------------------------------------------------------------------------
    
-   // Inner classes -------------------------------------------------
+   // Inner classes --------------------------------------------------------------------------------
 }

Modified: trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java	2007-01-23 09:43:51 UTC (rev 2021)
+++ trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java	2007-01-23 09:46:32 UTC (rev 2022)
@@ -81,7 +81,7 @@
  */
 public class JMSWireFormat implements Marshaller, UnMarshaller
 {
-   // Constants -----------------------------------------------------
+   // Constants ------------------------------------------------------------------------------------
 
    private static final long serialVersionUID = -7646123424863782043L;
 
@@ -113,25 +113,48 @@
    protected static final byte CALLBACK_LIST = 106;
 
 
-   // Static --------------------------------------------------------
+   // Static ---------------------------------------------------------------------------------------
    
    public static void setUsingJBossSerialization(boolean b)
    {
       usingJBossSerialization = b;
    }
 
-   // Attributes ----------------------------------------------------
+   public static String formatTypeToString(byte formatType)
+   {
+      return
+         formatType == SERIALIZED ? "SERIALIZED" :
+         formatType == ACKNOWLEDGE ? "ACKNOWLEDGE" :
+         formatType == ACKNOWLEDGE_LIST ? "ACKNOWLEDGE_LIST" :
+         formatType == CANCEL ? "CANCEL" :
+         formatType == CANCEL_LIST ? "CANCEL_LIST" :
+         formatType == SEND ? "SEND" :
+         formatType == CHANGE_RATE ? "CHANGE_RATE" :
+         formatType == SEND_TRANSACTION ? "SEND_TRANSACTION" :
+         formatType == GET_ID_BLOCK ? "GET_ID_BLOCK" :
+         formatType == RECOVER_DELIVERIES ? "RECOVER_DELIVERIES" :
+         formatType == CANCEL_INFLIGHT_MESSAGES ? "CANCEL_INFLIGHT_MESSAGES" :
+         formatType == MESSAGE_DELIVERY ? "MESSAGE_DELIVERY" :
+         formatType == NULL_RESPONSE ? "NULL_RESPONSE" :
+         formatType == ID_BLOCK_RESPONSE ? "ID_BLOCK_RESPONSE" :
+         formatType == BROWSE_MESSAGE_RESPONSE ? "BROWSE_MESSAGE_RESPONSE" :
+         formatType == BROWSE_MESSAGES_RESPONSE ? "BROWSE_MESSAGES_RESPONSE" :
+         formatType == CALLBACK_LIST ? "CALLBACK_LIST" :
+            "UNKNOWN";
+   }
 
+   // Attributes -----------------------------------------------------------------------------------
+
    protected boolean trace;
 
-   // Constructors --------------------------------------------------
+   // Constructors ---------------------------------------------------------------------------------
 
    public JMSWireFormat()
    {
       trace = log.isTraceEnabled();
    }
 
-   // Marshaller implementation -------------------------------------
+   // Marshaller implementation --------------------------------------------------------------------
 
    public void write(Object obj, OutputStream out) throws IOException
    {          
@@ -163,10 +186,10 @@
       {
          if (obj instanceof InvocationRequest)
          {
-            if (trace) { log.trace("writing InvocationRequest"); }
-   
             InvocationRequest req = (InvocationRequest)obj;
-   
+
+            if (trace) { log.trace("writing " + obj); }
+
             Object param = req.getParameter();
             
             if (param instanceof OnewayInvocation)
@@ -202,8 +225,6 @@
                param = ((MessagingMarshallable)param).getLoad();
             }
 
-            if (trace) { log.trace("param is " + param); }
-   
             if (param instanceof MethodInvocation)
             {
                MethodInvocation mi = (MethodInvocation)param;
@@ -419,11 +440,11 @@
             }
             else
             {
-               //Internal invocation
+               // Internal invocation
    
                dos.write(SERIALIZED);
    
-               //Delegate to serialization to handle the wire format
+               // Delegate to serialization to handle the wire format
                serialize(dos, obj);
    
                if (trace) { log.trace("wrote using standard serialization"); }
@@ -558,7 +579,7 @@
       return this;
    }
 
-   // UnMarshaller implementation -----------------------------------
+   // UnMarshaller implementation ------------------------------------------------------------------
 
    public Object read(InputStream in, Map map) throws IOException, ClassNotFoundException
    {            
@@ -573,24 +594,25 @@
          // Further sanity check
          if (in instanceof ObjectInputStream)
          {
-            throw new IllegalArgumentException("Invalid stream - are you sure you have configured socket wrappers?");
+            throw new IllegalArgumentException("Invalid stream - are you sure you have " +
+                                               "configured socket wrappers?");
          }
          
          // This would be the case for the HTTP transport for example. Wrap the stream
          
          //TODO Ideally remoting would let us wrap this before invoking the marshaller
-         //but this does not appear to be possible
+         //     but this does not appear to be possible
          dis = new DataInputStream(in);
       }
       
       // First byte read is always version
 
       byte version = dis.readByte();
+      if (trace) { log.trace("read version " + version + " from " + dis); }
 
       byte formatType = (byte)dis.read();
+      if (trace) { log.trace("read format type " + formatTypeToString(formatType) + " from " + dis); }
 
-      if (trace) { log.trace("reading, format type is " + formatType); }
-      
       try
       {
    
@@ -601,7 +623,7 @@
                // Delegate to serialization
                Object ret = deserialize(dis);
    
-               if (trace) { log.trace("read using standard serialization"); }
+               if (trace) { log.trace("read " + ret + " using standard serialization"); }
    
                return ret;
             }
@@ -883,19 +905,18 @@
                   msgs[i] = msg;
                }
                
-               InvocationResponse resp = new InvocationResponse(null, new MessagingMarshallable(version, msgs), false, null);
+               InvocationResponse resp =
+                  new InvocationResponse(null, new MessagingMarshallable(version, msgs), false, null);
    
                if (trace) { log.trace("read browse message response"); }
    
                return resp;
             }
             case NULL_RESPONSE:
-            {    
-               InvocationResponse resp =
-                  new InvocationResponse(null, new MessagingMarshallable(version, null), false, null);
-   
+            {
+               MessagingMarshallable mm = new MessagingMarshallable(version, null);
+               InvocationResponse resp = new InvocationResponse(null, mm, false, null);
                if (trace) { log.trace("read null response"); }
-   
                return resp;
             }
             case MESSAGE_DELIVERY:
@@ -970,11 +991,11 @@
    {
    }
 
-   // Public --------------------------------------------------------
+   // Public ---------------------------------------------------------------------------------------
 
-   // Package protected ---------------------------------------------
+   // Package protected ----------------------------------------------------------------------------
 
-   // Protected -----------------------------------------------------
+   // Protected ------------------------------------------------------------------------------------
 
    protected void handleVersion(Object obj, DataOutputStream oos) throws IOException
    {
@@ -1009,11 +1030,12 @@
       oos.writeByte(version);
    }
 
-   // Private -------------------------------------------------------
+   // Private --------------------------------------------------------------------------------------
 
    private void writeHeader(MethodInvocation mi, DataOutputStream dos) throws IOException
    {
-      int objectId = ((Integer)mi.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue();
+      int objectId =
+         ((Integer)mi.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue();
 
       dos.writeInt(objectId);
 
@@ -1067,5 +1089,5 @@
       return ois.readObject();
    }
 
-   // Inner classes -------------------------------------------------
+   // Inner classes --------------------------------------------------------------------------------
 }

Modified: trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java	2007-01-23 09:43:51 UTC (rev 2021)
+++ trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java	2007-01-23 09:46:32 UTC (rev 2022)
@@ -27,9 +27,6 @@
 import java.io.ObjectOutput;
 
 /**
- * 
- * A MessagingMarshallableSupport.
- * 
  * @author <a href="tim.fox at jboss.com">Tim Fox</a>
  * @version $Revision$
  *
@@ -37,31 +34,51 @@
  */
 public class MessagingMarshallable implements Externalizable
 {
-   // Constants -----------------------------------------------------
+   // Constants ------------------------------------------------------------------------------------
 
    private static final long serialVersionUID = 4715063783844562048L;
    
-   // Static --------------------------------------------------------
+   // Static ---------------------------------------------------------------------------------------
 
-   // Attributes ----------------------------------------------------
+   // Attributes -----------------------------------------------------------------------------------
    
-   protected byte version;
-   protected Object load;
+   private byte version;
+   private Object load;
 
-   // Constructors --------------------------------------------------
+   // it only works as long this class is immutable
+   private String toString;
 
+   // Constructors ---------------------------------------------------------------------------------
+
    public MessagingMarshallable()
    {     
    }
-   
+
+   /**
+    * @param load - can be null (for example, in case of "void" invocation response).
+    */
    public MessagingMarshallable(byte version, Object load)
    {
       this.version = version;
       this.load = load;
    }
 
-   // Public --------------------------------------------------------
+   // Externalizable implemenation -----------------------------------------------------------------
 
+   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+   {
+      version = in.readByte();
+      load = in.readObject();
+   }
+
+   public void writeExternal(ObjectOutput out) throws IOException
+   {
+      out.writeByte(version);
+      out.writeObject(load);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
    public Object getLoad()
    {
       return load;
@@ -74,29 +91,33 @@
 
    public String toString()
    {
-      return "MessagingMarshallable[" + version + ", " + load + "]";
-   }
+      if (toString == null)
+      {
+         // this only works as long as this class is immutable
+         StringBuffer sb = new StringBuffer("MessagingMarshallable[");
+         //sb.append(Integer.toHexString(hashCode())).append(", ");
+         sb.append("v").append(version).append(", ");
+         if (load == null)
+         {
+            sb.append("EMPTY");
+         }
+         else
+         {
+            sb.append(load);
+         }
+         sb.append(']');
+         toString = sb.toString();
+      }
 
-   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
-   {
-      version = in.readByte();
-      
-      load = in.readObject();
+      return toString;
    }
 
-   public void writeExternal(ObjectOutput out) throws IOException
-   {
-      out.writeByte(version);
-      
-      out.writeObject(load);
-   }
+   // Package protected ----------------------------------------------------------------------------
 
-   // Package protected ---------------------------------------------
+   // Protected ------------------------------------------------------------------------------------
 
-   // Protected -----------------------------------------------------
+   // Private --------------------------------------------------------------------------------------
 
-   // Private -------------------------------------------------------
+   // Inner classes --------------------------------------------------------------------------------
 
-   // Inner classes -------------------------------------------------
-
 }

Modified: trunk/src/main/org/jboss/messaging/core/SimpleDelivery.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/SimpleDelivery.java	2007-01-23 09:43:51 UTC (rev 2021)
+++ trunk/src/main/org/jboss/messaging/core/SimpleDelivery.java	2007-01-23 09:46:32 UTC (rev 2022)
@@ -35,13 +35,13 @@
  */
 public class SimpleDelivery implements Delivery
 {
-   // Constants -----------------------------------------------------
+   // Constants ------------------------------------------------------------------------------------
 
-   // Static --------------------------------------------------------
+   // Static ---------------------------------------------------------------------------------------
    
    private static final Logger log = Logger.getLogger(SimpleDelivery.class);
    
-   // Attributes ----------------------------------------------------
+   // Attributes -----------------------------------------------------------------------------------
 
    protected volatile boolean done;
    protected boolean selectorAccepted;
@@ -50,7 +50,7 @@
 
    private boolean trace = log.isTraceEnabled();
 
-   // Constructors --------------------------------------------------
+   // Constructors ---------------------------------------------------------------------------------
 
    public SimpleDelivery()
    {
@@ -88,9 +88,8 @@
       this.observer = observer;
       this.selectorAccepted = selectorAccepted;
    }
-   
 
-   // Delivery implementation ---------------------------------
+   // Delivery implementation ----------------------------------------------------------------------
 
    public MessageReference getReference()
    {
@@ -119,7 +118,7 @@
 
    public void acknowledge(Transaction tx) throws Throwable
    {        
-      if (trace) { log.trace(this + " acknowledging delivery in " + tx); }
+      if (trace) { log.trace(this + " acknowledging delivery " + ( tx == null ? "non-transactionally" : "in " + tx)); }
       
       observer.acknowledge(this, tx);
 
@@ -135,7 +134,7 @@
       done = true;
    }
    
-   // Public --------------------------------------------------------
+   // Public ---------------------------------------------------------------------------------------
 
    public String toString()
    {
@@ -143,11 +142,11 @@
          "(" + ( done ? "done" : "active") + ")";
    }
 
-   // Package protected ---------------------------------------------
+   // Package protected ----------------------------------------------------------------------------
    
-   // Protected -----------------------------------------------------
+   // Protected ------------------------------------------------------------------------------------
    
-   // Private -------------------------------------------------------
+   // Private --------------------------------------------------------------------------------------
    
-   // Inner classes -------------------------------------------------
+   // Inner classes --------------------------------------------------------------------------------
 }




More information about the jboss-cvs-commits mailing list