[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting ...
Ron Sigal
ron_sigal at yahoo.com
Tue Jan 16 03:11:13 EST 2007
User: rsigal
Date: 07/01/16 03:11:13
Modified: src/main/org/jboss/remoting ServerInvoker.java
Log:
JBREM-298: Added ability to wrap ServerSocketFactory with a CreationListenerServerSocketFactory. Also, incorporated logging changes introduced by Ovidiu on remoting_2_x branch
Revision Changes Path
1.59 +61 -55 JBossRemoting/src/main/org/jboss/remoting/ServerInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ServerInvoker.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/ServerInvoker.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- ServerInvoker.java 12 Jan 2007 18:56:22 -0000 1.58
+++ ServerInvoker.java 16 Jan 2007 08:11:13 -0000 1.59
@@ -31,20 +31,26 @@
import org.jboss.remoting.security.SSLSocketBuilder;
import org.jboss.remoting.security.ServerSocketFactoryMBean;
import org.jboss.remoting.security.ServerSocketFactoryWrapper;
-import org.jboss.remoting.serialization.ClassLoaderUtility;
+import org.jboss.remoting.socketfactory.CreationListenerServerSocketFactory;
+import org.jboss.remoting.socketfactory.CreationListenerSocketFactory;
+import org.jboss.remoting.socketfactory.SocketCreationListener;
import org.jboss.remoting.stream.StreamHandler;
import org.jboss.remoting.stream.StreamInvocationHandler;
import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.serialization.ClassLoaderUtility;
import org.jboss.util.threadpool.BasicThreadPool;
import org.jboss.util.threadpool.BlockingMode;
import org.jboss.util.threadpool.ThreadPool;
import org.jboss.util.threadpool.ThreadPoolMBean;
+import org.jboss.logging.Logger;
import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.net.InetAddress;
@@ -59,10 +65,14 @@
*
* @author <a href="mailto:jhaynie at vocalocity.net">Jeff Haynie</a>
* @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
- * @version $Revision: 1.58 $
+ * @version $Revision: 1.59 $
*/
public abstract class ServerInvoker extends AbstractInvoker implements ServerInvokerMBean
{
+ private static final Logger log = Logger.getLogger(ServerInvoker.class);
+
+ private static boolean trace = log.isTraceEnabled();
+
/**
* Key for the the maximum number of thread to be used in the thread pool
* for one way invocations (server side).
@@ -185,8 +195,6 @@
protected ServerSocketFactory serverSocketFactory = null;
- private boolean isTraceEnabled = false;
-
public ServerInvoker(InvokerLocator locator)
{
super(locator);
@@ -195,7 +203,6 @@
{
configuration.putAll(locator.getParameters());
}
- isTraceEnabled = log.isTraceEnabled();
}
public ServerInvoker(InvokerLocator locator, Map configuration)
@@ -210,7 +217,6 @@
{
this.configuration.putAll(locator.getParameters());
}
- isTraceEnabled = log.isTraceEnabled();
}
protected void setup() throws Exception
@@ -469,6 +475,7 @@
log.debug("Created server socket factory: " + serverSocketFactory);
+ serverSocketFactory = wrapServerSocketFactory(serverSocketFactory, configuration);
return serverSocketFactory;
}
@@ -508,6 +515,20 @@
return ServerSocketFactory.getDefault();
}
+
+ protected ServerSocketFactory wrapServerSocketFactory(ServerSocketFactory ssf, Map config)
+ {
+ if (config == null)
+ return ssf;
+
+ Object o = config.get(Remoting.SOCKET_CREATION_LISTENER);
+ if (o != null && o instanceof SocketCreationListener)
+ return new CreationListenerServerSocketFactory(ssf, (SocketCreationListener) o);
+
+ return ssf;
+ }
+
+
/**
* Sets timeout (in millseconds) to be used for the socket connection.
* @param timeout
@@ -841,10 +862,7 @@
InvocationRequest request = null;
InvocationResponse response = null;
- if(isTraceEnabled)
- {
- log.trace("server received invocation =>" + invoke);
- }
+ if(trace) { log.trace("server received invocation " + invoke); }
if(invoke != null && invoke instanceof InvocationRequest)
{
@@ -860,10 +878,6 @@
}
catch(Throwable throwable)
{
- if(isTraceEnabled)
- {
- //throwable.printStackTrace();
- }
response = new InvocationResponse(request.getSessionId(),
throwable, true, request.getReturnPayload());
}
@@ -992,10 +1006,7 @@
}
else
{
- if (isTraceEnabled)
- {
- log.trace("dispatching invocation: " + invocation + " to subsystem: " + subsystem + " from client: " + clientId);
- }
+ if (trace) { log.trace(this + " dispatching invocation " + invocation + " from client " + clientId + " to subsystem " + subsystem); }
if (handler == null)
{
@@ -1005,13 +1016,9 @@
}
result = handler.invoke(invocation);
}
- if (isTraceEnabled)
- {
- log.trace("dispatch invocation, returning back: " + result + " from subsystem: " + subsystem +
- " to client: " + clientId);
- }
- }
+ if (trace) { log.trace(this + " successfully dispatched invocation, returning " + result + " from subsystem " + subsystem + " to client " + clientId); }
+ }
return result;
}
@@ -1068,7 +1075,7 @@
String clientSessionId = invocation.getSessionId();
if(clientSessionId != null)
{
- if(isTraceEnabled)
+ if(trace)
{
log.trace("Getting lease for client session id: " + clientSessionId);
}
@@ -1083,7 +1090,7 @@
clientLeases.put(clientSessionId, newClientLease);
newClientLease.startLease();
- if(isTraceEnabled)
+ if(trace)
{
log.trace("No lease established for client session id (" + clientSessionId + "), so starting a new one.");
}
@@ -1093,7 +1100,7 @@
// including request payload from invocation as may contain updated list of clients.
clientLease.updateLease(leasePeriod, invocation.getRequestPayload());
- if(isTraceEnabled)
+ if(trace)
{
log.trace("Updated lease for client session id (" + clientSessionId + ")");
}
@@ -1154,7 +1161,7 @@
{
Object result = null;
String methodName = param.getMethodName();
- if(isTraceEnabled)
+ if(trace)
{
log.trace("handling InternalInvocation where method name = " + methodName);
}
@@ -1183,7 +1190,7 @@
"or via the Connector's addInvocationHandler() method.");
}
handler.removeListener(callbackHandler);
- if(isTraceEnabled)
+ if(trace)
{
log.trace("ServerInvoker (" + this + ") removing server callback handler " + callbackHandler + ".");
}
@@ -1199,7 +1206,7 @@
else if(InternalInvocation.GETCALLBACKS.equals(methodName))
{
ServerInvokerCallbackHandler callbackHandler = getCallbackHandler(invocation);
- if(isTraceEnabled)
+ if(trace)
{
log.trace("ServerInvoker (" + this + ") getting callbacks for callback handler " + callbackHandler + ".");
}
@@ -1209,7 +1216,7 @@
else if(InternalInvocation.ACKNOWLEDGECALLBACK.equals(methodName))
{
ServerInvokerCallbackHandler callbackHandler = getCallbackHandler(invocation);
- if(isTraceEnabled)
+ if(trace)
{
log.trace("ServerInvoker (" + this + ") acknowledge callback on callback handler " + callbackHandler + ".");
}
@@ -1252,7 +1259,7 @@
else if(InternalInvocation.HANDLECALLBACK.equals(methodName))
{
String sessionId = ServerInvokerCallbackHandler.getId(invocation);
- if(isTraceEnabled)
+ if(trace)
{
log.trace("ServerInvoker (" + this + ") is being asked to deliver callback on client callback handler with session id of " + sessionId + ".");
}
@@ -1318,7 +1325,6 @@
{
ServerInvokerCallbackHandler callbackHandler = null;
String id = ServerInvokerCallbackHandler.getId(invocation);
-
synchronized(callbackHandlers)
{
callbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.get(id);
@@ -1329,7 +1335,7 @@
callbackHandlers.put(id, callbackHandler);
}
}
- if(isTraceEnabled)
+ if(trace)
{
log.trace("ServerInvoker (" + this + ") adding server callback handler " + callbackHandler + " with id of " + id + ".");
}
@@ -1398,13 +1404,11 @@
public void start() throws IOException
{
started = true;
- log.debug("Invoker started for locator: " + getLocator());
+ log.debug(this + " started for locator: " + getLocator());
}
/**
* return true if the server invoker is started, false if not
- *
- * @return
*/
public boolean isStarted()
{
@@ -1424,6 +1428,8 @@
ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler) it.next();
callbackHandler.destroy();
}
+
+ log.debug(this + " stopped");
}
/**
More information about the jboss-cvs-commits
mailing list