Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jboss.remoting;
 
 import java.util.List;
 import java.util.Map;
 import  org.jboss.logging.Logger;

This class is used on the server side to notify any connection listeners when a client connection has been terminated (either by loss of lease or by normal disconnect).

Author(s):
Tom Elrod
public class ConnectionNotifier
   private List listeners = Collections.synchronizedList(new ArrayList());
   private static final Logger log = Logger.getLogger(ConnectionNotifier.class);
   public void addListener(ConnectionListener listener)
   {
      .add(listener);
   }
   
   public void addListenerFirst(ConnectionListener listener)
   {
      .add(0, listener);
   }
   public void removeListener(ConnectionListener listener)
   {
      .remove(listener);
   }
   public int size()
   {
      return .size();
   }
   public void connectionLost(String locatorurlString clientSessionIdMap requestPayload)
   {
      try
      {
         .debug("Server connection lost to client (session id = " + clientSessionId);
         Client client = new Client(new InvokerLocator(locatorurl), requestPayload);
         client.setSessionId(clientSessionId);
         
         synchronized ()
         {
            Iterator it = .iterator();
            while (it.hasNext())
            {
               ((ConnectionListenerit.next()).handleConnectionException(nullclient);
            }
         }
      }
      catch(Exception e)
      {
         .error("Error notifying connection listeners of lost client connection."e);
      }
   }
   public void connectionTerminated(String locatorURLString clientSessionIdMap requestPayload)
   {
      try
      {
         if(.isTraceEnabled())
         {
            .trace("Client disconnected (session id = " + clientSessionId);
         }
         Client client = new Client(new InvokerLocator(locatorURL), requestPayload);
         client.setSessionId(clientSessionId);
         
         synchronized ()
         {
            Iterator it = .iterator();
            while (it.hasNext())
            {
               ((ConnectionListenerit.next()).handleConnectionException(exclient);
            }
         }
      }
      catch(Exception e)
      {
         .error("Error notifying connection listeners of disconnected client connection."e);
      }
   }
New to GrepCode? Check out our FAQ X