org.apache.servicemix.nmr.audit
Class AbstractAuditor

java.lang.Object
  extended by org.apache.servicemix.nmr.audit.AbstractAuditor
All Implemented Interfaces:
EventListener, ExchangeListener, Listener, AuditorMBean
Direct Known Subclasses:
FileAuditor, JdbcAuditor, LuceneAuditor

public abstract class AbstractAuditor
extends Object
implements AuditorMBean, ExchangeListener

Base class for ServiceMix auditors implementations.

Since:
1.0.0
Version:
$Revision: 550578 $
Author:
Guillaume Nodet (gnt)

Field Summary
protected  org.slf4j.Logger logger
           
 
Constructor Summary
AbstractAuditor()
           
 
Method Summary
 int deleteAllExchanges()
          Delete all exchanges =from the data store.
 boolean deleteExchangeById(String id)
          Delete the exchange with the specified id.
 boolean deleteExchangeByIndex(int index)
          Delete a message, given its index.
abstract  int deleteExchangesByIds(String[] ids)
          Delete exchanges given their ids.
 int deleteExchangesByRange(int fromIndex, int toIndex)
          Delete exchanges ranging from fromIndex to toIndex.
 void exchangeDelivered(Exchange exchange)
          Method called each time an exchange is delivered
 void exchangeFailed(Exchange exchange)
          Method called when an exchange resulted in an exception to be thrown and the exchange not delivered.
 String[] getAllExchangeIds()
          Retrieve all exchanges ids from the data store.
 Exchange[] getAllExchanges()
          Retrieve all exchanges =from the data store.
 Exchange getExchangeById(String id)
          Retrieve the exchange for a specified id.
 Exchange getExchangeByIndex(int index)
          Retrieve the exchange at the specified index.
abstract  int getExchangeCount()
          Get the number of exchanges stored by this auditor.
 String getExchangeIdByIndex(int index)
          Retrieve the exchange id of the exchange at the specified index.
abstract  String[] getExchangeIdsByRange(int fromIndex, int toIndex)
          Retrieve a range of message exchange ids.
abstract  Exchange[] getExchangesByIds(String[] ids)
          Retrieve exchanges for the specified ids.
 Exchange[] getExchangesByRange(int fromIndex, int toIndex)
          Retrieve a range of message exchange.
 void resendExchange(Exchange exchange)
          Resend an exchange on behalf of the consumer component that initiated this exchange.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.servicemix.nmr.api.event.ExchangeListener
exchangeSent
 

Field Detail

logger

protected final org.slf4j.Logger logger
Constructor Detail

AbstractAuditor

public AbstractAuditor()
Method Detail

getExchangeCount

public abstract int getExchangeCount()
                              throws AuditorException
Description copied from interface: AuditorMBean
Get the number of exchanges stored by this auditor.

Specified by:
getExchangeCount in interface AuditorMBean
Returns:
the number of exchanges stored
Throws:
AuditorException - if an error occurs accessing the data store.

getExchangeIdByIndex

public String getExchangeIdByIndex(int index)
                            throws AuditorException
Description copied from interface: AuditorMBean
Retrieve the exchange id of the exchange at the specified index. Index must be a null or positive integer. If index is greater than the number of exchanges stored, a null string should be returned.

Specified by:
getExchangeIdByIndex in interface AuditorMBean
Parameters:
index - the index of the exchange
Returns:
the exchange id, or null of index is greater than the exchange count
Throws:
AuditorException - if an error occurs accessing the data store.

getAllExchangeIds

public String[] getAllExchangeIds()
                           throws AuditorException
Description copied from interface: AuditorMBean
Retrieve all exchanges ids from the data store.

Specified by:
getAllExchangeIds in interface AuditorMBean
Returns:
an array of exchange ids
Throws:
AuditorException - if an error occurs accessing the data store.

getExchangeIdsByRange

public abstract String[] getExchangeIdsByRange(int fromIndex,
                                               int toIndex)
                                        throws AuditorException
Description copied from interface: AuditorMBean
Retrieve a range of message exchange ids. The ids retrieved range from fromIndex (inclusive) to toIndex (exclusive). If fromIndex == toIndex, an empty array must be returned. If fromIndex is less than zero, or if toIndex is less than fromIndex, an exception will be thrown. An array of exactly (toIndex - fromIndex) element should be returned. This array must be filled by null, for indexes that are greater than the number of exchanges stored.

Specified by:
getExchangeIdsByRange in interface AuditorMBean
Parameters:
fromIndex - the lower bound index of the ids to be retrieved. fromIndex must be greater or equal to zero.
toIndex - the upper bound (exclusive) of the ids to be retrieved. toIndex must be greater or equal to fromIndex
Returns:
an array of exchange ids
Throws:
AuditorException - if an error occurs accessing the data store.

getExchangeByIndex

public Exchange getExchangeByIndex(int index)
                            throws AuditorException
Description copied from interface: AuditorMBean
Retrieve the exchange at the specified index. Index must be a null or positive integer, and should be less than the current exchange count stored. If index is greater than the number of exchanges stored, a null exchange should be returned.

Specified by:
getExchangeByIndex in interface AuditorMBean
Parameters:
index - the index of the exchange
Returns:
the exchange, or null of index is greater than the exchange count
Throws:
AuditorException - if an error occurs accessing the data store.

getExchangeById

public Exchange getExchangeById(String id)
                         throws AuditorException
Description copied from interface: AuditorMBean
Retrieve the exchange for a specified id. Id must be non null and non empty. If the exchange with the specified id is not found, null should be returned.

