org.exist.collections.triggers
Interface Trigger

All Known Subinterfaces:
CollectionTrigger, DocumentTrigger
All Known Implementing Classes:
FilteringTrigger, HistoryTrigger

public interface Trigger

Defines the base interface for collection triggers. Triggers are registered through the collection configuration file, called "collection.xconf", which should be stored in the corresponding database collection. If a collection configuration file is found in the collection, it will be parsed and any triggers will be created and configured. The configure method is called once on each trigger. Triggers listen to events. Currently, there are five events to which triggers may be attached:

STORE_DOCUMENT_EVENT Fired, if a new document is inserted into the collection.
UPDATE_DOCUMENT_EVENT Fired, whenever an existing document is updated, i.e. replaced with a new version.
REMOVE_DOCUMENT_EVENT Fired, whenever a document is removed from the collection.
RENAME_COLLECTION_EVENT Fired, before a collection is renamed.
CREATE_COLLECTION_EVENT Fired, before a new collection is created.
The document-related events are handled by the sub-interface DocumentTrigger, collection-related events are handled by CollectionTrigger. The collection configuration file looks as follows:
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <exist:collection xmlns:exist="http://exist-db.org/collection-config/1.0">
	<exist:triggers>
		<exist:trigger event="store"
		class="fully qualified classname of the trigger">
			<exist:parameter name="parameter-name"
				value="parameter-value"/>
		</exist:trigger>
	</exist:triggers>
 </exist:collection>
 

Author:
wolf
See Also:
DocumentTrigger

Field Summary
static int CREATE_COLLECTION_EVENT
           
static int DELETE_COLLECTION_EVENT
           
static int REMOVE_DOCUMENT_EVENT
           
static int RENAME_COLLECTION_EVENT
           
static int STORE_DOCUMENT_EVENT
           
static int UPDATE_DOCUMENT_EVENT
           
 
Method Summary
 void configure(DBBroker broker, Collection parent, java.util.Map parameters)
          The configure method is called once whenever the collection configuration is loaded.
 org.apache.log4j.Logger getLogger()
          Returns a Logger object.
 

Field Detail

STORE_DOCUMENT_EVENT

public static final int STORE_DOCUMENT_EVENT
See Also:
Constant Field Values

UPDATE_DOCUMENT_EVENT

public static final int UPDATE_DOCUMENT_EVENT
See Also:
Constant Field Values

REMOVE_DOCUMENT_EVENT

public static final int REMOVE_DOCUMENT_EVENT
See Also:
Constant Field Values

CREATE_COLLECTION_EVENT

public static final int CREATE_COLLECTION_EVENT
See Also:
Constant Field Values

RENAME_COLLECTION_EVENT

public static final int RENAME_COLLECTION_EVENT
See Also:
Constant Field Values

DELETE_COLLECTION_EVENT

public static final int DELETE_COLLECTION_EVENT
See Also:
Constant Field Values
Method Detail

configure

public void configure(DBBroker broker,
                      Collection parent,
                      java.util.Map parameters)
               throws CollectionConfigurationException
The configure method is called once whenever the collection configuration is loaded. Use it to initialize the trigger, probably by looking at the parameters.

Parameters:
broker - the database instance used to load the collection configuration. The broker object is required for all database actions. Please note: the broker instance used for configuration is probably different from the one passed to the prepare method. Don't store the broker object in your class.
parent - the collection to which this trigger belongs.
parameters - a Map containing any key/value parameters defined in the configuration file.
Throws:
CollectionConfigurationException - if the trigger cannot be initialized.

getLogger

public org.apache.log4j.Logger getLogger()
Returns a Logger object. Use this to log debugging information.



Copyright (C) Wolfgang Meier. All rights reserved.