#triggerCommit
and #triggerFlush
. This Trigger class works around an inconvenient situation when using a general ValueHolder as trigger channel of a BufferedValueModel. BufferedValueHolder performs commit and flush events only if the trigger channel value reports a change. And a ValueHolder doesn't report a change if #setValue
tries to set the current value. For example if you set Boolean.TRUE
twice, the latter doesn't fire a property change event. The methods #triggerCommit
and #triggerFlush
check for the current state and guarantee that the appropriate PropertyChangeEvent
is fired. On the other hand, the implementation minimizes the number of events necessary to commit or flush buffered values.
Constraints: The value is of type Boolean
.
The following example delays the commit of a buffered value:
ValueModel subject = new ValueHolder(); Trigger trigger = new Trigger(); BufferedValueModel buffer = new BufferedValueModel(subject, trigger); buffer.setValue("value"); ... trigger.triggerCommit();@author Karsten Lentzsch @version $Revision: 1.5 $ @see BufferedValueModel Copyright (c) 2002-2005 JGoodies Karsten Lentzsch. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: o Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. o Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. o Neither the name of JGoodies Karsten Lentzsch nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
DatabasetTrigger
defines the trigger methods associated with a database. They provide a mechanism to track the database definition operations used to manage the lifecycle of the database itself, as well as the record operations used to modify the contents of the database. The following table captures the relationship between the database granularity operations and their associated trigger methods.
Database Operation | Trigger Method |
{@link Environment#openDatabase Environment.openDatabase} resulting inthe creation of a new primary database. Or the first open of a database for write operations. | {@link #open open} |
{@link Database#close Database.close} the close of a database that wasopened for write operations. | {@link #close close} |
{@link Environment#removeDatabase Environment.removeDatabase} | {@link #remove remove} |
{@link Environment#truncateDatabase Environment.truncateDatabase} | {@link #truncate truncate} |
{@link Environment#renameDatabase Environment.renameDatabase} | {@link #rename truncate} |
The trigger methods {@link #put put} and {@link #delete delete} are used totrack all record operations on the database.
A trigger method takes a transaction as its first argument. If the environment is not transactional, the argument is null. In all other cases, it's a valid transaction ( {@link Transaction#isValid() Transaction.isValid}is true) and the trigger can use this transaction to make it's own set of accompanying changes.
If the invocation of a trigger results in a runtime exception, the transaction (if one was associated with the method) is invalidated and any subsequent triggers associated with the operation are skipped. It's the caller's responsibility to handle the exception and abort the invalidated transaction. If the exception is thrown during the replay of a transaction on a replica in an HA application, the environment is invalidated and a new environment handle must be created.
A Trigger is associated with a database via {@link DatabaseConfig#setTriggers DatabaseConfig.setTriggers}.
Note that all subtypes of Trigger must be serializable, because they are stored persistently in the environment.To register a custom {@link Trigger} from a plugin,put {@link Extension} on your {@link TriggerDescriptor} class. @author Kohsuke Kawaguchi
Each Trigger instance will be invoked within the same process in which it was registered.
Trigger should be Serializable if it is to be used on a distributed {@code ManagedScheduledExecutorService}.
Example:
/ * A trigger that only returns a single date. */ public class SingleDateTrigger implements Trigger { private Date fireTime; public TriggerSingleDate(Date newDate) { fireTime = newDate; } public Date getNextRunTime( LastExecution lastExecutionInfo, Date taskScheduledTime) { if(taskScheduledTime.after(fireTime)) { return null; } return fireTime; } public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { return scheduledRunTime.after(fireTime); } } / * A fixed-rate trigger that will skip any runs if * the latencyAllowance threshold is exceeded (the task * ran too late). */ public class TriggerFixedRateLatencySensitive implements Trigger { private Date startTime; private long delta; private long latencyAllowance; public TriggerFixedRateLatencySensitive(Date startTime, long delta, long latencyAllowance) { this.startTime = startTime; this.delta = delta; this.latencyAllowance = latencyAllowance; } public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { if(lastExecutionInfo==null) { return startTime; } return new Date(lastExecutionInfo.getScheduledStart().getTime() + delta); } public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { return System.currentTimeMillis() - scheduledRunTime.getTime() > latencyAllowance; } }
@since 1.0
#triggerCommit
and #triggerFlush
. This Trigger class works around an inconvenient situation when using a general ValueHolder as trigger channel of a BufferedValueModel. BufferedValueHolder performs commit and flush events only if the trigger channel value reports a change. And a ValueHolder doesn't report a change if #setValue
tries to set the current value. For example if you set Boolean.TRUE
twice, the latter doesn't fire a property change event. The methods #triggerCommit
and #triggerFlush
check for the current state and guarantee that the appropriate PropertyChangeEvent
is fired. On the other hand, the implementation minimizes the number of events necessary to commit or flush buffered values.
Constraints: The value is of type Boolean
.
The following example delays the commit of a buffered value:
ValueModel subject = new ValueHolder(); Trigger trigger = new Trigger(); BufferedValueModel buffer = new BufferedValueModel(subject, trigger); buffer.setValue("value"); ... trigger.triggerCommit();@author Karsten Lentzsch @version $Revision: 1.5 $ @see BufferedValueModel Copyright (c) 2002-2005 JGoodies Karsten Lentzsch. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: o Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. o Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. o Neither the name of JGoodies Karsten Lentzsch nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The abstract class for any object that can be used as a trigger for a binding. This ensures that trigger conform to certain minimum requirements. Namely, triggers need to be hashable.
@since 3.1 The payload of all scheduled events, be they arbitrarily scheduled or one of the built-in @Every() schedules. Note that the presence of this superclass implies that the following observation is possible: public void doSomething(@Observes @Every Trigger e)
Such an observation is valid, and will respond to every single scheduled event fired (including the built in events).
@author Peter RoyleTrigger
that embodies the desired condition, and invoking {@link org.mitre.sim.Entity#waitForActionOrTrigger(Trigger) waitForActionOrTrigger}. See the summary section, "Triggers."
Copyright © 2003-2004 The MITRE Corporation
The base abstract class to be extended by all Trigger
s.
Triggers
s have a name and group associated with them, which should uniquely identify them within a single {@link Scheduler}
.
Trigger
s are the 'mechanism' by which Job
s are scheduled. Many Trigger
s can point to the same Job
, but a single Trigger
can only point to one Job
.
Triggers can 'send' parameters/data to Job
s by placing contents into the JobDataMap
on the Trigger
.
beforeXxx()
will stop the transaction and return HTTP 400 BadRequest to the client. Throwing {@link SqlResourceException} from a beforeXxx()
orafterXxx()
will return HTTP 500 Internal Server Error to the client.
@author Mark Sawers
@see AbstractTrigger
Ready-to-use triggers are made available by several components such as Buttons or Menus. @see Button#triggerClick @see MenuItem#triggerClick @see WindowInterceptor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|