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

Ron Sigal ron_sigal at yahoo.com
Sat Feb 3 00:21:33 EST 2007


  User: rsigal  
  Date: 07/02/03 00:21:33

  Modified:    src/main/org/jboss/remoting/transport/socket 
                        SocketWrapper.java
  Log:
  JBREM-690, JBREM-692, ovidiu's logging and reorganization: sync with remoting_2_x.
  
  Revision  Changes    Path
  1.9       +68 -8     JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketWrapper.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SocketWrapper.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketWrapper.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- SocketWrapper.java	30 Dec 2005 05:26:38 -0000	1.8
  +++ SocketWrapper.java	3 Feb 2007 05:21:32 -0000	1.9
  @@ -22,6 +22,8 @@
   
   package org.jboss.remoting.transport.socket;
   
  +import org.jboss.logging.Logger;
  +
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
  @@ -33,17 +35,38 @@
    */
   public abstract class SocketWrapper
   {
  +   // Constants ------------------------------------------------------------------------------------
  +
  +   private static final Logger log = Logger.getLogger(SocketWrapper.class);
  +
  +   public static final String MARSHALLER = "marshaller";
  +   public static final String UNMARSHALLER = "unmarshaller";
  +   public static final String TEMP_TIMEOUT = "temptimeout";
  +   
  +   protected static final int CLOSING = 3;
  +   
  +   // Static ---------------------------------------------------------------------------------------
  +
  +   private static boolean trace = log.isTraceEnabled();
  +
  +   // Attributes -----------------------------------------------------------------------------------
  +
      private Socket socket;
      private int timeout;
   
  +   // Constructors ---------------------------------------------------------------------------------
  +
      protected SocketWrapper(Socket socket)
      {
  +      if (trace) { log.trace("creating " + getClass().getName() + " instance for " + socket); }
         this.socket = socket;
      }
   
      protected SocketWrapper(Socket socket, Integer timeoutInt) throws SocketException
      {
  +      if (trace) { log.trace("creating " + getClass().getName() + " instance for " + socket + ", using timeout " + timeoutInt); }
         this.socket = socket;
  +
         if(timeoutInt != null)
         {
            this.timeout = timeoutInt.intValue();
  @@ -51,14 +74,11 @@
         }
      }
   
  -   public abstract OutputStream getOutputStream() throws IOException;
  -
  -   public abstract InputStream getInputStream() throws IOException;
  -
  -   public abstract void checkConnection() throws IOException;
  +   // Public ---------------------------------------------------------------------------------------
   
      public void setTimeout(int timeout) throws SocketException
      {
  +      if (trace) { log.trace(this + " setting timeout to " + timeout); }
         this.timeout = timeout;
         if(socket != null)
         {
  @@ -71,15 +91,50 @@
         return timeout;
      }
   
  -
      public void close() throws IOException
      {
  +      InputStream in = getInputStream();
  +      if (in != null)
  +      {
  +         try
  +         {
  +            in.close();
  +         }
  +         catch (IOException e)
  +         {
  +            log.debug("unable to close input stream");
  +         }
  +      }
  +      OutputStream out = getOutputStream();
  +      if (out != null)
  +      {
  +         try
  +         {
  +            out.close();
  +         }
  +         catch (IOException e)
  +         {
  +            log.debug("unable to close output stream");
  +         }
  +      }
  +
         if(socket != null)
         {
  +         log.debug(this + " closing");
            socket.close();
         }
      }
   
  +   public abstract OutputStream getOutputStream() throws IOException;
  +
  +   public abstract InputStream getInputStream() throws IOException;
  +
  +   public abstract void checkConnection() throws IOException;
  +
  +   // Package protected ----------------------------------------------------------------------------
  +
  +   // Protected ------------------------------------------------------------------------------------
  +
      protected Socket getSocket()
      {
         return socket;
  @@ -93,10 +148,15 @@
            {
               socket.close();
            }
  -         catch(Exception ignored)
  +         catch(Exception e)
            {
  +            log.debug(this + " failed to close socket", e);
            }
         }
      }
   
  +   // Private --------------------------------------------------------------------------------------
  +
  +   // Inner classes --------------------------------------------------------------------------------
  +
   }
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list