Author: ron.sigal(a)jboss.com
Date: 2009-04-18 02:34:54 -0400 (Sat, 18 Apr 2009)
New Revision: 5062
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-1119: (1) Made removeCallbackHandler() public; (2) added shutdownCallbackHandler().
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2009-04-18
06:34:10 UTC (rev 5061)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2009-04-18
06:34:54 UTC (rev 5062)
@@ -825,28 +825,7 @@
//then it will just use that without having to do a lookup or HashMap
iteration over
//values
- ServerInvocationHandler handler = null;
-
- if (singleHandler != null)
- {
- handler = singleHandler;
- }
- else
- {
- if (subsystem != null)
- {
- handler =
(ServerInvocationHandler)handlers.get(subsystem.toUpperCase());
- }
- else
- {
- // subsystem not specified, so will hope for a default one being set
- if (!handlers.isEmpty())
- {
- if (trace) { log.trace(this + " handling invocation with no
subsystem explicitely specified, using the default handler"); }
- handler =
(ServerInvocationHandler)handlers.values().iterator().next();
- }
- }
- }
+ ServerInvocationHandler handler = findInvocationHandler(subsystem);
if (param instanceof InternalInvocation)
{
@@ -1506,6 +1485,14 @@
ServerInvokerCallbackHandler callbackHandler =
removeCallbackHandler(invocation);
if(callbackHandler != null)
{
+ if (registerCallbackListeners)
+ {
+// connectionNotifier.removeListener(callbackHandler);
+ removeConnectionListener(callbackHandler);
+ }
+
+ callbackHandler.destroy();
+
if(handler == null)
{
throw new InvalidConfigurationException(
@@ -1513,15 +1500,10 @@
"registered. Please add via xml configuration or via the
Connector's " +
"addInvocationHandler() method.");
}
- if (registerCallbackListeners)
- {
- connectionNotifier.removeListener(callbackHandler);
- }
+
handler.removeListener(callbackHandler);
if(trace) { log.trace("ServerInvoker (" + this + ") removing
server callback handler " + callbackHandler + "."); }
-
- callbackHandler.destroy();
}
else
{
@@ -1550,7 +1532,7 @@
// the only elements should be the callback handler and possibly the callback
handle object
if(params == null || params.length < 0 || params.length > 3)
{
- log.error("Recieved addClientListener InternalInvocation, but
getParameters() " +
+ log.debug("Received addClientListener InternalInvocation, but
getParameters() " +
"returned: " + params);
throw new RuntimeException(
"InvokerCallbackHandler and callback handle object (optional) must be
supplied as " +
@@ -1636,7 +1618,34 @@
}
return result;
}
+
+ protected ServerInvocationHandler findInvocationHandler(String subsystem)
+ {
+ ServerInvocationHandler handler = null;
+ if (singleHandler != null)
+ {
+ handler = singleHandler;
+ }
+ else
+ {
+ if (subsystem != null)
+ {
+ handler = (ServerInvocationHandler)handlers.get(subsystem.toUpperCase());
+ }
+ else
+ {
+ // subsystem not specified, so will hope for a default one being set
+ if (!handlers.isEmpty())
+ {
+ if (trace) { log.trace(this + " handling invocation with no subsystem
explicitely specified, using the default handler"); }
+ handler = (ServerInvocationHandler)handlers.values().iterator().next();
+ }
+ }
+ }
+ return handler;
+ }
+
/**
* Called prior to an invocation.
* TODO is sending in the arg appropriate?
@@ -1865,7 +1874,7 @@
return callbackHandler;
}
- private ServerInvokerCallbackHandler removeCallbackHandler(InvocationRequest
invocation)
+ public ServerInvokerCallbackHandler removeCallbackHandler(InvocationRequest
invocation)
{
String id = ServerInvokerCallbackHandler.getId(invocation);
ServerInvokerCallbackHandler callbackHandler = null;
@@ -1876,6 +1885,25 @@
}
return callbackHandler;
}
+
+ public void shutdownCallbackHandler(ServerInvokerCallbackHandler callbackHandler,
InvocationRequest invocation)
+ {
+ removeCallbackHandler(invocation);
+ if (registerCallbackListeners)
+ {
+ removeConnectionListener(callbackHandler);
+ }
+ ServerInvocationHandler handler =
findInvocationHandler(invocation.getSessionId());
+ if (handler != null)
+ {
+ handler.removeListener(callbackHandler);
+ if(trace) { log.trace(this + " removing server callback handler " +
callbackHandler + "."); }
+ }
+ else
+ {
+ log.debug(this + " cannot remove " + callbackHandler + ":
associated ServerInvocationHandler not longer exists");
+ }
+ }
// Inner classes
--------------------------------------------------------------------------------
Show replies by date