public class MessageRouter extends Object implements Runnable
MessageRouter class facilitates intra-process message routing. It provides
 application classes with convenient access to the message channels via the
 PrintWriter class. The MessageRouter class, by default, defines 2
 standard message channels - for standard output and standard error messages. Applications can
 publish their standard output and standard error messages using the outWriter() and
 errWriter() methods correspondingly. MessageRouter class distributes the messages to a number of message channel
 listeners, added by applications. Standard message channel listeners should implement the
 MessageRouter.StdChannelListener interface. The MessageRouter class
 collects all published messages. When a new message channel listener is added, it receives all
 collected messages from the message history.
 
 The MessageRouter code runs in a separate thread that should be started and
 terminated by applications. Applications should use the start() and
 terminate() methods to start and terminate the MessageRouter thread
 correspondingly. 
 For terminology see the  Enterprise
 Integration Patterns book.
 
| Modifier and Type | Class and Description | 
|---|---|
| static interface  | MessageRouter.StdChannelListenerThe  StdChannelListenerinterface declares methods that should be implemented by
 each standard message channel listener. | 
| Constructor and Description | 
|---|
| MessageRouter()Default constructor for the  MessageRouterclass. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addChannelListener(MessageRouter.StdChannelListener listener)Adds a given object, implementing the  StdChannelListenerinterface, to the list of
 standard message channel listeners. | 
| int | countStdChannelListeners() | 
| PrintWriter | errWriter() | 
| boolean | isRunning() | 
| PrintWriter | outWriter() | 
| void | removeChannelListener(MessageRouter.StdChannelListener listener)Removes a given  StdChannelListenerobject from the list of standard channel
 listeners. | 
| void | run()Implements the main service method that runs in a separate thread. | 
| void | start()Starts the main service thread. | 
| void | terminate()Terminates the main service thread. | 
public MessageRouter()
MessageRouter class. This constructor allocates all
 resources, but does not start the main service thread. Applications should start the
 MessageRouter thread using the start() method.public void addChannelListener(MessageRouter.StdChannelListener listener)
StdChannelListener interface, to the list of
 standard message channel listeners. Sends to the new listener all previously collected messages
 for this channel.listener - The given new standard message channel listener.public int countStdChannelListeners()
public boolean isRunning()
true, if the router thread is running, false otherwise.public void removeChannelListener(MessageRouter.StdChannelListener listener)
StdChannelListener object from the list of standard channel
 listeners.listener - The StdChannelListener object to be removed from the list.public void run()
public PrintWriter errWriter()
public PrintWriter outWriter()
public void start()
public void terminate()
Copyright © 2006–2022 The Apache Software Foundation. All rights reserved.