Package de.hybris.platform.cronjob.jalo
Class Trigger
- java.lang.Object
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable
public class Trigger extends GeneratedTrigger
ATrigger
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 theTrigger
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 relatedTriggerTaskRunner
activates it. The specified time attributes are either interpreted as relative or absolute values depending on the value ofGeneratedTrigger.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Trigger.Mode
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.GenericItem
GenericItem.GenericItemImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LocalizableItem.LocalizableItemImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.ExtensibleItem
ExtensibleItem.ExtensibleItemImpl
-
Nested 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, YEAR
-
Fields inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LANGUAGE_FALLBACK_ENABLED
-
Fields 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, TYPE
-
Fields inherited from class de.hybris.platform.util.BridgeAbstraction
impl, tenant
-
-
Constructor Summary
Constructors Constructor Description Trigger()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
activate()
Deprecated.since ages - as of release 4.3, please useTriggerService.activate(de.hybris.platform.cronjob.model.TriggerModel)
protected java.util.Calendar
calculateFixedTime(java.util.Calendar relativeTo)
protected java.util.Calendar
calculateNextTimeRelativeMode(java.util.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 cronJoblong
getNextTime(long time)
Deprecated.since ages - as of release 4.3, please useTriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar)
long
getNextTime(java.util.Calendar relativeTo)
Deprecated.since ages - as of release 4.3, please useTriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar)
static int
getPulseseconds()
java.lang.String
getTimeTable(SessionContext ctx)
Deprecated.since ages - useTriggerModel.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, java.util.Date activationTime)
Deprecated.since ages - useGeneratedTrigger.setCronExpression(String)
to cover schedulingvoid
setMaxAcceptableDelay(int seconds)
Generated method - Setter of theTrigger.maxAcceptableDelay
attribute.void
setMaxAcceptableDelay(SessionContext ctx, int value)
Generated method - Setter of theTrigger.maxAcceptableDelay
attribute.void
setMaxAcceptableDelay(SessionContext ctx, java.lang.Integer value)
The field MaxAcceptableDelayS describes how long after the job was scheduled can it still be triggered.void
setMaxAcceptableDelay(java.lang.Integer value)
Generated method - Setter of theTrigger.maxAcceptableDelay
attribute.java.lang.String
toString()
Returns theString
representation 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, setYear
-
Methods inherited from class de.hybris.platform.jalo.GenericItem
getImplementation, getInitialProperties, getNonInitialAttributes, getRelatedItems, setRelatedItems
-
Methods 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, setLocalizedProperty
-
Methods inherited from class de.hybris.platform.jalo.ExtensibleItem
createNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setProperty
-
Methods 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, 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, useTA, writeReplace
-
Methods inherited from class de.hybris.platform.util.BridgeAbstraction
setTenant
-
-
-
-
Method Detail
-
createItem
protected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException
Description copied from class:Item
Has 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:
createItem
in 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 public void activate()
Deprecated.since ages - as of release 4.3, please useTriggerService.activate(de.hybris.platform.cronjob.model.TriggerModel)
Executes the assignedJob
using the assignedCronJob
if the next activation time ((@link #getActivationTime()} is less or equal than the current system time.
-
calculateNextTimeRelativeMode
protected java.util.Calendar calculateNextTimeRelativeMode(java.util.Calendar relativeTo)
-
calculateFixedTime
protected java.util.Calendar calculateFixedTime(java.util.Calendar relativeTo)
-
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 public long getNextTime(long time)
Deprecated.since ages - as of release 4.3, please useTriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar)
Returns the next activation time for theTrigger
in 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
Trigger
in relation to the specified time
-
getNextTime
@Deprecated public long getNextTime(java.util.Calendar relativeTo)
Deprecated.since ages - as of release 4.3, please useTriggerService.getNextTime(de.hybris.platform.cronjob.model.TriggerModel, Calendar)
Returns the next activation time for theTrigger
in 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
Trigger
in relation to the specified time
-
toString
public java.lang.String toString()
Returns theString
representation 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
protected CronJob getCronJobForExecution()
If cronJob is null and job is a triggerable job, make a new cronJob- Returns:
- The (possibly new) cronJob
-
setActivationTime
@Deprecated public void setActivationTime(SessionContext ctx, java.util.Date activationTime)
Deprecated.since ages - useGeneratedTrigger.setCronExpression(String)
to cover schedulingSets the next activation time of theTrigger
.- Overrides:
setActivationTime
in classGeneratedTrigger
- Parameters:
ctx
- theSessionContext
, which will be usedactivationTime
- the new activation time
-
getTimeTable
@Deprecated public java.lang.String getTimeTable(SessionContext ctx)
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
public void setMaxAcceptableDelay(SessionContext ctx, java.lang.Integer value)
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:
setMaxAcceptableDelay
in classGeneratedTrigger
- Parameters:
ctx
- the session contextvalue
- the potential new value
-
setMaxAcceptableDelay
public void setMaxAcceptableDelay(java.lang.Integer value)
Description copied from class:GeneratedTrigger
Generated method - Setter of theTrigger.maxAcceptableDelay
attribute.- Overrides:
setMaxAcceptableDelay
in classGeneratedTrigger
- Parameters:
value
- the maxAcceptableDelay - the maximum acceptable delay (s) in which the job can be triggered, after which it is ignored.
-
setMaxAcceptableDelay
public void setMaxAcceptableDelay(SessionContext ctx, int value)
Description copied from class:GeneratedTrigger
Generated method - Setter of theTrigger.maxAcceptableDelay
attribute.- Overrides:
setMaxAcceptableDelay
in classGeneratedTrigger
value
- 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:GeneratedTrigger
Generated method - Setter of theTrigger.maxAcceptableDelay
attribute.- Overrides:
setMaxAcceptableDelay
in 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()
-
-