org.apache.servicemix.eip.patterns
Class SplitAggregator

java.lang.Object
  extended by org.apache.servicemix.common.endpoints.AbstractEndpoint
      extended by org.apache.servicemix.common.endpoints.SimpleEndpoint
          extended by org.apache.servicemix.common.endpoints.ProviderEndpoint
              extended by org.apache.servicemix.eip.EIPEndpoint
                  extended by org.apache.servicemix.eip.support.AbstractAggregator
                      extended by org.apache.servicemix.eip.patterns.SplitAggregator
All Implemented Interfaces:
Endpoint
Direct Known Subclasses:
RecipientListAggregator

public class SplitAggregator
extends AbstractAggregator

Aggregator can be used to wait and combine several messages. This component implements the Aggregator pattern. This aggregator collect messages with a count, index and correlationId properties. These properties are automatically set by splitters. A timeout may be specified so that the aggregator will not keep data forever if a message is missing.

Version:
$Revision: 376451 $
Author:
gnodet

Nested Class Summary
protected static class SplitAggregator.SplitterAggregation
           
 
Nested classes/interfaces inherited from class org.apache.servicemix.eip.support.AbstractAggregator
AbstractAggregator.ClosedAggregateException
 
Field Summary
protected  javax.xml.namespace.QName aggregateElementName
           
protected  org.apache.servicemix.expression.Expression corrId
           
protected  org.apache.servicemix.expression.Expression count
           
protected  java.lang.String countAttribute
           
protected  org.apache.servicemix.expression.Expression index
           
protected  java.lang.String indexAttribute
           
protected  javax.xml.namespace.QName messageElementName
           
protected  long timeout
           
 
Fields inherited from class org.apache.servicemix.eip.EIPEndpoint
lockManager, store, storeFactory, timerManager, wsdlExchangeTarget, wsdlResource
 
Fields inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
definition, description, endpoint, interfaceName, service, serviceUnit
 
Constructor Summary
SplitAggregator()
           
 
Method Summary
 boolean addMessage(java.lang.Object aggregation, javax.jbi.messaging.NormalizedMessage message, javax.jbi.messaging.MessageExchange exchange)
          Add a newly received message to this aggregation
 void buildAggregate(java.lang.Object aggregation, javax.jbi.messaging.NormalizedMessage message, javax.jbi.messaging.MessageExchange exchange, boolean doTimeout)
          Fill the given JBI message with the aggregation result.
 java.lang.Object createAggregation(java.lang.String correlationID)
          Creates a new empty aggregation.
protected  org.w3c.dom.Element createChildElement(javax.xml.namespace.QName name, org.w3c.dom.Node parent)
           
 javax.xml.namespace.QName getAggregateElementName()
           
 java.lang.String getCorrelationID(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage message)
          Retrieve the correlation ID of the given exchange
 org.apache.servicemix.expression.Expression getCorrId()
           
 org.apache.servicemix.expression.Expression getCount()
           
 java.lang.String getCountAttribute()
           
 org.apache.servicemix.expression.Expression getIndex()
           
 java.lang.String getIndexAttribute()
           
 javax.xml.namespace.QName getMessageElementName()
           
 long getTimeout()
           
 java.util.Date getTimeout(java.lang.Object aggregation)
          Returns the date when the onTimeout method should be called if the aggregation is not completed yet, or null if the aggregation has no timeout.
 void setAggregateElementName(javax.xml.namespace.QName aggregateElementName)
          The qualified name that will be used as the root xml element when building the aggregate.
 void setCorrId(org.apache.servicemix.expression.Expression corrId)
          An expression used to compute the correlation ids of incoming messages to find related messages.
 void setCount(org.apache.servicemix.expression.Expression count)
          An expression used to compute the total number of message that the aggregate will contain.
 void setCountAttribute(java.lang.String countAttribute)
          The name of the xml attribute attached to the root element that will contain the number of messages in this aggregate.
 void setIndex(org.apache.servicemix.expression.Expression index)
          An expression used to compute the index of this message in the aggregate.
 void setIndexAttribute(java.lang.String indexAttribute)
          The name of the xml attribute attached to the message element that will contain the index of messages in this aggregate.
 void setMessageElementName(javax.xml.namespace.QName messageElementName)
          The qualified name of the xml element used to embed each message when building the aggregated message.
 void setTimeout(long timeout)
          The maximum amount of time (in milliseconds) that can elapse between messages for a single aggregate.
 
