Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.presumo.jms.router
Class Router  view Router download Router.java

java.lang.Object
  extended bycom.presumo.jms.router.RouterAdapter
      extended bycom.presumo.jms.router.Router
All Implemented Interfaces:
java.lang.Runnable

public final class Router
extends RouterAdapter

The main routing functionality. The Router maintains a list of RoutingTarget's, and for every message it is asked to route, it simply hands it to each routing target asking. The RoutingTarget itself determines if it needs the message and keeps it if so.

The Router is also responsible for maintaining the filters.


Field Summary
private  java.util.ArrayList eListeners
          Data structure of all exception listeners
private static com.presumo.util.log.Logger logger
           
private  long msgsRouted
          Number of messages routed by this instance
private  java.lang.String name
          Name of the router
private  int numOfTargets
          Number of routing targets
private  com.presumo.jms.selector.Parser parser
          Local instance of the parser singleton for convienance.
private  java.lang.Object targetChangeLock
          Synchronization lock
private  RoutingTarget[] targets
          All possible routing targets to route messages to
 
Fields inherited from class com.presumo.jms.router.RouterAdapter
 
Constructor Summary
Router(com.presumo.jms.plugin.MessageQueue queue)
           
 
Method Summary
 void addExceptionListener(javax.jms.ExceptionListener listener)
           
 void addTarget(RoutingTarget target)
          Add the given target to this instances' list of RoutingTarget's to route to.
 java.lang.String getName()
           
 void recalculateFilters(boolean filterAdded)
           
 void removeExceptionListener(javax.jms.ExceptionListener listener)
           
 void removeTarget(RoutingTarget target)
           
private  void reportException(java.lang.Exception e)
          Convienancs function to report an exception to all registered ExceptionListeners.
 void routeMessage(com.presumo.jms.message.JmsMessage msg)
           
protected  void routeMessages(int batchsize)
          Subclasses of this adapter implement this method to add the final piece of functionality.
 void routeMessages(com.presumo.jms.message.JmsMessage[] msgs)
           
 void setName(java.lang.String value)
           
 
Methods inherited from class com.presumo.jms.router.RouterAdapter
closeRouter, getNext, queueMessage, queueMessages, queueSize, run, setBatchSize, setMessageQueue, startRouter, stopRouter, timerTick
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

private final com.presumo.jms.selector.Parser parser
Local instance of the parser singleton for convienance.


targets

private RoutingTarget[] targets
All possible routing targets to route messages to


numOfTargets

private int numOfTargets
Number of routing targets


targetChangeLock

private final java.lang.Object targetChangeLock
Synchronization lock


eListeners

private final java.util.ArrayList eListeners
Data structure of all exception listeners


msgsRouted

private long msgsRouted
Number of messages routed by this instance


name

private java.lang.String name
Name of the router


logger

private static com.presumo.util.log.Logger logger
Constructor Detail

Router

public Router(com.presumo.jms.plugin.MessageQueue queue)
Method Detail

getName

public final java.lang.String getName()

setName

public final void setName(java.lang.String value)

addTarget

public final void addTarget(RoutingTarget target)
Add the given target to this instances' list of RoutingTarget's to route to.


removeTarget

public final void removeTarget(RoutingTarget target)

recalculateFilters

public final void recalculateFilters(boolean filterAdded)

routeMessage

public final void routeMessage(com.presumo.jms.message.JmsMessage msg)
                        throws java.io.IOException

routeMessages

public final void routeMessages(com.presumo.jms.message.JmsMessage[] msgs)
                         throws java.io.IOException

addExceptionListener

public final void addExceptionListener(javax.jms.ExceptionListener listener)

removeExceptionListener

public final void removeExceptionListener(javax.jms.ExceptionListener listener)

routeMessages

protected final void routeMessages(int batchsize)
Description copied from class: RouterAdapter
Subclasses of this adapter implement this method to add the final piece of functionality. The thread embedded in this class will call this method when there are messages on the inbox that need to be routed.

Specified by:
routeMessages in class RouterAdapter

reportException

private void reportException(java.lang.Exception e)
Convienancs function to report an exception to all registered ExceptionListeners.