|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Interface for triggers that react to document-related events. Document triggers may have two roles:
prepare
method is called. The trigger code may take any action desired, for example, to ensure referential
integrity on the database, issue XUpdate commands on other documents in the database...content handler
and
lexical handler
. It will thus receive any SAX events generated by the SAX parser. The default
implementation just forwards the SAX events to the indexer, i.e. the output content handler. However,
a trigger may also alter the received SAX events before it forwards them to the indexer, for example,
by applying a stylesheet.prepare(int, DBBroker, Txn, XmldbURI, DocumentImpl)
and
finish(int, DBBroker, Txn, DocumentImpl)
will be called. To determine if the document is a binary resource,
call DocumentImpl.getResourceType()
.
The general contract for a trigger is as follows:
configure
method
will be called once.prepare
method once for each document to be stored, removed or updated. The trigger may
throw a TriggerException if the current action should be aborted.isValidating
in your code to check that you're
in validation phase.finish(int, DBBroker, Txn, DocumentImpl)
is called. At this point, the document
has already been stored and is ready to be used or - for Trigger.REMOVE_DOCUMENT_EVENT
- has been removed.
Field Summary |
Fields inherited from interface org.exist.collections.triggers.Trigger |
CREATE_COLLECTION_EVENT, DELETE_COLLECTION_EVENT, REMOVE_DOCUMENT_EVENT, RENAME_COLLECTION_EVENT, STORE_DOCUMENT_EVENT, UPDATE_DOCUMENT_EVENT |
Method Summary | |
void |
finish(int event,
DBBroker broker,
Txn transaction,
DocumentImpl document)
This method is called after the operation completed. |
org.xml.sax.ContentHandler |
getInputHandler()
Returns the input content handler. |
org.xml.sax.ext.LexicalHandler |
getLexicalInputHandler()
Returns the lexical input handler for this trigger. |
org.xml.sax.ext.LexicalHandler |
getLexicalOutputHandler()
Called by the database to set the lexical output handler for this trigger. |
org.xml.sax.ContentHandler |
getOutputHandler()
Returns the output handler to which SAX events should be forwarded. |
boolean |
isValidating()
Returns true if the SAX parser is currently in validation phase. |
void |
prepare(int event,
DBBroker broker,
Txn transaction,
XmldbURI documentPath,
DocumentImpl existingDocument)
This method is called once before the database will actually parse the input data. |
void |
setLexicalOutputHandler(org.xml.sax.ext.LexicalHandler handler)
Called by the database to set the lexical output content handler for this trigger. |
void |
setOutputHandler(org.xml.sax.ContentHandler handler)
Called by the database to set the output content handler for this trigger. |
void |
setValidating(boolean validating)
Called by the database to report that it is entering validation phase. |
Methods inherited from interface org.exist.collections.triggers.Trigger |
configure, getLogger |
Methods inherited from interface org.xml.sax.ContentHandler |
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping |
Methods inherited from interface org.xml.sax.ext.LexicalHandler |
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity |
Method Detail |
public void prepare(int event, DBBroker broker, Txn transaction, XmldbURI documentPath, DocumentImpl existingDocument) throws TriggerException
event
- the type of event that triggered this call (see the constants defined in this interface). The ContentHandler instance for the output.broker
- the database instance used to process the current action.transaction
- the current transaction contextdocumentPath
- the full absolute path of the document currently processed.existingDocument
- optional: if event is a Trigger.UPDATE_DOCUMENT_EVENT
,
existingDocument will contain the Document object for the old document, which will be overwritten. Otherwise, the parameter
is null.
TriggerException
- throwing a TriggerException will abort the current action.public void finish(int event, DBBroker broker, Txn transaction, DocumentImpl document)
event
- the type of event that triggered this call (see the constants defined in this interface).broker
- the database instance used to process the current action.transaction
- the current transaction contextdocument
- the stored documentpublic boolean isValidating()
isValidating
returns false, no exceptions should be
thrown.
public void setValidating(boolean validating)
validating
- public void setOutputHandler(org.xml.sax.ContentHandler handler)
handler
- public void setLexicalOutputHandler(org.xml.sax.ext.LexicalHandler handler)
handler
- public org.xml.sax.ContentHandler getOutputHandler()
public org.xml.sax.ContentHandler getInputHandler()
public org.xml.sax.ext.LexicalHandler getLexicalOutputHandler()
public org.xml.sax.ext.LexicalHandler getLexicalInputHandler()
getInputHandler
.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |