org.apache.servicemix.jbi.audit.jdbc
Class JdbcAuditor

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.jdbc.JdbcAuditor
All Implemented Interfaces:
EventListener, javax.jbi.management.LifeCycleMBean, AuditorMBean, ExchangeListener, ServiceMixListener, MBeanInfoProvider, org.springframework.beans.factory.InitializingBean

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

Basic implementation of ServiceMix auditor on a jdbc store. This implementation, for performance purposes, only relies on one table SM_AUDIT with two columns:

To minimize overhead, the exchange serialized is the undelying ExchangePacket.

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

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
JdbcAuditor()
           
 
Method Summary
 void afterPropertiesSet()
           
 int deleteExchangesByIds(String[] ids)
          Delete exchanges given their ids.
 void exchangeSent(ExchangeEvent event)
           
 DataSource getDataSource()
           
 String getDescription()
           
protected  javax.jbi.messaging.MessageExchange getExchange(byte[] data)
           
 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.
 boolean isAutoStart()
           
 void setAutoStart(boolean autoStart)
           
 void setDataSource(DataSource dataSource)
           
protected  void store(Connection connection, String id, byte[] data)
           
 
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

JdbcAuditor

public JdbcAuditor()
Method Detail

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

exchangeSent

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

store

protected void store(Connection connection,
                     String id,
                     byte[] data)
              throws Exception
Throws:
Exception

getDataSource

public DataSource getDataSource()

setDataSource

public void setDataSource(DataSource dataSource)

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.

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.

getExchange

protected javax.jbi.messaging.MessageExchange getExchange(byte[] data)
                                                   throws AuditorException
Throws:
AuditorException

isAutoStart

public boolean isAutoStart()

setAutoStart

public void setAutoStart(boolean autoStart)


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