[jboss-cvs] JBoss Messaging SVN: r1578 - branches/Branch_1_0_1_SP/src/main/org/jboss/jms/server/remoting
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 16 23:25:14 EST 2006
Author: ron_sigal
Date: 2006-11-16 23:25:14 -0500 (Thu, 16 Nov 2006)
New Revision: 1578
Added:
branches/Branch_1_0_1_SP/src/main/org/jboss/jms/server/remoting/ServerSocketWrapper.java
Log:
Netflix patch: Socket wrapper for server side socket transport invoker.
Added: branches/Branch_1_0_1_SP/src/main/org/jboss/jms/server/remoting/ServerSocketWrapper.java
===================================================================
--- branches/Branch_1_0_1_SP/src/main/org/jboss/jms/server/remoting/ServerSocketWrapper.java 2006-11-17 04:24:51 UTC (rev 1577)
+++ branches/Branch_1_0_1_SP/src/main/org/jboss/jms/server/remoting/ServerSocketWrapper.java 2006-11-17 04:25:14 UTC (rev 1578)
@@ -0,0 +1,107 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.jms.server.remoting;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.Socket;
+import java.util.Map;
+
+import org.jboss.jms.client.remoting.ClientSocketWrapper;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.serialization.SerializationStreamFactory;
+
+/**
+ * @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
+ */
+public class ServerSocketWrapper extends ClientSocketWrapper
+{
+ final static private Logger log = Logger.getLogger(ServerSocketWrapper.class);
+
+ public ServerSocketWrapper(Socket socket) throws Exception
+ {
+ super(socket);
+ }
+
+ public ServerSocketWrapper(Socket socket, Map metadata, Integer timeout) throws Exception
+ {
+ super(socket, metadata, timeout);
+ }
+
+ protected ObjectInputStream createInputStream(String serializationType, Socket socket) throws IOException
+ {
+ BufferedInputStream bin = new BufferedInputStream(socket.getInputStream());
+ ObjectInputStream oin = SerializationStreamFactory.getManagerInstance(serializationType).createInput(bin, null);
+ return oin;
+ }
+
+ protected ObjectOutputStream createOutputStream(String serializationType, Socket socket)
+ throws IOException
+ {
+ BufferedOutputStream bout = new BufferedOutputStream(socket.getOutputStream());
+ ObjectOutputStream oout = SerializationStreamFactory.getManagerInstance(serializationType).createOutput(bout);
+ oout.flush();
+ return oout;
+ }
+
+ public void checkConnection() throws IOException
+ {
+ // Perform acknowledgement to convince client
+ // that the socket is still active
+ byte ACK = 0;
+ //long startWait = System.currentTimeMillis();
+ try
+ {
+ ACK = ((ObjectInputStream) getInputStream()).readByte();
+ }
+ catch(EOFException eof)
+ {
+ if(log.isTraceEnabled())
+ {
+ log.trace("socket timeout is set to : " + getTimeout());
+ log.trace("EOFException waiting on ACK in readByte().");
+ //log.trace("Time waited was " + (System.currentTimeMillis() - startWait));
+ }
+ throw eof;
+ }
+ catch(IOException e)
+ {
+ log.trace("IOException when reading in ACK", e);
+ throw e;
+ }
+
+ if(log.isTraceEnabled())
+ {
+ log.trace("***acknowledge read byte" + Thread.currentThread());
+ }
+
+ ObjectOutputStream out = (ObjectOutputStream) getOutputStream();
+ out.writeByte(ACK);
+ out.flush();
+ out.reset();
+ }
+}
More information about the jboss-cvs-commits
mailing list