com.infoscape.proteus.router
Class Router
java.lang.Object
|
+--com.infoscape.proteus.router.Router
- All Implemented Interfaces:
- MessageHandler, MessageSink, java.lang.Runnable, Transactional
- Direct Known Subclasses:
- StraightRouter, SwitchedRouter
- public abstract class Router
- extends java.lang.Object
- implements java.lang.Runnable, MessageSink
A Router is a thread that gets messages from a source and routes them. Routing them generally involves putting them to one or more sinks. The run() method gets messages from the source and calls route(), which is abstract, and continues to do so until the thread is stopped externally. A Router can also be used as a sink by another router, in which case it runs in the same thread with its parent.
|
Constructor Summary |
Router(org.jdom.Element elt)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Router
public Router(org.jdom.Element elt)
throws java.lang.Exception
- Parameters:
elt -
- Throws:
java.lang.Exception
route
public abstract void route(java.lang.Object msg)
throws java.lang.Exception
- Parameters:
msg -
- Throws:
java.lang.Exception
run
public void run()
- Specified by:
run in interface java.lang.Runnable
putMessage
public void putMessage(java.lang.Object msg)
throws java.lang.Exception
- Description copied from interface:
MessageSink
- This method takes an Object as parameter. In real life this is usually a string, but we have found that the flexibility gained by declaring this as an Object can be very useful.
- Specified by:
putMessage in interface MessageSink
- Parameters:
msg -
- Throws:
java.lang.Exception
setSyncPoint
public void setSyncPoint(boolean on)
throws java.lang.Exception
- Specified by:
setSyncPoint in interface Transactional
- Parameters:
on -
- Throws:
java.lang.Exception
commit
public void commit()
throws java.lang.Exception
- Specified by:
commit in interface Transactional
- Throws:
java.lang.Exception
rollback
public void rollback()
throws java.lang.Exception
- Specified by:
rollback in interface Transactional
- Throws:
java.lang.Exception
addSink
protected void addSink(MessageSink sink)
routeMessage
protected void routeMessage(java.lang.Object msg,
MessageSink sink)
throws java.lang.Exception
java.lang.Exception
log
protected void log(java.lang.String msg)
- Parameters:
msg -
log
protected void log(java.lang.Exception e)
- Parameters:
e -
disconnect
public void disconnect()
throws java.lang.Exception
- Specified by:
disconnect in interface MessageHandler
- Throws:
java.lang.Exception
reconnect
public void reconnect()
throws java.lang.Exception
- Specified by:
reconnect in interface MessageHandler
- Throws:
java.lang.Exception
getConnection
public Connection getConnection()
- Specified by:
getConnection in interface MessageHandler