Methods inherited from class org.apache.servicemix.eip.support.AbstractAggregator
closeAggregation, getClosedAggregatesStoreFactory, getTarget, isAggregationClosed, isCopyAttachments, isCopyProperties, isReportClosedAggregatesAsErrors, isReportErrors, isReportTimeoutAsErrors, isRescheduleTimeouts, isSynchronous, onTimeout, process, processAsync, processSync, sendAggregate, setClosedAggregatesStoreFactory, setCopyAttachments, setCopyProperties, setReportClosedAggregatesAsErrors, setReportErrors, setReportTimeoutAsErrors, setRescheduleTimeouts, setSynchronous, setTarget, start
 
Methods inherited from class org.apache.servicemix.eip.EIPEndpoint
chooseFirstEndpointWithDescriptor, copyAttachments, copyProperties, getDefinition, getDefinitionFromDescription, getDefinitionFromWsdlExchangeTarget, getDefinitionFromWsdlResource, getDescription, getDescriptionForExchangeTarget, getEndpointsForExchangeTarget, getLockManager, getStore, getStoreFactory, getTimerManager, getWsdlExchangeTarget, getWsdlResource, setLockManager, setStore, setStoreFactory, setTimerManager, setWsdlExchangeTarget, setWsdlResource, stop
 
Methods inherited from class org.apache.servicemix.common.endpoints.ProviderEndpoint
activate, deactivate, getRole, processInOnly, processInOut
 
Methods inherited from class org.apache.servicemix.common.endpoints.SimpleEndpoint
done, fail, getChannel, getContext, getExchangeFactory, send, sendSync
 
Methods inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
getEndpoint, getInterfaceName, getKey, getService, getServiceUnit, isExchangeOkay, prepareExchange, setDefinition, setDescription, setEndpoint, setInterfaceName, setService, setServiceUnit, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

count

protected org.apache.servicemix.expression.Expression count

index

protected org.apache.servicemix.expression.Expression index

corrId

protected org.apache.servicemix.expression.Expression corrId

aggregateElementName

protected javax.xml.namespace.QName aggregateElementName

messageElementName

protected javax.xml.namespace.QName messageElementName

countAttribute

protected java.lang.String countAttribute

indexAttribute

protected java.lang.String indexAttribute

timeout

protected long timeout
Constructor Detail

SplitAggregator

public SplitAggregator()
Method Detail

getAggregateElementName

public javax.xml.namespace.QName getAggregateElementName()
Returns:
the aggregateElementName

setAggregateElementName

public void setAggregateElementName(javax.xml.namespace.QName aggregateElementName)
The qualified name that will be used as the root xml element when building the aggregate. Messages contents will be appended to this root element as direct children or inside an element dependending on the messageElementName property.

Parameters:
aggregateElementName - the aggregateElementName to set

getCorrId

public org.apache.servicemix.expression.Expression getCorrId()
Returns:
the corrId

setCorrId

public void setCorrId(org.apache.servicemix.expression.Expression corrId)
An expression used to compute the correlation ids of incoming messages to find related messages. The default value is to retrieve the same property as the splitter.

Parameters:
corrId - the corrId to set

getCount

public org.apache.servicemix.expression.Expression getCount()
Returns:
the count

setCount

public void setCount(org.apache.servicemix.expression.Expression count)
An expression used to compute the total number of message that the aggregate will contain. The default value is to retrieve the same property as the splitter. This property is evaluated on each incoming message and must always have the same value for all messages in the same aggregate.

