public class Trigger extends GeneratedTrigger
Trigger allows the definition of schedules for the automatic execution of Jobs and BatchJobs. There
are several attributes which allow you to define the rules, when the Trigger should fire and therefore
the assigned Job/BatchJob will be executed. First of all the following six attributes allow the definition of time
components:
Trigger will be fired every
time the related TriggerTaskRunner activates it. The specified time attributes
are either interpreted as relative or absolute values depending on the value of GeneratedTrigger.isRelative().
Some examples:
| Year | Month | Day | Hour | Minute | Second | relative | daysOfWeek | weekInterval | Description |
|---|---|---|---|---|---|---|---|---|---|
| -1 | -1 | -1 | 5 | 0 | 0 | false | --- | --- | every day at 5:00 |
| -1 | -1 | -1 | 12 | 12 | 12 | false | --- | --- | every 12th of a month at 12:12:12 |
| -1 | -1 | -1 | 6 | 0 | 0 | true | --- | --- | every six hours |
| -1 | -1 | -1 | 12 | 0 | 0 | false | MO,WE,FR | --- | every Monday, Wednesday, Friday at 12:00 |
| -1 | -1 | -1 | 12 | 0 | 0 | false | MO,WE,FR | 2 | every 2 weeks, Monday, Wednesday, Friday at 12:00 |
| Modifier and Type | Class and Description |
|---|---|
static class |
Trigger.Mode |
GenericItem.GenericItemImplLocalizableItem.LocalizableItemImplExtensibleItem.ExtensibleItemImplItem.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationExceptionACTIVATIONTIME, ACTIVE, CRONEXPRESSION, CRONJOB, CRONJOBHANDLER, DATERANGE, DAY, DAYSOFWEEK, DEFAULT_INITIAL_ATTRIBUTES, HOUR, JOB, JOBHANDLER, MAXACCEPTABLEDELAY, MINUTE, MONTH, RELATIVE, SECOND, WEEKINTERVAL, YEARLANGUAGE_FALLBACK_ENABLED_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPEimpl, tenant| Constructor and Description |
|---|
Trigger() |
| Modifier and Type | Method and Description |
|---|---|
void |
activate()
Deprecated.
as of release 4.3, please use
TriggerService.activate(de.hybris.platform.cronjob.model.TriggerModel) |
protected Calendar |
calculateFixedTime(Calendar relativeTo) |
protected Calendar |
calculateNextTimeRelativeMode(Calendar relativeTo) |
protected Item |
createItem(SessionContext ctx,
ComposedType type,
Item.ItemAttributeMap allAttributes)
Has to be implemented for each concrete subtype of item.
|
protected CronJob |
getCronJobForExecution()
If cronJob is null and job is a triggerable job, make a new cronJob
|
long |
getNextTime(Calendar relativeTo)
Deprecated.
as of release 4.3, please use
TriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar) |
long |
getNextTime(long time)
Deprecated.
as of release 4.3, please use
TriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar) |
static int |
getPulseseconds() |
String |
getTimeTable(SessionContext ctx)
Deprecated.
use
TriggerModel.getTimeTable() instead. |
protected boolean |
hasDay() |
protected boolean |
hasDayOfWeek() |
protected boolean |
hasHour() |
protected boolean |
hasMinute() |
protected boolean |
hasMonth() |
protected boolean |
hasSecond() |
protected boolean |
hasWeekInterval() |
protected boolean |
hasYear() |
void |
setActivationTime(SessionContext ctx,
Date activationTime)
Deprecated.
use
GeneratedTrigger.setCronExpression(String) to cover scheduling |
void |
setMaxAcceptableDelay(int seconds)
Generated method - Setter of the
Trigger.maxAcceptableDelay attribute. |
void |
setMaxAcceptableDelay(Integer value)
Generated method - Setter of the
Trigger.maxAcceptableDelay attribute. |
void |
setMaxAcceptableDelay(SessionContext ctx,
int value)
Generated method - Setter of the
Trigger.maxAcceptableDelay attribute. |
void |
setMaxAcceptableDelay(SessionContext ctx,
Integer value)
The field MaxAcceptableDelayS describes how long after the job was scheduled can it still be triggered.
|
String |
toString()
Returns the
String representation of the Trigger. |
getActivationTime, getActivationTime, getCronExpression, getCronExpression, getCronJob, getCronJob, getDateRange, getDateRange, getDay, getDay, getDayAsPrimitive, getDayAsPrimitive, getDaysOfWeek, getDaysOfWeek, getDefaultAttributeModes, getHour, getHour, getHourAsPrimitive, getHourAsPrimitive, getJob, getJob, getMaxAcceptableDelay, getMaxAcceptableDelay, getMaxAcceptableDelayAsPrimitive, getMaxAcceptableDelayAsPrimitive, getMinute, getMinute, getMinuteAsPrimitive, getMinuteAsPrimitive, getMonth, getMonth, getMonthAsPrimitive, getMonthAsPrimitive, getSecond, getSecond, getSecondAsPrimitive, getSecondAsPrimitive, getWeekInterval, getWeekInterval, getWeekIntervalAsPrimitive, getWeekIntervalAsPrimitive, getYear, getYear, getYearAsPrimitive, getYearAsPrimitive, isActive, isActive, isActiveAsPrimitive, isActiveAsPrimitive, isRelative, isRelative, isRelativeAsPrimitive, isRelativeAsPrimitive, setActivationTime, setActive, setActive, setActive, setActive, setCronExpression, setCronExpression, setCronJob, setCronJob, setDateRange, setDateRange, setDay, setDay, setDay, setDay, setDaysOfWeek, setDaysOfWeek, setHour, setHour, setHour, setHour, setJob, setJob, setMinute, setMinute, setMinute, setMinute, setMonth, setMonth, setMonth, setMonth, setRelative, setRelative, setRelative, setRelative, setSecond, setSecond, setSecond, setSecond, setWeekInterval, setWeekInterval, setWeekInterval, setWeekInterval, setYear, setYear, setYear, setYeargetInitialProperties, getNonInitialAttributesgetAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedPropertycreateNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setPropertyaddLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addNegativePermission, addPermission, addPositivePermission, assureExtensionsLoaded, changeTypeAfterCreation, checkConstraint, checkItemPermission, checkMandatoryAttribute, checkMandatoryAttribute, checkPermission, checkPermission, checkRemovable, clearPermission, compareTo, ctx, doAfterRemove, doBeforeRemove, equals, getAccessorFor, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributesInternal, getAllLinkedItems, getAndCheckCacheBoundItem, getAttribute, getAttribute, getCacheBoundItem, getComposedType, getComposedTypePK, getCreationTime, getCurrentlyRemovingCount, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItemsCount, getLinkedItemsCount, getLinkedItemsCount, getModificationTime, getNegativePermissions, getOwner, getPermissionMap, getPermissions, getPersistenceVersion, getPK, getPositivePermissions, getRestrictedPrincipals, getSession, getSyncObject, getTenant, getTransientObject, getTransientObjectMap, hashCode, hasRegisteredClassAccessorFor, internal_registerClassAccessorFor, internal_registerNonClassAccessorFor, invalidateLocalCaches, isAlive, isCacheBound, isCurrentlyRemoving, isCurrentlyRemoving, isEmptyRelationValue, isInCreate, isInstanceOf, isItemCheckBeforeRemoveableDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, readResolve, refreshRemote, registerAccessFor, registerAccessFor, registerJaloInvalidationListeners, remove, remove, removeItemCollection, removeItemCollection, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinks, removePartOfItems, removePartOfItems, setAllAttributes, setAllAttributes, setAllAttributesInternal, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAttribute, setAttribute, setAttributeFromString, setAttributeFromString, setCacheBound, setComposedType, setCreationTime, setImplementation, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setModificationTime, setNonInitialAttributes, setOwner, setPermissionsByMap, setTransientObject, setUseTA, useTA, writeReplacegetImplementation, setTenantprotected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException
ItemComposedType.newInstance(Map).
In case this method uses any of the attribute values during creation it is required to override
Item.getNonInitialAttributes(SessionContext, ItemAttributeMap) too.
Sn example:
public static final String MY_ATTRIBUTE = "someAttribute"; ... protected Item createItem(SessionContext
ctx, ComposedType type, Map allAttributes ) throws JaloBusinessException { MyManager man = ... return
man.createMyItem( (String)allAttributes.get(MY_ATTRIBUTE) );
// here MY_ATTRIBUTE is used for creation, so it must not be set again } protected Map getNonInitialAttributes(
SessionContext ctx, Map allAttributes ) { // let superclass remove its own initial attributes Map ret =
super.getNonInitialAttributes( ctx, allAttributes );
// remove MY_ATTRIBUTE from all attributes since if has already been set ret.remove(MY_ATTRIBUTE); return ret; }
createItem in class GeneratedTriggerctx - the current session context which this item is created withintype - the actual item type ( since subtypes may not provide a own jalo class this may be different from the
type which this method was implemented for )JaloBusinessException - indicates an error during creation - any changes will be rollbacked@Deprecated public void activate()
TriggerService.activate(de.hybris.platform.cronjob.model.TriggerModel)Job using the assigned CronJob if the next activation time ((@link
#getActivationTime()} is less or equal than the current system time.protected boolean hasYear()
protected boolean hasMonth()
protected boolean hasDay()
protected boolean hasDayOfWeek()
protected boolean hasWeekInterval()
protected boolean hasHour()
protected boolean hasMinute()
protected boolean hasSecond()
@Deprecated public long getNextTime(long time)
TriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar)Trigger in relation to the specified time.time - the time for which the next activation time should be calculatedTrigger in relation to the specified time@Deprecated public long getNextTime(Calendar relativeTo)
TriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar)Trigger in relation to the specified calendar.
Use this method e.g. for different first day of week modes.
relativeTo - the calendar which the next activation time should be calculated relatively forTrigger in relation to the specified timepublic String toString()
String representation of the Trigger. String format:, active=true|false, [second=xy,][minute=xy,][hour=xy,][day=xy,][month=xy,][year=xy,][relative=xy,][days of week=xy,][week interval=xy,][date range=xy,] next activationtime=xy ]protected CronJob getCronJobForExecution()
@Deprecated public void setActivationTime(SessionContext ctx, Date activationTime)
GeneratedTrigger.setCronExpression(String) to cover schedulingTrigger.setActivationTime in class GeneratedTriggerctx - the SessionContext, which will be usedactivationTime - the new activation time@Deprecated public String getTimeTable(SessionContext ctx)
TriggerModel.getTimeTable() instead.ctx - the session contextpublic void setMaxAcceptableDelay(SessionContext ctx, Integer value)
setMaxAcceptableDelay in class GeneratedTriggerctx - the session contextvalue - the potential new valuepublic void setMaxAcceptableDelay(Integer value)
GeneratedTriggerTrigger.maxAcceptableDelay attribute.setMaxAcceptableDelay in class GeneratedTriggervalue - the maxAcceptableDelay - the maximum acceptable delay (s) in which the job can be triggered, after which it is
ignored.public void setMaxAcceptableDelay(SessionContext ctx, int value)
GeneratedTriggerTrigger.maxAcceptableDelay attribute.setMaxAcceptableDelay in class GeneratedTriggervalue - the maxAcceptableDelay - the maximum acceptable delay (s) in which the job can be triggered, after which it is
ignored.public void setMaxAcceptableDelay(int seconds)
GeneratedTriggerTrigger.maxAcceptableDelay attribute.setMaxAcceptableDelay in class GeneratedTriggerseconds - the maxAcceptableDelay - the maximum acceptable delay (s) in which the job can be triggered, after which it is
ignored.public static int getPulseseconds()
Copyright © 2017 SAP SE. All Rights Reserved.