org.cid.distribution
Class DistributionNode

java.lang.Object
  extended by org.cid.distribution.DistributionNode
All Implemented Interfaces:
DistributionContextAware, MessageHandler

public class DistributionNode
extends java.lang.Object
implements DistributionContextAware, MessageHandler

This class represents each one of the nodes defined in a distribution process. A node may hold a reference to a message handler and to a list of forwards.

Each node holds the forwarding information that conforms the process flow logic. The @see org.cid.distribution.core.MessageFlowController class uses this data to route the messages between the different nodes.

A node wraps the calls to the lifecycle methods of a MessageHandler, performing some control operations and getting metrics.

Version:
$Revision: 133 $

Constructor Summary
DistributionNode()
          Default constructor
 
Method Summary
 void addForward(Forward forward)
          Adds a forward
static void addRules(org.apache.commons.digester.Digester d, java.lang.String patternPrefix)
          Configures additional rules for the commons-digester library.
 void destroy()
          Cleans up this node
 java.util.List<Forward> getForwards()
          Returns the forwards list.
 MessageHandler getHandler()
           
 java.lang.String getId()
          The handler Id.
 long getInitMilliseconds()
           
 int getMessagesProcessed()
          Returns the total count of messages processed by this node.
 long getProcessMilliseconds()
          Returns the count of milliseconds spent by this node in its processing.
 void init()
          Initializes this node
 MessageEnumeration process(DistributionMessage message)
          Performs the node operation with a message.
 void setDistributionContext(DistributionContext context)
          A callback method that DistributionContextAware objects must implement.
 void setHandler(MessageHandler handler)
           
 void setId(java.lang.String id)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistributionNode

public DistributionNode()
Default constructor

Method Detail

getHandler

public MessageHandler getHandler()
Returns:
Returns the handler.

setHandler

public void setHandler(MessageHandler handler)
Parameters:
handler - The handler to set.

addForward

public void addForward(Forward forward)
Adds a forward


getForwards

public java.util.List<Forward> getForwards()
Returns the forwards list.


addRules

public static void addRules(org.apache.commons.digester.Digester d,
                            java.lang.String patternPrefix)
Configures additional rules for the commons-digester library.


setDistributionContext

public void setDistributionContext(DistributionContext context)
Description copied from interface: DistributionContextAware
A callback method that DistributionContextAware objects must implement.

Specified by:
setDistributionContext in interface DistributionContextAware

process

public MessageEnumeration process(DistributionMessage message)
                           throws DistributionProcessingException,
                                  DistributionConfigurationException

Performs the node operation with a message.

This method calls the homologue process method on the handler contained in this node.

Specified by:
process in interface MessageHandler
Returns:
The result of the handle processing, usually indicating whether the processing of this message has succeeded or failed.
Throws:
DistributionProcessingException
DistributionConfigurationException

getMessagesProcessed

public int getMessagesProcessed()
Returns the total count of messages processed by this node.

Returns:
Returns the messagesProcessed.

getProcessMilliseconds

public long getProcessMilliseconds()
Returns the count of milliseconds spent by this node in its processing.

Returns:
Returns the processMilliseconds.

init

public void init()
          throws DistributionProcessingException,
                 DistributionConfigurationException
Initializes this node

Specified by:
init in interface MessageHandler
Throws:
DistributionProcessingException
DistributionConfigurationException

destroy

public void destroy()
             throws DistributionProcessingException,
                    DistributionConfigurationException
Cleans up this node

Specified by:
destroy in interface MessageHandler
Throws:
DistributionProcessingException
DistributionConfigurationException

getInitMilliseconds

public long getInitMilliseconds()
Returns:
Returns the initMilliseconds.

getId

public java.lang.String getId()
Description copied from interface: MessageHandler
The handler Id. It's guaranteed that the handler id is the same that the node it is contained in.

Specified by:
getId in interface MessageHandler
Returns:
Returns the id.

setId

public void setId(java.lang.String id)
Parameters:
id - The id to set.


Copyright © 2006 null. All Rights Reserved.