[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/socket ...

Ron Sigal ron_sigal at yahoo.com
Mon Jan 29 00:33:09 EST 2007


  User: rsigal  
  Date: 07/01/29 00:33:09

  Modified:    src/main/org/jboss/remoting/transport/socket  Tag:
                        remoting_2_x ServerThread.java
  Log:
  JBREM-692:  (1) Passes (un)marshaller to ServerSocketWrapper, and (2) creates (un)marshaller once when new socket is created.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.29.2.13 +51 -20    JBossRemoting/src/main/org/jboss/remoting/transport/socket/ServerThread.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ServerThread.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/ServerThread.java,v
  retrieving revision 1.29.2.12
  retrieving revision 1.29.2.13
  diff -u -b -r1.29.2.12 -r1.29.2.13
  --- ServerThread.java	25 Jan 2007 01:07:10 -0000	1.29.2.12
  +++ ServerThread.java	29 Jan 2007 05:33:09 -0000	1.29.2.13
  @@ -26,6 +26,7 @@
   import org.jboss.logging.Logger;
   import org.jboss.remoting.InvocationRequest;
   import org.jboss.remoting.InvocationResponse;
  +import org.jboss.remoting.InvokerLocator;
   import org.jboss.remoting.ServerInvoker;
   import org.jboss.remoting.Version;
   import org.jboss.remoting.Client;
  @@ -44,6 +45,7 @@
   import java.net.SocketAddress;
   import java.net.SocketException;
   import java.net.SocketTimeoutException;
  +import java.util.HashMap;
   import java.util.LinkedList;
   import java.util.Map;
   
  @@ -62,7 +64,7 @@
    * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
    * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
    *
  - * @version $Revision: 1.29.2.12 $
  + * @version $Revision: 1.29.2.13 $
    */
   public class ServerThread extends Thread
   {
  @@ -98,6 +100,9 @@
      protected SocketServerInvoker invoker;
      private Constructor serverSocketConstructor;
   
  +   protected Marshaller marshaller;
  +   protected UnMarshaller unmarshaller;
  +
      // the unique identity of the thread, which won't change during the life of the thread. The
      // thread may get associated with different IP addresses though.
      private int id = Integer.MIN_VALUE;
  @@ -129,6 +134,7 @@
         this.invoker = invoker;
         this.clientpool = clientpool;
         this.threadpool = threadpool;
  +      processNewSocket();
   
         if (invoker != null)
         {
  @@ -230,6 +236,7 @@
   
         running = true;
         handlingResponse = true;
  +      processNewSocket();
         notify();
   
         if(trace) { log.trace(this + " has notified on mutex"); }
  @@ -628,16 +635,6 @@
            case Version.VERSION_1:
            case Version.VERSION_2:
            {
  -            //TODO: -TME Need better way to get the unmarshaller (via config)
  -            UnMarshaller unmarshaller = MarshalFactory.
  -               getUnMarshaller(invoker.getLocator(), classLoader);
  -
  -            if (unmarshaller == null)
  -            {
  -               unmarshaller = MarshalFactory.
  -                  getUnMarshaller(invoker.getDataType(), invoker.getSerializationType());
  -            }
  -
               if(trace) { log.trace("blocking to read invocation from unmarshaller"); }
   
               Object o = unmarshaller.read(inputStream, null);
  @@ -682,8 +679,20 @@
   
         if (serverSocketConstructor.getParameterTypes().length == 3)
         {
  +         Map localMetadata = null;
  +         if (metadata == null)
  +         {
  +            localMetadata = new HashMap(2);
  +         }
  +         else
  +         {
  +            localMetadata = new HashMap(metadata);   
  +         }
  +         localMetadata.put(SocketWrapper.MARSHALLER, marshaller);
  +         localMetadata.put(SocketWrapper.UNMARSHALLER, unmarshaller);
  +         
            serverSocketWrapper = (SocketWrapper)serverSocketConstructor.
  -            newInstance(new Object[]{socket, metadata, new Integer(timeout)});
  +            newInstance(new Object[]{socket, localMetadata, new Integer(timeout)});
         }
         else
         {
  @@ -727,6 +736,36 @@
         }
      }
   
  +   private void processNewSocket()
  +   {
  +      InvokerLocator locator = invoker.getLocator();
  +      ClassLoader classLoader = getClass().getClassLoader();
  +      String dataType = invoker.getDataType();
  +      String serializationType = invoker.getSerializationType();
  +      
  +      //TODO: -TME Need better way to get the unmarshaller (via config)
  +      
  +      if (unmarshaller == null)
  +      {
  +         unmarshaller = MarshalFactory.getUnMarshaller(locator, classLoader);
  +      }
  +      if (unmarshaller == null)
  +      {
  +         unmarshaller = MarshalFactory.getUnMarshaller(dataType, serializationType);
  +      }
  +     
  +      if (marshaller == null)
  +      {
  +         marshaller = MarshalFactory.getMarshaller(locator, classLoader);
  +      }
  +      if (marshaller == null)
  +      {
  +         marshaller = MarshalFactory.getMarshaller(dataType, serializationType);
  +      }
  +      
  +      
  +   }
  +
      private void versionedWrite(OutputStream outputStream, SocketServerInvoker invoker,
                                  ClassLoader classLoader, Object resp, int version) throws IOException
      {
  @@ -736,14 +775,6 @@
            case Version.VERSION_1:
            case Version.VERSION_2:
            {
  -            Marshaller marshaller = MarshalFactory.getMarshaller(invoker.getLocator(), classLoader);
  -
  -            if (marshaller == null)
  -            {
  -               marshaller = MarshalFactory.
  -                  getMarshaller(invoker.getDataType(), invoker.getSerializationType());
  -            }
  -
               marshaller.write(resp, outputStream);
               if (trace) { log.trace("wrote response to the output stream"); }
               return;
  
  
  



More information about the jboss-cvs-commits mailing list