[jboss-remoting-commits] JBoss Remoting SVN: r4984 - remoting2/branches/2.x/src/main/org/jboss/remoting.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Mon Apr 13 06:31:34 EDT 2009


Author: ron.sigal at jboss.com
Date: 2009-04-13 06:31:34 -0400 (Mon, 13 Apr 2009)
New Revision: 4984

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-1113: (1) Made removeCallbackHandler() public; (2) added shutdownCallbackHandler().

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java	2009-04-13 10:29:47 UTC (rev 4983)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java	2009-04-13 10:31:34 UTC (rev 4984)
@@ -867,28 +867,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)
             {
@@ -1664,6 +1643,10 @@
          if (registerCallbackListeners)
          {
             connectionNotifier.addListenerFirst(callbackHandler);
+            if(leasePeriod > 0)
+            {
+               leaseManagement = true;
+            }
          }
          handler.addListener(callbackHandler);
       }
@@ -1672,6 +1655,14 @@
          ServerInvokerCallbackHandler callbackHandler = removeCallbackHandler(invocation);
          if(callbackHandler != null)
          {
+            if (registerCallbackListeners)
+            {
+//               connectionNotifier.removeListener(callbackHandler);
+               removeConnectionListener(callbackHandler);
+            }
+            
+            callbackHandler.destroy();
+            
             if(handler == null)
             {
                throw new InvalidConfigurationException(
@@ -1679,15 +1670,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
          {
@@ -1815,7 +1801,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?
@@ -2049,7 +2062,7 @@
       return callbackHandler;
    }
 
-   private ServerInvokerCallbackHandler removeCallbackHandler(InvocationRequest invocation)
+   public ServerInvokerCallbackHandler removeCallbackHandler(InvocationRequest invocation)
    {
       String id = ServerInvokerCallbackHandler.getId(invocation);
       ServerInvokerCallbackHandler callbackHandler = null;
@@ -2060,6 +2073,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 --------------------------------------------------------------------------------
 




More information about the jboss-remoting-commits mailing list