public abstract class Job extends GeneratedJob
Job implements tasks, whose execution can be scheduled and which can be executed both synchronous
and asynchronous (by running in a separated Thread). The Job just implements all the logic
of the task it implements, it stores no "runtime" information. The runtime information (for example session
parameters (user, language, currency), import source file, or execution result) are stored in the
CronJob instance, which is passed to the Job when it is started.
Apart from the normal execution of the task the Job implements, a Job can support the
undo-mechanism, which allows to undo all changes, which have been performed by the previous execution of the
Job and the specified CronJob.| Modifier and Type | Class and Description |
|---|---|
protected static class |
Job.JobFileLogContainer |
static class |
Job.Synchronicity |
GenericItem.GenericItemImplLocalizableItem.LocalizableItemImplExtensibleItem.ExtensibleItemImplItem.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationException| Modifier and Type | Field and Description |
|---|---|
static String |
CTX_CURRENTCRONJOB
Name of the
SessionContext attribute which contains the CronJob instance. |
static String |
CTX_CURRENTJOB
Name of the
SessionContext attribute which contains the Job instance. |
ACTIVE, ALTERNATIVEDATASOURCEID, CHANGERECORDINGENABLED, CODE, CRONJOBS, CRONJOBSHANDLER, DEFAULT_INITIAL_ATTRIBUTES, EMAILADDRESS, EMAILNOTIFICATIONTEMPLATE, ERRORMODE, LOGLEVELDATABASE, LOGLEVELFILE, LOGTODATABASE, LOGTOFILE, NODEGROUP, NODEID, PRIORITY, REMOVEONEXIT, REQUESTABORT, REQUESTABORTSTEP, RESTRICTIONS, RESTRICTIONSHANDLER, RETRY, SENDEMAIL, SESSIONCONTEXTVALUES, SESSIONCURRENCY, SESSIONLANGUAGE, SESSIONUSER, SINGLEEXECUTABLE, TRIGGERS, TRIGGERSHANDLERLANGUAGE_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 |
|---|
Job() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canPerform(CronJob cronJob)
Deprecated.
no available counterpart in servicelayer
|
protected boolean |
canUndo(CronJob cronJob)
Deprecated.
no counterpart in servicelayer available
|
protected void |
checkRemovable(SessionContext ctx)
Checks whether or not this it may be removed or not.
|
protected void |
configureCronjob(CronJob cronjob)
Deprecated.
use
CronJobFactory mechanism instead, refer to
appropriate wiki document |
protected Item |
createItem(SessionContext ctx,
ComposedType type,
Item.ItemAttributeMap allAttributes)
Has to be implemented for each concrete subtype of item.
|
protected CronJobLogListener.CronJobLogContext |
createLogContext(CronJob cronjob) |
void |
debug(String message)
Deprecated.
|
void |
error(String message)
Deprecated.
|
void |
fatal(String message)
Deprecated.
|
protected Map<String,String> |
getConfigAttributes(CronJob cronjob)
Deprecated.
use
CronJobFactory mechanism instead, refer to
appropriate wiki document |
Collection<CronJob> |
getCronJobsByCode(SessionContext ctx,
String code)
Deprecated.
use
CronJobService.getCronJob(String) instead |
Collection<CronJob> |
getCronJobsByCode(String code)
Deprecated.
use
CronJobService.getCronJob(String) instead |
protected static Job.JobFileLogContainer |
getCurrentLogContainer() |
protected Level |
getEffectiveLogLevel(CronJob cronjob) |
protected Item.ItemAttributeMap |
getNonInitialAttributes(SessionContext ctx,
Item.ItemAttributeMap allAttributes)
The default implementation of
GenericItem.getNonInitialAttributes(SessionContext, Item.ItemAttributeMap ) assures
that the 'registered initial' properties GenericItem.getInitialProperties(JaloSession, Item.ItemAttributeMap ) will
be removed from the 'non initial map'. |
void |
info(String message)
Deprecated.
|
boolean |
isAbortable(CronJob conJob)
Deprecated.
|
boolean |
isDebugEnabled()
Deprecated.
|
boolean |
isEnabledFor(Level level)
Deprecated.
|
boolean |
isErrorEnabled()
Deprecated.
|
boolean |
isInfoEnabled()
Deprecated.
|
boolean |
isPerformable(CronJob cronJob)
Deprecated.
|
boolean |
isPerformable(CronJob cronJob,
int clusternode)
Deprecated.
|
boolean |
isUndoable(CronJob cronJob)
Deprecated.
obsolete feature won't be supported in the future
|
boolean |
isWarnEnabled()
Deprecated.
|
protected static boolean |
jobIsCurrentlyRunning() |
void |
log(String message,
Level level) |
protected void |
logToFile(String message,
Level level)
Proxy method to write cronjob logs to file too.
|
void |
perform(CronJob cronJob)
Deprecated.
|
void |
perform(CronJob cronJob,
boolean synchronous)
Deprecated.
|
void |
perform(CronJob cronJob,
Job.Synchronicity synchronousType)
Deprecated.
|
protected abstract CronJob.CronJobResult |
performCronJob(CronJob cronJob)
Deprecated.
|
protected AfterCronJobFinishedEvent |
prepareAfterFinishEvent(CronJob cj,
boolean synchronous) |
protected BeforeCronJobStartEvent |
prepareBeforeStartEvent(CronJob cj,
boolean synchronous) |
void |
remove(SessionContext ctx)
First all assigned
CronJobs were removed, than the Job itself. |
protected static void |
saveToLogFile(Job.JobFileLogContainer container,
CronJob cronJob) |
protected void |
sendFinishedEvent(AfterCronJobFinishedEvent event,
CronJob.CronJobResult result) |
protected void |
sendStartEvent(BeforeCronJobStartEvent event) |
void |
setCode(SessionContext ctx,
String code)
Generated method - Setter of the
Job.code attribute. |
void |
setCronJobs(SessionContext ctx,
Collection<CronJob> cronJobs)
Deprecated.
not supported anymore
|
protected static void |
setCurrentLogContainer(Job.JobFileLogContainer logContainer) |
void |
setNonInitialAttributes(SessionContext ctx,
Item item,
Item.ItemAttributeMap nonInitialAttributes)
Sets all attributes which could not be set during
Item.createItem(SessionContext, ComposedType, ItemAttributeMap). |
protected JaloSession |
startOwnSession(CronJob cronJob)
Activates a own session for executing the job.
|
protected void |
stopOwnSession(JaloSession previousSession,
CronJob cronJob)
Deactivates the own session and re-activates the previous session if available.
|
protected void |
switchDataSource(CronJob cronjob) |
void |
undo(CronJob cronJob)
Deprecated.
obsolete feature won't be supported in the future
|
void |
undo(CronJob cronJob,
boolean synchronous)
Deprecated.
obsolete feature won't be supported in the future
|
protected CronJob.CronJobResult |
undoCronJob(CronJob cronJob)
Deprecated.
this feature is not available since 4.3
|
protected void |
unsetAlternativeDataSource() |
protected static void |
unsetCurrentLogContainer() |
void |
warn(String message)
Deprecated.
|
addToRestrictions, addToRestrictions, addToTriggers, addToTriggers, getAlternativeDataSourceID, getAlternativeDataSourceID, getCode, getCode, getCronJobs, getCronJobs, getDefaultAttributeModes, getEmailAddress, getEmailAddress, getEmailNotificationTemplate, getEmailNotificationTemplate, getErrorMode, getErrorMode, getLogLevelDatabase, getLogLevelDatabase, getLogLevelFile, getLogLevelFile, getNodeGroup, getNodeGroup, getNodeID, getNodeID, getNodeIDAsPrimitive, getNodeIDAsPrimitive, getPriority, getPriority, getPriorityAsPrimitive, getPriorityAsPrimitive, getRestrictions, getRestrictions, getSessionCurrency, getSessionCurrency, getSessionLanguage, getSessionLanguage, getSessionUser, getSessionUser, getTriggers, getTriggers, isActive, isActive, isActiveAsPrimitive, isActiveAsPrimitive, isChangeRecordingEnabled, isChangeRecordingEnabled, isChangeRecordingEnabledAsPrimitive, isChangeRecordingEnabledAsPrimitive, isLogToDatabase, isLogToDatabase, isLogToDatabaseAsPrimitive, isLogToDatabaseAsPrimitive, isLogToFile, isLogToFile, isLogToFileAsPrimitive, isLogToFileAsPrimitive, isRemoveOnExit, isRemoveOnExit, isRemoveOnExitAsPrimitive, isRemoveOnExitAsPrimitive, isRequestAbort, isRequestAbort, isRequestAbortAsPrimitive, isRequestAbortAsPrimitive, isRequestAbortStep, isRequestAbortStep, isRequestAbortStepAsPrimitive, isRequestAbortStepAsPrimitive, isRetry, isRetry, isRetryAsPrimitive, isRetryAsPrimitive, isSendEmail, isSendEmail, isSendEmailAsPrimitive, isSendEmailAsPrimitive, isSingleExecutable, isSingleExecutable, isSingleExecutableAsPrimitive, isSingleExecutableAsPrimitive, removeFromRestrictions, removeFromRestrictions, removeFromTriggers, removeFromTriggers, setActive, setActive, setActive, setActive, setAlternativeDataSourceID, setAlternativeDataSourceID, setChangeRecordingEnabled, setChangeRecordingEnabled, setChangeRecordingEnabled, setChangeRecordingEnabled, setCode, setEmailAddress, setEmailAddress, setEmailNotificationTemplate, setEmailNotificationTemplate, setErrorMode, setErrorMode, setLogLevelDatabase, setLogLevelDatabase, setLogLevelFile, setLogLevelFile, setLogToDatabase, setLogToDatabase, setLogToDatabase, setLogToDatabase, setLogToFile, setLogToFile, setLogToFile, setLogToFile, setNodeGroup, setNodeGroup, setNodeID, setNodeID, setNodeID, setNodeID, setPriority, setPriority, setPriority, setPriority, setRemoveOnExit, setRemoveOnExit, setRemoveOnExit, setRemoveOnExit, setRequestAbort, setRequestAbort, setRequestAbort, setRequestAbort, setRequestAbortStep, setRequestAbortStep, setRequestAbortStep, setRequestAbortStep, setRestrictions, setRestrictions, setRetry, setRetry, setRetry, setRetry, setSendEmail, setSendEmail, setSendEmail, setSendEmail, setSessionCurrency, setSessionCurrency, setSessionLanguage, setSessionLanguage, setSessionUser, setSessionUser, setSingleExecutable, setSingleExecutable, setSingleExecutable, setSingleExecutable, setTriggers, setTriggersgetInitialPropertiesgetAllLocalizedProperties, 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, 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, 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, setOwner, setPermissionsByMap, setTransientObject, setUseTA, toString, useTA, writeReplacegetImplementation, setTenantpublic static final String CTX_CURRENTJOB
SessionContext attribute which contains the Job instance.public static final String CTX_CURRENTCRONJOB
SessionContext attribute which contains the CronJob instance.protected 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 GenericItemctx - 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 rollbackedpublic void setNonInitialAttributes(SessionContext ctx, Item item, Item.ItemAttributeMap nonInitialAttributes) throws JaloBusinessException
ItemItem.createItem(SessionContext, ComposedType, ItemAttributeMap). as default this method just iterates over all
attribute mappings and sets the value by invoking Item.setAttribute(SessionContext, String, Object).setNonInitialAttributes in class Itemctx - session context with language = NULLitem - the newly created itemnonInitialAttributes - the non-initial attributed obtained via
Item.getNonInitialAttributes(SessionContext, ItemAttributeMap)JaloBusinessExceptionprotected Item.ItemAttributeMap getNonInitialAttributes(SessionContext ctx, Item.ItemAttributeMap allAttributes)
GenericItemGenericItem.getNonInitialAttributes(SessionContext, Item.ItemAttributeMap ) assures
that the 'registered initial' properties GenericItem.getInitialProperties(JaloSession, Item.ItemAttributeMap ) will
be removed from the 'non initial map'.getNonInitialAttributes in class GenericItemctx - session context with language = NULLallAttributes - a ItemAttributeMap contaning attribute values.ItemAttributeMap containing all attribute values, which belong to non-initial attributes.public void remove(SessionContext ctx) throws ConsistencyCheckException
CronJobs were removed, than the Job itself.remove in class Itemctx - A SessionContext objectConsistencyCheckException - if this item could not be removed for some reasonItem.remove(de.hybris.platform.jalo.SessionContext)protected void checkRemovable(SessionContext ctx) throws ConsistencyCheckException
ItemcheckRemovable in class ItemConsistencyCheckException - to indicate that the item cannot be removed@Deprecated public void setCronJobs(SessionContext ctx, Collection<CronJob> cronJobs)
Collection of CronJobs to this Job. All CronJobs, which where assigned to the
Job before and which are not part of the specified Collection will be deleted.ctx - The SessionContext, which will be usedcronJobs - the Collection of CronJobs, which will be assigned to the Job@Deprecated public Collection<CronJob> getCronJobsByCode(String code)
CronJobService.getCronJob(String) insteadcode - The code of the searched Cronjobs@Deprecated public Collection<CronJob> getCronJobsByCode(SessionContext ctx, String code)
CronJobService.getCronJob(String) insteadctx - The SessionContext, which will be usedcode - The code of the searched Cronjobs@Deprecated protected boolean canUndo(CronJob cronJob)
true, if the specified CronJob can be undone. Overwrite this method of you want
to undo your CronJob. Default value is falsecronJob - the CronJob to undo changes fortrue if this Job is undoable, false otherwise.@Deprecated public boolean isAbortable(CronJob conJob)
CronJobService.isAbortable(de.hybris.platform.cronjob.model.CronJobModel)
insteadconJob - the current execution of this job.true if the cronjob is running and the job supports aborting via
GeneratedCronJob.setRequestAbort(boolean)@Deprecated public boolean isUndoable(CronJob cronJob)
cronJob - the CronJob to undoCronJob is undoable or not@Deprecated protected boolean canPerform(CronJob cronJob)
Job is performed. If you override this method you can check the things
that are necessary for the performing of your Job. Default value is true.cronJob - the actual CronJobtrue if this Job is performable, false otherwise.
de.hybris.platform.servicelayer.cronjob.CronJobService@Deprecated public boolean isPerformable(CronJob cronJob)
CronJobService.isPerformable(de.hybris.platform.cronjob.model.CronJobModel)
insteadcanPerform( final CronJob cronJob ) and canPerformInternal( final CronJob cronJob ) are called. Only
if both methods returning true, this method also return true Returns true,
if this Job can be performed using the specified Cronjob. Otherwise false
is returned.cronJob - which should be performedtrue, if this Job can be performed using the specified Cronjob.
Otherwise false is returned@Deprecated public boolean isPerformable(CronJob cronJob, int clusternode)
CronJobService.isPerformable(de.hybris.platform.cronjob.model.CronJobModel)
instead@Deprecated public final void perform(CronJob cronJob)
CronJobService.performCronJob(de.hybris.platform.cronjob.model.CronJobModel)
insteadJob asynchronous in a separate Thread using the specified
Cronjob.cronJob - which is used to perform this Job@Deprecated public final void perform(CronJob cronJob, boolean synchronous)
CronJobService.performCronJob(de.hybris.platform.cronjob.model.CronJobModel, boolean)
insteadJob using the specified Cronjob. If synchronous is true, the
Job will be performed synchronous, which means that this method will return the control to its caller
as recently as this Job is performed. Synchronous execution is especially useful for short Jobs or
testing purpose (JUnit tests for example). If synchronous is false, the Job will be
performed asynchronous by executing the Job in a separate Thread.cronJob - which will be used to perform this Jobsynchronous - true if this Job should be performed synchronously, false if this
Job should be performed asynchronously@Deprecated public final void perform(CronJob cronJob, Job.Synchronicity synchronousType)
CronJobService.performCronJob(de.hybris.platform.cronjob.model.CronJobModel, boolean)
insteadprotected BeforeCronJobStartEvent prepareBeforeStartEvent(CronJob cj, boolean synchronous)
protected void sendStartEvent(BeforeCronJobStartEvent event)
protected AfterCronJobFinishedEvent prepareAfterFinishEvent(CronJob cj, boolean synchronous)
protected void sendFinishedEvent(AfterCronJobFinishedEvent event, CronJob.CronJobResult result)
protected void switchDataSource(CronJob cronjob)
protected void unsetAlternativeDataSource()
protected static final void setCurrentLogContainer(Job.JobFileLogContainer logContainer)
protected static final void unsetCurrentLogContainer()
protected static final Job.JobFileLogContainer getCurrentLogContainer()
protected static final boolean jobIsCurrentlyRunning()
protected static final void saveToLogFile(Job.JobFileLogContainer container, CronJob cronJob)
protected void logToFile(String message, Level level)
public void log(String message, Level level)
@Deprecated public void debug(String message)
@Deprecated public void info(String message)
@Deprecated public void warn(String message)
@Deprecated public void error(String message)
@Deprecated public void fatal(String message)
@Deprecated public boolean isEnabledFor(Level level)
@Deprecated public boolean isDebugEnabled()
@Deprecated public boolean isInfoEnabled()
@Deprecated public boolean isWarnEnabled()
@Deprecated public boolean isErrorEnabled()
@Deprecated public final void undo(CronJob cronJob)
Job asynchronous in a separate Thread using the specified
Cronjob.cronJob - which is used to perform this Job@Deprecated public final void undo(CronJob cronJob, boolean synchronous)
Job using the specified Cronjob. If synchronous is true, the
Job will be undone synchronous, which means that this method will return the control to its caller as
recently as this Job is undone. Synchronous undo is especially useful for short Jobs or testing
purpose (JUnit tests for example). If synchronous is false, the Job will be undone
asynchronous by executing it in a separate Thread.cronJob - which will ne used to undo this Jobsynchronous - true if this Job should be undone synchronously, false if this
Job should be undone asynchronously@Deprecated protected abstract CronJob.CronJobResult performCronJob(CronJob cronJob) throws AbortCronJobException
CronJobService.performCronJob(de.hybris.platform.cronjob.model.CronJobModel, boolean)
insteadJob. Here you can execute the job. You have to return a
CronJobResult that indicates whether the Job was successfully executed or not.cronJob - the CronJob to executeCronJobResult that indicates whether the Job was successfully executed or not.
AbortCronJobExceptionCronJob.getFinishedResult(boolean),
CronJob.getAbortResult()@Deprecated protected CronJob.CronJobResult undoCronJob(CronJob cronJob)
cronJob - the CronJob to undoCronJobResult that indicates whether the undo of your Job was successful or
notprotected JaloSession startOwnSession(CronJob cronJob) throws ConsistencyCheckException
ConsistencyCheckExceptionprotected void stopOwnSession(JaloSession previousSession, CronJob cronJob)
previousSession - cronJob - public void setCode(SessionContext ctx, String code)
GeneratedJobJob.code attribute.setCode in class GeneratedJobcode - the code@Deprecated protected void configureCronjob(CronJob cronjob) throws JaloInvalidParameterException, JaloBusinessException
CronJobFactory mechanism instead, refer to
appropriate wiki document@Deprecated protected Map<String,String> getConfigAttributes(CronJob cronjob)
CronJobFactory mechanism instead, refer to
appropriate wiki documentprotected CronJobLogListener.CronJobLogContext createLogContext(CronJob cronjob)
protected Level getEffectiveLogLevel(CronJob cronjob)
Copyright © 2017 SAP SE. All Rights Reserved.