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

java.lang.Object
  extended by org.apache.servicemix.nmr.audit.AbstractAuditor
      extended by org.apache.servicemix.nmr.audit.lucene.LuceneAuditor
All Implemented Interfaces:
EventListener, ExchangeListener, Listener, AuditorMBean, AuditorQueryMBean

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: 550578 $
Author:
George Gastaldi

Field Summary
static String FIELD_CONTENT
           
static String FIELD_ID
           
static String FIELD_MEP
           
static String FIELD_PROPERTIES
           
static String FIELD_ROLE
           
static String FIELD_STATUS
           
 
Fields inherited from class org.apache.servicemix.nmr.audit.AbstractAuditor
logger
 
Constructor Summary
LuceneAuditor()
           
 
Method Summary
protected  void addExchangePropertiesToDocument(Exchange exchange, org.apache.lucene.document.Document document)
           
protected  void addMessageHeadersToDocument(Message message, org.apache.lucene.document.Document document, Type type)
           
protected  org.apache.lucene.document.Document createDocument(Exchange exchange)
           
 int deleteExchangesByIds(String[] ids)
          Delete exchanges given their ids.
 int deleteExchangesByRange(int fromIndex, int toIndex)
          Delete exchanges ranging from fromIndex to toIndex.
 void exchangeSent(Exchange exchange)
          Method called each time an exchange is sent
 String[] findExchangesIdsByMessageContent(String type, String content)
           
 String[] findExchangesIdsByMessageHeader(String type, String property, String value)
           
 String[] findExchangesIdsByProperty(String property, String value)
           
 String[] findExchangesIdsByQuery(String query)
           
 String[] findExchangesIdsByStatus(Status status)
           
protected  String getBodyAsText(Message message)
           
 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.
 Exchange[] 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.nmr.audit.AbstractAuditor
deleteAllExchanges, deleteExchangeById, deleteExchangeByIndex, exchangeDelivered, exchangeFailed, getAllExchangeIds, getAllExchanges, getExchangeById, getExchangeByIndex, getExchangeIdByIndex, getExchangesByRange, resendExchange
 
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.audit.AuditorMBean
deleteAllExchanges, deleteExchangeById, deleteExchangeByIndex, getAllExchangeIds, getAllExchanges, getExchangeById, getExchangeByIndex, getExchangeIdByIndex, getExchangesByRange, resendExchange
 

Field Detail

FIELD_ID

public static final String FIELD_ID
See Also:
Constant Field Values

FIELD_STATUS

public static final String FIELD_STATUS
See Also:
Constant Field Values

FIELD_MEP

public static final String FIELD_MEP
See Also:
Constant Field Values

FIELD_ROLE

public static final String FIELD_ROLE
See Also:
Constant Field Values

FIELD_PROPERTIES

public static final String FIELD_PROPERTIES
See Also:
Constant Field Values

FIELD_CONTENT

public static final String FIELD_CONTENT
See Also:
Constant Field Values
Constructor Detail

LuceneAuditor

public LuceneAuditor()
Method Detail

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 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
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:
the number of exchanges deleted
Throws:
AuditorException - if an error occurs accessing the data store.

exchangeSent

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

Specified by:
exchangeSent in interface ExchangeListener
Parameters:
exchange - the exchange sent

getDescription

public String getDescription()

findExchangesIdsByQuery

public String[] findExchangesIdsByQuery(String query)
                                 throws AuditorException
Specified by:
findExchangesIdsByQuery in interface AuditorQueryMBean
Throws:
AuditorException

findExchangesIdsByStatus

public String[] findExchangesIdsByStatus(Status status)
                                  throws AuditorException
Specified by:
findExchangesIdsByStatus in interface AuditorQueryMBean
Throws:
AuditorException

findExchangesIdsByProperty

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

findExchangesIdsByMessageContent

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

findExchangesIdsByMessageHeader

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

createDocument

protected org.apache.lucene.document.Document createDocument(Exchange exchange)
                                                      throws AuditorException
Throws:
AuditorException

getBodyAsText

protected String getBodyAsText(Message message)

addExchangePropertiesToDocument

protected void addExchangePropertiesToDocument(Exchange exchange,
                                               org.apache.lucene.document.Document document)

addMessageHeadersToDocument

protected void addMessageHeadersToDocument(Message message,
                                           org.apache.lucene.document.Document document,
                                           Type type)

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-2012 FuseSource. All Rights Reserved.