com.radekzitek.userver
Class ListenerThread

java.lang.Object
  extended bycom.radekzitek.userver.ListenerThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
BasicListener

public abstract class ListenerThread
extends java.lang.Object
implements java.lang.Runnable

The base class for the listener implementing classes.

Author:
rzitek

Field Summary
protected  HandlerPool hp
          Handler pool.
private static org.apache.log4j.Logger LOG
          Log4j logger.
 
Constructor Summary
ListenerThread()
          Default constructor.
 
Method Summary
 void configure(java.util.Properties lc)
          Method to configure listener based on the configuration managed by the Configuration class.
protected abstract  void listen()
          Protorype for the actual listener work method.
protected abstract  void localConfigure(java.util.Properties lc)
          Prototype for the implemetation specific configuration method.
 void registerHandlerPool(HandlerPool hp)
          Method to register the HandlerPool which manages the handlers for this listener.
 void run()
          The execution method of the thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.log4j.Logger LOG
Log4j logger.


hp

protected HandlerPool hp
Handler pool. This one is registered when the listener is instantiated by the UServer.

Constructor Detail

ListenerThread

public ListenerThread()
Default constructor. Not doing anything at the moment. The configuration and registering of the HandlerPoll must be done through seperate methods.

Method Detail

run

public void run()
The execution method of the thread. It only calls the listen method of the listener implementing class and catches all the exceptions coming out of this method.

Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

listen

protected abstract void listen()
                        throws ListenerThreadException
Protorype for the actual listener work method.

Throws:
ListenerThreadException - Any exceptions caught within the listener implementation must be dealt with or propagated out as a ListenerThreadException.

configure

public void configure(java.util.Properties lc)
               throws ListenerConfigurationException
Method to configure listener based on the configuration managed by the Configuration class. This method is used to do some global / standard configuration and eventually to call the configuration method of the listener implementation class (localConfigure). The configuration properites are passed to the implementation.

Parameters:
lc - properies relevant to this listener
Throws:
ListenerConfigurationException - Thrown by the implementation class in case of configuration problems.

localConfigure

protected abstract void localConfigure(java.util.Properties lc)
                                throws ListenerConfigurationException
Prototype for the implemetation specific configuration method. Called by the configure method. Any exception withing the localConfigure must be dealt with or propagated as a ListenerConfigurationException.

Parameters:
lc - properties relevant to the listener
Throws:
ListenerConfigurationException - Thrown by the implementation class in case of configuration problems.

registerHandlerPool

public void registerHandlerPool(HandlerPool hp)
Method to register the HandlerPool which manages the handlers for this listener.

Parameters:
hp - the HandlerPool