org.apache.servicemix.jbi.audit.file
Class FileAuditor

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
              extended by org.apache.servicemix.jbi.audit.file.FileAuditor
All Implemented Interfaces:
EventListener, javax.jbi.management.LifeCycleMBean, AuditorMBean, ExchangeListener, ServiceMixListener, MBeanInfoProvider, org.springframework.beans.factory.InitializingBean

public class FileAuditor
extends AbstractAuditor
implements org.springframework.beans.factory.InitializingBean

Simple implementation of a ServiceMix auditor that stores messages in files in a directory. Shows usage of TeeInputStream for auditing StreamSource message content. Currently, the file auditor will only store the message body for ACTIVE exchanges.


Field Summary
 
Fields inherited from class org.apache.servicemix.jbi.audit.AbstractAuditor
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
FileAuditor()
           
 
Method Summary
 void afterPropertiesSet()
           
 int deleteExchangesByIds(String[] ids)
          Delete exchanges given their ids.
 void exchangeSent(ExchangeEvent event)
          
 String getDescription()
          
 int getExchangeCount()
          Get the number of exchanges stored by this auditor.
 String[] getExchangeIdsByRange(int fromIndex, int toIndex)
          Retrieve a range of message exchange ids.
 javax.jbi.messaging.MessageExchange[] getExchangesByIds(String[] ids)
          Retrieve exchanges for the specified ids.
 void setDirectory(File directory)
          The directory used for storing the audited messages
 
Methods inherited from class org.apache.servicemix.jbi.audit.AbstractAuditor
deleteAllExchanges, deleteExchangeById, deleteExchangeByIndex, deleteExchangesByRange, doStart, doStop, exchangeAccepted, getAllExchangeIds, getAllExchanges, getAttributeInfos, getContainer, getExchangeById, getExchangeByIndex, getExchangeIdByIndex, getExchangesByRange, getOperationInfos, getServiceMBean, isAsContainerListener, resendExchange, setAsContainerListener, setContainer, start, 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
 

Constructor Detail

FileAuditor

public FileAuditor()
Method Detail

setDirectory

public void setDirectory(File directory)
The directory used for storing the audited messages

Parameters:
directory - the directory

exchangeSent

public void exchangeSent(ExchangeEvent event)

Specified by:
exchangeSent in interface ExchangeListener

deleteExchangesByIds

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

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

getExchangeCount

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

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

getExchangeIdsByRange

public 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
Specified by:
getExchangeIdsByRange in class AbstractAuditor
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.

getExchangesByIds

public 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
Specified by:
getExchangesByIds in class AbstractAuditor
Parameters:
ids - the ids of exchanges to retrieve
Returns:
an array of exchanges
Throws:
AuditorException - if an error occurs accessing the data store.

getDescription

public String getDescription()

Specified by:
getDescription in interface MBeanInfoProvider

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception


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