org.apache.servicemix.jbi.audit
Class AbstractAuditor

java.lang.Object
  extended by org.apache.servicemix.jbi.management.BaseLifeCycle
      extended by org.apache.servicemix.jbi.management.BaseSystemService
          extended by org.apache.servicemix.jbi.audit.AbstractAuditor
All Implemented Interfaces:
EventListener, javax.jbi.management.LifeCycleMBean, AuditorMBean, ExchangeListener, ServiceMixListener, MBeanInfoProvider
Direct Known Subclasses:
FileAuditor, JdbcAuditor, LuceneAuditor

public abstract class AbstractAuditor
extends BaseSystemService
implements AuditorMBean, ExchangeListener

Base class for ServiceMix auditors implementations.

Since:
2.1
Version:
$Revision: 34165 $
Author:
Guillaume Nodet (gnt)

Field Summary
protected  Log log
           
 
Fields inherited from class org.apache.servicemix.jbi.management.BaseSystemService
container
 
Fields inherited from class org.apache.servicemix.jbi.management.BaseLifeCycle
currentState, INITIALIZED, listener
 
Fields inherited from interface javax.jbi.management.LifeCycleMBean
SHUTDOWN, STARTED, STOPPED, UNKNOWN
 
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.
protected  void doStart()
           
protected  void doStop()
           
 void exchangeAccepted(ExchangeEvent event)
           
 String[] getAllExchangeIds()
          Retrieve all exchanges ids from the data store.
 javax.jbi.messaging.MessageExchange[] getAllExchanges()
          Retrieve all exchanges =from the data store.
 MBeanAttributeInfo[] getAttributeInfos()
           
 JBIContainer getContainer()
           
 javax.jbi.messaging.MessageExchange getExchangeById(String id)
          Retrieve the exchange for a specified id.
 javax.jbi.messaging.MessageExchange 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  javax.jbi.messaging.MessageExchange[] getExchangesByIds(String[] ids)
          Retrieve exchanges for the specified ids.
 javax.jbi.messaging.MessageExchange[] getExchangesByRange(int fromIndex, int toIndex)
          Retrieve a range of message exchange.
 MBeanOperationInfo[] getOperationInfos()
           
protected  Class getServiceMBean()
           
 boolean isAsContainerListener()
          Test if Auditor should be included as a container listener
 void resendExchange(javax.jbi.messaging.MessageExchange exchange)
          Resend an exchange on behalf of the consumer component that initiated this exchange.
 void setAsContainerListener(boolean addToContainer)
          Set if Auditor should be included as a container listener.
 void setContainer(JBIContainer container)
           
 void start()
           
 void stop()
           
 
Methods inherited from class org.apache.servicemix.jbi.management.BaseSystemService
getName, getType, init, shutDown
 
Methods inherited from class org.apache.servicemix.jbi.management.BaseLifeCycle
firePropertyChanged, getCurrentState, getObjectToManage, getSubType, init, isInitialized, isShutDown, isStarted, isStopped, isUnknown, setCurrentState, setPropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jbi.management.LifeCycleMBean
getCurrentState, shutDown
 
Methods inherited from interface org.apache.servicemix.jbi.event.ExchangeListener
exchangeSent
 
Methods inherited from interface org.apache.servicemix.jbi.management.MBeanInfoProvider
getDescription
 

Field Detail

log

protected final Log log
Constructor Detail

AbstractAuditor

public AbstractAuditor()
Method Detail

getContainer

public JBIContainer getContainer()
Overrides:
getContainer in class BaseSystemService

setContainer

public void setContainer(JBIContainer container)

getServiceMBean

protected Class getServiceMBean()
Specified by:
getServiceMBean in class BaseSystemService

start

public void start()
           throws javax.jbi.JBIException
Specified by:
start in interface javax.jbi.management.LifeCycleMBean
Overrides:
start in class BaseLifeCycle
Throws:
javax.jbi.JBIException

stop

public void stop()
          throws javax.jbi.JBIException
Specified by:
stop in interface javax.jbi.management.LifeCycleMBean
Overrides:
stop in class BaseLifeCycle
Throws:
javax.jbi.JBIException

doStart

protected void doStart()
                throws javax.jbi.JBIException
Throws:
javax.jbi.JBIException

doStop

protected void doStop()
               throws javax.jbi.JBIException
Throws:
javax.jbi.JBIException

getAttributeInfos

public MBeanAttributeInfo[] getAttributeInfos()
                                       throws JMException
Specified by:
getAttributeInfos in interface MBeanInfoProvider
Overrides:
getAttributeInfos in class BaseLifeCycle
Throws:
JMException

getOperationInfos

public MBeanOperationInfo[] getOperationInfos()
                                       throws JMException
Specified by:
getOperationInfos in interface MBeanInfoProvider
Overrides:
getOperationInfos in class BaseLifeCycle
Throws:
JMException

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 javax.jbi.messaging.MessageExchange 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 javax.jbi.messaging.MessageExchange 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 javax.jbi.messaging.MessageExchange[] 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 javax.jbi.messaging.MessageExchange[] 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 javax.jbi.messaging.MessageExchange[] 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:
an array of exchanges
Throws:
AuditorException - if an error occurs accessing the data store.

resendExchange

public void resendExchange(javax.jbi.messaging.MessageExchange exchange)
                    throws javax.jbi.JBIException
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:
javax.jbi.JBIException - if an error occurs re-sending the exchange

isAsContainerListener

public boolean isAsContainerListener()
Test if Auditor should be included as a container listener

Returns:
Returns the addToContainer.

setAsContainerListener

public void setAsContainerListener(boolean addToContainer)
Set if Auditor should be included as a container listener.

Parameters:
addToContainer - The addToContainer to set.

exchangeAccepted

public void exchangeAccepted(ExchangeEvent event)
Specified by:
exchangeAccepted in interface ExchangeListener


Copyright © 2005-2008 The Apache Software Foundation. All Rights Reserved.