Parameters:
count - the count to set

getCountAttribute

public java.lang.String getCountAttribute()
Returns:
the countAttribute

setCountAttribute

public void setCountAttribute(java.lang.String countAttribute)
The name of the xml attribute attached to the root element that will contain the number of messages in this aggregate.

Parameters:
countAttribute - the countAttribute to set

getIndex

public org.apache.servicemix.expression.Expression getIndex()
Returns:
the index

setIndex

public void setIndex(org.apache.servicemix.expression.Expression index)
An expression used to compute the index of this message in the aggregate. For a given message, the index must be unique within the aggregate and must range between 0 and count - 1 included.

Parameters:
index - the index to set

getIndexAttribute

public java.lang.String getIndexAttribute()
Returns:
the indexAttribute

setIndexAttribute

public void setIndexAttribute(java.lang.String indexAttribute)
The name of the xml attribute attached to the message element that will contain the index of messages in this aggregate.

Parameters:
indexAttribute - the indexAttribute to set

getMessageElementName

public javax.xml.namespace.QName getMessageElementName()
Returns:
the messageElementName

setMessageElementName

public void setMessageElementName(javax.xml.namespace.QName messageElementName)
The qualified name of the xml element used to embed each message when building the aggregated message. If null, messages contents will be appended directly as children of the root element.

Parameters:
messageElementName - the messageElementName to set

getTimeout

public long getTimeout()
Returns:
the timeout

setTimeout

public void setTimeout(long timeout)
The maximum amount of time (in milliseconds) that can elapse between messages for a single aggregate. The default value is 0 which means that the timeout is not used at all.

Parameters:
timeout - the timeout to set

createAggregation

public java.lang.Object createAggregation(java.lang.String correlationID)
Description copied from class: AbstractAggregator
Creates a new empty aggregation.

Specified by:
createAggregation in class AbstractAggregator
Returns:
a newly created aggregation

getCorrelationID

public java.lang.String getCorrelationID(javax.jbi.messaging.MessageExchange exchange,
                                         javax.jbi.messaging.NormalizedMessage message)
                                  throws java.lang.Exception
Description copied from class: AbstractAggregator
Retrieve the correlation ID of the given exchange

Specified by:
getCorrelationID in class AbstractAggregator
Returns:
the correlationID
Throws:
AbstractAggregator.ClosedAggregateException
java.lang.Exception

addMessage

public boolean addMessage(java.lang.Object aggregation,
                          javax.jbi.messaging.NormalizedMessage message,
                          javax.jbi.messaging.MessageExchange exchange)
                   throws java.lang.Exception
Description copied from class: AbstractAggregator
Add a newly received message to this aggregation

Specified by:
addMessage in class AbstractAggregator
Returns:
true if the aggregate id complete
Throws:
java.lang.Exception

buildAggregate

public void buildAggregate(java.lang.Object aggregation,
                           javax.jbi.messaging.NormalizedMessage message,
                           javax.jbi.messaging.MessageExchange exchange,
                           boolean doTimeout)
                    throws java.lang.Exception
Description copied from class: AbstractAggregator
Fill the given JBI message with the aggregation result.

Specified by:
buildAggregate in class AbstractAggregator
doTimeout - false if the aggregation has completed or true if this aggregation has timed out
Throws:
java.lang.Exception

createChildElement

protected org.w3c.dom.Element createChildElement(javax.xml.namespace.QName name,
                                                 org.w3c.dom.Node parent)

getTimeout

public java.util.Date getTimeout(java.lang.Object aggregation)
Description copied from class: AbstractAggregator
Returns the date when the onTimeout method should be called if the aggregation is not completed yet, or null if the aggregation has no timeout.

Specified by:
getTimeout in class AbstractAggregator
Returns:


Copyright © 2005-2011 FuseSource. All Rights Reserved.