org.apache.servicemix.jbi.audit.lucene
Class LuceneAuditor

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.lucene.LuceneAuditor
All Implemented Interfaces:
EventListener, javax.jbi.management.LifeCycleMBean, AuditorMBean, AuditorQueryMBean, ExchangeListener, ServiceMixListener, MBeanInfoProvider

public class LuceneAuditor
extends AbstractAuditor
implements AuditorQueryMBean

Lucene AuditorQuery implementation. It uses Lucene as the indexing mechanism for searching Exchanges and needs a delegated AuditorMBean to persist Exchanges. The Content of messages are stored as: - org.apache.servicemix.in.contents - org.apache.servicemix.out.contents, if exists - org.apache.servicemix.fault.contents, if exists Properties for IN Messages are stored as: - org.apache.servicemix.in.propertyname - org.apache.servicemix.out.propertyname, if exists - org.apache.servicemix.fault.propertyname, if exists

Since:
2.1
Version:
$Revision: 34165 $
Author:
George Gastaldi

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
LuceneAuditor()
           
 
Method Summary
protected  void addMessagePropertiesToDocument(javax.jbi.messaging.NormalizedMessage nm, org.apache.lucene.document.Document document, String type)
           
protected  org.apache.lucene.document.Document createDocument(javax.jbi.messaging.MessageExchange me)
           
 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 exchangeSent(ExchangeEvent event)
           
 String[] findExchangesIDsByMessageContent(String type, String content)
           
 String[] findExchangesIDsByMessageProperty(String type, String property, String value)
           
 String[] findExchangesIDsByStatus(javax.jbi.messaging.ExchangeStatus status)
           
 AuditorMBean getDelegatedAuditor()
           
 String getDescription()
           
 int getExchangeCount()
          Get the number of exchanges stored by this auditor.
 String[] getExchangeIds(String queryContent, String field)
          Searches for Exchanges IDs using the supplied key-field and the expected content of the field
 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.
 LuceneIndexer getLuceneIndexer()
           
 void setDelegatedAuditor(AuditorMBean delegatedAuditor)
           
 void setLuceneIndexer(LuceneIndexer luceneIndexer)
           
 
Methods inherited from class org.apache.servicemix.jbi.audit.AbstractAuditor
deleteAllExchanges, deleteExchangeById, deleteExchangeByIndex, 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 org.apache.servicemix.jbi.audit.AuditorMBean
deleteAllExchanges, deleteExchangeById, deleteExchangeByIndex, getAllExchangeIds, getAllExchanges, getExchangeById, getExchangeByIndex, getExchangeIdByIndex, getExchangesByRange, resendExchange
 
Methods inherited from interface javax.jbi.management.LifeCycleMBean
getCurrentState, shutDown, start, stop
 

Constructor Detail

LuceneAuditor

public LuceneAuditor()
Method Detail

doStart

protected void doStart()
                throws javax.jbi.JBIException
Overrides:
doStart in class AbstractAuditor
Throws:
javax.jbi.JBIException

doStop

protected void doStop()
               throws javax.jbi.JBIException
Overrides:
doStop in class AbstractAuditor
Throws:
javax.jbi.JBIException

getLuceneIndexer

public LuceneIndexer getLuceneIndexer()
Returns:
Returns the luceneIndexer.

setLuceneIndexer

public void setLuceneIndexer(LuceneIndexer luceneIndexer)
Parameters:
luceneIndexer - The luceneIndexer to set.

getDelegatedAuditor

public AuditorMBean getDelegatedAuditor()
Returns:
Returns the delegatedAuditor.

setDelegatedAuditor

public void setDelegatedAuditor(AuditorMBean delegatedAuditor)
Parameters:
delegatedAuditor - The delegatedAuditor to set.

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.

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
Overrides:
deleteExchangesByRange in class AbstractAuditor
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 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.

exchangeSent

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

getDescription

public String getDescription()
Specified by:
getDescription in interface MBeanInfoProvider

findExchangesIDsByStatus

public String[] findExchangesIDsByStatus(javax.jbi.messaging.ExchangeStatus status)
                                  throws AuditorException
Specified by:
findExchangesIDsByStatus in interface AuditorQueryMBean
Throws:
AuditorException

findExchangesIDsByMessageContent

public String[] findExchangesIDsByMessageContent(String type,
                                                 String content)
                                          throws AuditorException
Specified by:
findExchangesIDsByMessageContent in interface AuditorQueryMBean
Throws:
AuditorException

findExchangesIDsByMessageProperty

public String[] findExchangesIDsByMessageProperty(String type,
                                                  String property,
                                                  String value)
                                           throws AuditorException
Specified by:
findExchangesIDsByMessageProperty in interface AuditorQueryMBean
Throws:
AuditorException

createDocument

protected org.apache.lucene.document.Document createDocument(javax.jbi.messaging.MessageExchange me)
                                                      throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

addMessagePropertiesToDocument

protected void addMessagePropertiesToDocument(javax.jbi.messaging.NormalizedMessage nm,
                                              org.apache.lucene.document.Document document,
                                              String type)
                                       throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

getExchangeIds

public String[] getExchangeIds(String queryContent,
                               String field)
                        throws AuditorException
Description copied from interface: AuditorQueryMBean
Searches for Exchanges IDs using the supplied key-field and the expected content of the field

Specified by:
getExchangeIds in interface AuditorQueryMBean
Returns:
exchange ids
Throws:
AuditorException - if an error occurs


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