com.realtime.xmpp.util
Class XmppSessionRestarter

java.lang.Object
  |
  +--com.realtime.xmpp.util.XmppSessionRestarter
All Implemented Interfaces:
XmppSessionListener

public class XmppSessionRestarter
extends java.lang.Object
implements XmppSessionListener

An XMPP event listener that responds to socket close events by re-establishing the XMPP session.

Each new session attempt is done by a separate thread so we don't recurse into oblivion. After the restart is successful, the thread is destroyed.

To disable the automatic restarts, call stop().

Version:
1.0
Author:
Mike Prince

Nested Class Summary
protected  class XmppSessionRestarter.StarterThread
          Our session starter thread.
 
Nested classes inherited from class com.realtime.xmpp.XmppSessionListener
XmppSessionListener.Event, XmppSessionListener.Type
 
Field Summary
protected  XmppSessionRestarter.StarterThread m_activeStarterThread
          Our active starter thread.
protected  boolean m_bStopped
          Signal to our thread that we've been stopped.
protected  XmppSession m_session
          The session we will restart when failures occur.
protected  java.lang.Object m_threadMutex
          Protected mucking with out thread.
 
Fields inherited from interface com.realtime.xmpp.XmppSessionListener
AUTHENTICATION_FAILED, CANT_CONNECT, CLOSING_SOCKET, CONNECTION_ERROR, INCOMING_PACKET, OPENING_SOCKET, PARSER_SELECTED, PROTOCOL_ERROR, RESTARTING_CONNECTION, SENDING_PACKET, SESSION_AUTHENTICATED, SESSION_ENDED, SESSION_STARTED, SOCKET_CLOSED, SOCKET_OPEN, STARTING_SESSION, STOPPING_COMPONENT, WAITING
 
Constructor Summary
XmppSessionRestarter(XmppSession session)
          Create the session restarter.
 
Method Summary
 void start()
          (Re)start the task of listening for failed connections and restarting the session.
protected  void startSession()
          Create a worker thread and send it off to make sure the new session starts.
 void stop()
          Stop restarting any failed sessions.
 void xmppSessionEvent(XmppSessionListener.Event event)
          Respond to SOCKET_CLOSED events by restarting the XMPP session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_session

protected XmppSession m_session
The session we will restart when failures occur.


m_bStopped

protected boolean m_bStopped
Signal to our thread that we've been stopped.


m_activeStarterThread

protected XmppSessionRestarter.StarterThread m_activeStarterThread
Our active starter thread.


m_threadMutex

protected java.lang.Object m_threadMutex
Protected mucking with out thread.

Constructor Detail

XmppSessionRestarter

public XmppSessionRestarter(XmppSession session)

Create the session restarter. Each time the XMPP session is closed, this class will start a new one.

To stop this class, call the stop() method.

Method Detail

xmppSessionEvent

public void xmppSessionEvent(XmppSessionListener.Event event)

Respond to SOCKET_CLOSED events by restarting the XMPP session.

Specified by:
xmppSessionEvent in interface XmppSessionListener
Parameters:
event - The XMPP session event, as defined in this class.

startSession

protected void startSession()
Create a worker thread and send it off to make sure the new session starts.


start

public void start()

(Re)start the task of listening for failed connections and restarting the session.

This method should be called after stop(). It is not necessary to call this method after constructing this class.


stop

public void stop()

Stop restarting any failed sessions.



Copyright © 2002,2003 Real Time Entertainment Group, LLC. All Rights Reserved.