## org.exist.collections.triggers
Class TriggerStatePerThread

    java.lang.Object
      org.exist.collections.triggers.TriggerStatePerThread

public class TriggerStatePerThread
extends java.lang.Object

Finite State Machine, managing the state of a Running trigger; allows to avoid infinite recursions by forbidding another trigger to run where there is allready one; feature trigger_update . I implemented that when a trigger is running , another trigger in the same Thread cannot be fired . There is a second condition that when a trigger is running triggered by some document d, even the same trigger cannot run on a different document . maybe TODO: apply "state" design pattern

Nested Class Summary
`static class` `TriggerStatePerThread.TriggerState`

Field Summary
`static int` `NO_TRIGGER_RUNNING`
`static int` `TRIGGER_RUNNING_FINISH`
`static int` `TRIGGER_RUNNING_PREPARE`

Constructor Summary
`TriggerStatePerThread()`

Method Summary
`static DocumentImpl` `getModifiedDocument()`
`static DocumentTrigger` `getRunningTrigger()`
`static Txn` `getTransaction()`
`static int` `getTriggerRunningState()`
`static void` `setTransaction(Txn transaction)`
`static void` `setTriggerRunningState(int state, DocumentTrigger trigger, DocumentImpl modifiedDocument)`
`static boolean` `verifyUniqueTriggerPerThreadBeforeFinish(DocumentTrigger trigger, DocumentImpl modifiedDocument)`
`static boolean` `verifyUniqueTriggerPerThreadBeforePrepare(DocumentTrigger trigger, DocumentImpl modifiedDocument)`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NO_TRIGGER_RUNNING

    public static final int NO_TRIGGER_RUNNING

See Also:
  Constant Field Values

### TRIGGER_RUNNING_PREPARE

    public static final int TRIGGER_RUNNING_PREPARE

See Also:
  Constant Field Values

### TRIGGER_RUNNING_FINISH

    public static final int TRIGGER_RUNNING_FINISH

See Also:
  Constant Field Values

Constructor Detail

### TriggerStatePerThread

    public TriggerStatePerThread()

Method Detail

### verifyUniqueTriggerPerThreadBeforePrepare

    public static boolean verifyUniqueTriggerPerThreadBeforePrepare(DocumentTrigger trigger,
                                                                    DocumentImpl modifiedDocument)

### verifyUniqueTriggerPerThreadBeforeFinish

    public static boolean verifyUniqueTriggerPerThreadBeforeFinish(DocumentTrigger trigger,
                                                                   DocumentImpl modifiedDocument)

  Parameters:
    `modifiedDocument` - the document whose modification triggered the trigger

### getTriggerRunningState

    public static int getTriggerRunningState()

### getRunningTrigger

    public static DocumentTrigger getRunningTrigger()

### setTriggerRunningState

    public static void setTriggerRunningState(int state,
                                              DocumentTrigger trigger,
                                              DocumentImpl modifiedDocument)

### getTransaction

    public static Txn getTransaction()

### setTransaction

    public static void setTransaction(Txn transaction)

### getModifiedDocument

    public static DocumentImpl getModifiedDocument()

Copyright (C) Wolfgang Meier. All rights reserved.