Specified by:
getExchangeById in interface AuditorMBean
Parameters:
id - the id of the exchange
Returns:
the exchange with the specified id, or null if not found
Throws:
AuditorException - if an error occurs accessing the data store.

getAllExchanges

public Exchange[] getAllExchanges()
                           throws AuditorException
Description copied from interface: AuditorMBean
Retrieve all exchanges =from the data store.

Specified by:
getAllExchanges in interface AuditorMBean
Returns:
an array of exchange
Throws:
AuditorException - if an error occurs accessing the data store.

getExchangesByRange

public Exchange[] getExchangesByRange(int fromIndex,
                                      int toIndex)
                               throws AuditorException
Description copied from interface: AuditorMBean
Retrieve a range of message exchange. The exchanges retrieved range from fromIndex (inclusive) to toIndex (exclusive). If fromIndex == toIndex, an empty array must be returned. If fromIndex is less than zero, or if toIndex is less than fromIndex, an exception will be thrown. An array of exactly (toIndex - fromIndex) element should be returned. This array must be filled by null, for indexes that are greater than the number of exchanges stored.

Specified by:
getExchangesByRange in interface AuditorMBean
Parameters:
fromIndex - the lower bound index of the exchanges to be retrieved. fromIndex must be greater or equal to zero.
toIndex - the upper bound (exclusive) of the exchanges to be retrieved. toIndex must be greater or equal to fromIndex
Returns:
an array of exchange
Throws:
AuditorException - if an error occurs accessing the data store.

getExchangesByIds

public abstract Exchange[] getExchangesByIds(String[] ids)
                                      throws AuditorException
Description copied from interface: AuditorMBean
Retrieve exchanges for the specified ids. An array of exactly ids.length elements must be returned. This array should be filled with null for exchanges that have not been found in the store.

Specified by:
getExchangesByIds in interface AuditorMBean
Parameters:
ids - the ids of exchanges to retrieve
Returns:
an array of exchanges
Throws:
AuditorException - if an error occurs accessing the data store.

deleteAllExchanges

public int deleteAllExchanges()
                       throws AuditorException
Description copied from interface: AuditorMBean
Delete all exchanges =from the data store.

Specified by:
deleteAllExchanges in interface AuditorMBean
Returns:
the number of exchanges deleted, or -1 if such information can not be provided
Throws:
AuditorException - if an error occurs accessing the data store.

deleteExchangeByIndex

public boolean deleteExchangeByIndex(int index)
                              throws AuditorException
Description copied from interface: AuditorMBean
Delete a message, given its index. Index must be a null or positive integer, and should be less than the current exchange count stored. If index is greater than the number of exchanges stored, false should be returned.

Specified by:
deleteExchangeByIndex in interface AuditorMBean
Parameters:
index - the index of the exchange
Returns:
true if the exchange has been successfully deleted, false if index is greater than the number of exchanges stored
Throws:
AuditorException - if an error occurs accessing the data store.

deleteExchangeById

public boolean deleteExchangeById(String id)
                           throws AuditorException
Description copied from interface: AuditorMBean
Delete the exchange with the specified id. Id must be non null and non empty.

Specified by:
deleteExchangeById in interface AuditorMBean
Parameters:
id - the id of the exchange to delete
Returns:
true if the exchange has been successfully deleted, false if the exchange was not found
Throws:
AuditorException - if an error occurs accessing the data store.

deleteExchangesByRange

public int deleteExchangesByRange(int fromIndex,
                                  int toIndex)
                           throws AuditorException
Description copied from interface: AuditorMBean
Delete exchanges ranging from fromIndex to toIndex.

Specified by:
deleteExchangesByRange in interface AuditorMBean
Parameters:
fromIndex - the lower bound index of the exchanges to be retrieved. fromIndex must be greater or equal to zero.
toIndex - the upper bound (exclusive) of the exchanges to be retrieved. toIndex must be greater or equal to fromIndex
Returns:
the number of exchanges deleted
Throws:
AuditorException - if an error occurs accessing the data store.

deleteExchangesByIds

public abstract int deleteExchangesByIds(String[] ids)
                                  throws AuditorException
Description copied from interface: AuditorMBean
Delete exchanges given their ids.

Specified by:
deleteExchangesByIds in interface AuditorMBean
Parameters:
ids - the ids of exchanges to retrieve
Returns:
the number of exchanges deleted
Throws:
AuditorException - if an error occurs accessing the data store.

resendExchange

public void resendExchange(Exchange exchange)
                    throws AuditorException
Description copied from interface: AuditorMBean
Resend an exchange on behalf of the consumer component that initiated this exchange. The exchange must have been retrieved from this auditor, else the behavior is undefined. The exchange will be given a new id and will be reset to its original state: the out and fault messages will be removed (if they exist), the error will be set to null, state to ACTIVE. The consumer component must be prepared to receive a response or a DONE status to an exchange it did not have directly initiated.

Specified by:
resendExchange in interface AuditorMBean
Parameters:
exchange - the exchange to be sent
Throws:
AuditorException - if an error occurs re-sending the exchange

exchangeDelivered

public void exchangeDelivered(Exchange exchange)
Description copied from interface: ExchangeListener
Method called each time an exchange is delivered

Specified by:
exchangeDelivered in interface ExchangeListener
Parameters:
exchange - the delivered exchange

exchangeFailed

public void exchangeFailed(Exchange exchange)
Description copied from interface: ExchangeListener
Method called when an exchange resulted in an exception to be thrown and the exchange not delivered. This can happen if no endpoint can be found for the target or if something else bad happen.

Specified by:
exchangeFailed in interface ExchangeListener
Parameters:
exchange - the exchange that failed


Copyright © 2005-2012 FuseSource. All Rights Reserved.