public class TriggerDefinition
extends java.lang.Object
Triggers are non-static inner classes that may have data members. The initialization of those data members naturally occurs during construction. This means that only after construction can one be assured that the value of a trigger's data members is set to the expected default value. This means that every time a trigger is executed, that execution must occur on a newly constructed instance, so that the data member's default values will be correct.
This class stores the data needed to delegate the construction of a
Trigger
subclass to code that is executing that trigger. This is
complicated by the fact that triggers are implemented as non-static inner
classes of business logic classes. To instantiate a non-static inner class
it is required that the containing instance be available as an implicit
first parameter to the constructor.
The complexity of the instantiation is hidden in this class. The logic
can be found in getTrigger()
.
Modifier and Type | Field and Description |
---|---|
private java.lang.Class<?> |
cls
Specific subclass of
Trigger which implements the trigger. |
private java.lang.Object |
externalProgram
The external program instance where the trigger was defined.
|
private boolean |
fromExternalProgram
Flag indicating the trigger definition was created in an external program.
|
private boolean |
fullTrans
Determines if this trigger should start a full transaction.
|
private static java.util.logging.Logger |
LOG
Logger (this is JVM-wide rather than being context-local).
|
private java.lang.Object |
outer
Containing business logic instance (triggers are inner classes).
|
private Trigger |
trigger
Common case where there is a single trigger instance.
|
Constructor and Description |
---|
TriggerDefinition(java.lang.Class<?> cls,
java.lang.Object outer,
boolean fullTrans)
Constructor for inner class mode.
|
TriggerDefinition(Trigger trigger,
java.lang.Object outer,
boolean fullTrans)
Constructor for lambda mode.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getExternalProgram()
Get the external program instance where this trigger was defined.
|
Trigger |
getTrigger()
Construct a new instance of the trigger class that is defined by the
contained metadata.
|
boolean |
isFromExternalProgram()
Check if this trigger was created by an external program.
|
private static final java.util.logging.Logger LOG
private Trigger trigger
private java.lang.Class<?> cls
Trigger
which implements the trigger.private java.lang.Object outer
private java.lang.Object externalProgram
private boolean fullTrans
private final boolean fromExternalProgram
public TriggerDefinition(java.lang.Class<?> cls, java.lang.Object outer, boolean fullTrans)
cls
- The specific Trigger
subclass that implements the
trigger logic.outer
- The instance of the containing class for the trigger. This
is needed since all triggers are implemented as non-static
inner classes.fullTrans
- true
if the trigger should start a full
transaction, false
if the trigger should
create a sub-transaction.public TriggerDefinition(Trigger trigger, java.lang.Object outer, boolean fullTrans)
trigger
- The specific Trigger
instance that implements the
trigger logic.outer
- The instance of the containing class for the trigger.fullTrans
- true
if the trigger should start a full
transaction, false
if the trigger should
create a sub-transaction.public Trigger getTrigger()
null
.public java.lang.Object getExternalProgram()
public boolean isFromExternalProgram()
fromExternalProgram
flag.