Package de.hybris.platform.cronjob.jalo
Class Trigger
- All Implemented Interfaces:
Serializable,Comparable
A
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:
- Second: 0 to 59, or -1 for any
- Minute: 0 to 59, or -1 for any
- Hour: 0 to 23, or -1 for any
- Day: 1 to 31, or -1 for any
- Month: 1 to 12, or -1 for any
- Year: for example 2004, or -1 for any
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 |
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class de.hybris.platform.jalo.GenericItem
GenericItem.GenericItemImplNested classes/interfaces inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LocalizableItem.LocalizableItemImplNested classes/interfaces inherited from class de.hybris.platform.jalo.ExtensibleItem
ExtensibleItem.ExtensibleItemImplNested classes/interfaces inherited from class de.hybris.platform.jalo.Item
Item.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationException -
Field Summary
Fields inherited from class de.hybris.platform.cronjob.jalo.GeneratedTrigger
ACTIVATIONTIME, ACTIVE, CRONEXPRESSION, CRONJOB, CRONJOBHANDLER, DATERANGE, DAY, DAYSOFWEEK, DEFAULT_INITIAL_ATTRIBUTES, HOUR, JOB, JOBHANDLER, MAXACCEPTABLEDELAY, MINUTE, MONTH, RELATIVE, SECOND, WEEKINTERVAL, YEARFields inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LANGUAGE_FALLBACK_ENABLEDFields inherited from class de.hybris.platform.jalo.Item
_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, HJMPTS, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPEFields inherited from class de.hybris.platform.util.BridgeAbstraction
impl, tenant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Deprecated.protected CalendarcalculateFixedTime(Calendar relativeTo) protected CalendarcalculateNextTimeRelativeMode(Calendar relativeTo) protected ItemcreateItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) Has to be implemented for each concrete subtype of item.protected CronJobIf cronJob is null and job is a triggerable job, make a new cronJoblonggetNextTime(long time) Deprecated.since ages - as of release 4.3, please useTriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar)longgetNextTime(Calendar relativeTo) Deprecated.since ages - as of release 4.3, please useTriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar)static intDeprecated.since ages - useTriggerModel.getTimeTable()instead.protected booleanhasDay()protected booleanprotected booleanhasHour()protected booleanprotected booleanhasMonth()protected booleanprotected booleanprotected booleanhasYear()voidsetActivationTime(SessionContext ctx, Date activationTime) Deprecated.since ages - useGeneratedTrigger.setCronExpression(String)to cover schedulingvoidsetMaxAcceptableDelay(int seconds) Generated method - Setter of theTrigger.maxAcceptableDelayattribute.voidsetMaxAcceptableDelay(SessionContext ctx, int value) Generated method - Setter of theTrigger.maxAcceptableDelayattribute.voidsetMaxAcceptableDelay(SessionContext ctx, Integer value) The field MaxAcceptableDelayS describes how long after the job was scheduled can it still be triggered.voidsetMaxAcceptableDelay(Integer value) Generated method - Setter of theTrigger.maxAcceptableDelayattribute.toString()Returns theStringrepresentation of theTrigger.Methods inherited from class de.hybris.platform.cronjob.jalo.GeneratedTrigger
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, setYearMethods inherited from class de.hybris.platform.jalo.GenericItem
getImplementation, getInitialProperties, getNonInitialAttributes, getRelatedItems, getRelatedItems, setRelatedItemsMethods inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedPropertyMethods inherited from class de.hybris.platform.jalo.ExtensibleItem
createNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setPropertyMethods inherited from class de.hybris.platform.jalo.Item
addLinkedItems, 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, getPartOfRemovedSessionMarker, 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, isMarkModifiedDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, notifyManagerAboutItemRemoval, readResolve, 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, suppressRelation, useTA, writeReplaceMethods inherited from class de.hybris.platform.util.BridgeAbstraction
setTenant
-
Constructor Details
-
Trigger
public Trigger()
-
-
Method Details
-
createItem
protected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException Description copied from class:ItemHas to be implemented for each concrete subtype of item. This method is responsible for creating a new item instance ( by calling managers, ejb homes, etc. ) duringComposedType.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; }- Overrides:
createItemin classGeneratedTrigger- Parameters:
ctx- 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 )- Returns:
- the new item instance
- Throws:
JaloBusinessException- indicates an error during creation - any changes will be rollbacked
-
activate
Deprecated.since ages - as of release 4.3, please useTriggerService.activate(de.hybris.platform.cronjob.model.TriggerModel)Executes the assignedJobusing the assignedCronJobif the next activation time ((@link #getActivationTime()} is less or equal than the current system time. -
calculateNextTimeRelativeMode
-
calculateFixedTime
-
hasYear
protected boolean hasYear() -
hasMonth
protected boolean hasMonth() -
hasDay
protected boolean hasDay() -
hasDayOfWeek
protected boolean hasDayOfWeek() -
hasWeekInterval
protected boolean hasWeekInterval() -
hasHour
protected boolean hasHour() -
hasMinute
protected boolean hasMinute() -
hasSecond
protected boolean hasSecond() -
getNextTime
Deprecated.since ages - as of release 4.3, please useTriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar)Returns the next activation time for theTriggerin relation to the specified time.- Parameters:
time- the time for which the next activation time should be calculated- Returns:
- the next activation time for the
Triggerin relation to the specified time
-
getNextTime
Deprecated.since ages - as of release 4.3, please useTriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar)Returns the next activation time for theTriggerin relation to the specified calendar.Use this method e.g. for different first day of week modes.
- Parameters:
relativeTo- the calendar which the next activation time should be calculated relatively for- Returns:
- the next activation time for the
Triggerin relation to the specified time
-
toString
Returns theStringrepresentation of theTrigger. String format:
Trigger[ cronjob=, 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 ] -
getCronJobForExecution
If cronJob is null and job is a triggerable job, make a new cronJob- Returns:
- The (possibly new) cronJob
-
setActivationTime
@Deprecated(since="ages", forRemoval=false) public void setActivationTime(SessionContext ctx, Date activationTime) Deprecated.since ages - useGeneratedTrigger.setCronExpression(String)to cover schedulingSets the next activation time of theTrigger.- Overrides:
setActivationTimein classGeneratedTrigger- Parameters:
ctx- theSessionContext, which will be usedactivationTime- the new activation time
-
getTimeTable
Deprecated.since ages - useTriggerModel.getTimeTable()instead.Returns a localized text, representing the timetable of this trigger.- Parameters:
ctx- the session context- Returns:
- the localized timeTable text
-
setMaxAcceptableDelay
The field MaxAcceptableDelayS describes how long after the job was scheduled can it still be triggered. If set to minus one, the value is ignored. If set toseconds, then this job can only be triggered up to seconds after it should have run. This is to prevent the following scenario: a heavy job is scheduled to run at midnight, but the job engine crashes before hand. When the job engine restarts at say 9am the next day, the heavy job is then run. By saying that this job can only run up to (say) 1 hour after its scheduled time, we prevent the heavy job running in the day time. Return true if the conditions are appropriate for the job to run. If provided value is null, then internally -1 one is passed in which further is ignored. - Overrides:
setMaxAcceptableDelayin classGeneratedTrigger- Parameters:
ctx- the session contextvalue- the potential new value
-
setMaxAcceptableDelay
Description copied from class:GeneratedTriggerGenerated method - Setter of theTrigger.maxAcceptableDelayattribute.- Overrides:
setMaxAcceptableDelayin classGeneratedTrigger- Parameters:
value- the maxAcceptableDelay - the maximum acceptable delay (s) in which the job can be triggered, after which it is ignored.
-
setMaxAcceptableDelay
Description copied from class:GeneratedTriggerGenerated method - Setter of theTrigger.maxAcceptableDelayattribute.- Overrides:
setMaxAcceptableDelayin classGeneratedTriggervalue- the maxAcceptableDelay - the maximum acceptable delay (s) in which the job can be triggered, after which it is ignored.
-
setMaxAcceptableDelay
public void setMaxAcceptableDelay(int seconds) Description copied from class:GeneratedTriggerGenerated method - Setter of theTrigger.maxAcceptableDelayattribute.- Overrides:
setMaxAcceptableDelayin classGeneratedTrigger- Parameters:
seconds- the maxAcceptableDelay - the maximum acceptable delay (s) in which the job can be triggered, after which it is ignored.
-
getPulseseconds
public static int getPulseseconds()
-
TriggerService.activate(de.hybris.platform.cronjob.model.TriggerModel)