Interface ExtensionPointScriptObject
-
- All Superinterfaces:
com.redwood.scheduler.api.session.RestrictedSchedulerSessionSupport
public interface ExtensionPointScriptObject extends com.redwood.scheduler.api.session.RestrictedSchedulerSessionSupport
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
addToCloseList(AutoCloseable o, String name, boolean log)
Close the object when the action completes.void
clearRetainedActionSubjectSchedulerSession()
Clear an earlier requested retained SchedulerSessoin.void
clearRetainedUserSchedulerSession()
Clear an earlier requested retained SchedulerSessoin.SchedulerSession
createActionSubjectSchedulerSession()
Create an additional SchedulerSesison that has the context of the Act ion Subject as defined by the Extension Point These SchedulerSessions are detached and invalidated after the execution of the request, and should therefore NOT be held on to (by storing them in the session or otherwise).SchedulerSession
createUserSchedulerSession()
Create an additional SchedulerSesison that has the context of the user performing the action.void
executeActionWithLock(String name, Runnable action)
Execute the action when the lock with name has been acquired.void
forceCloseListLogging()
Force logging of all objects in close list.String
getBootStrapURL()
Retrieve the URL to the javascript that will contain the javascript api object jcsExtension to be used in javascript.ExtensionPoint
getExtensionPoint()
Get the extension point that defined this action.Long
getExtensionPointUniqueId()
Get the extension point Unique Id that defined this action.List<JobChainCall>
getJobChainCalls()
Return a list of JobChainCalls that make up the path from the last call that points to the JobDefinition of which the JobDefinitionParameter is being edited to the call of the root chain.String
getJobDefinitionBootStrapURL()
Retrieve the URL to the javascript that will contain the javascript api object jceJobDefinition extension to be used in javascript.JobDefinitionParameter
getJobDefinitionParameter()
Get the JobDefinitionParameter that this Extension Point was invoked from.int
getMaxRetries()
Get maximum retries.int
getMaxSpins()
Get maximum spins.String
getOriginalValue()
Return the original value of the field that initiated this ExtensionPointSchedulerSession
getRetainedActionSubjectSchedulerSession()
Get (or create if one does not exist yet) a SchedulerSession that will be available in consequent requests for this user for the same ExtensionPoint execution.SchedulerSession
getRetainedUserSchedulerSession()
Get (or create if one does not exist yet) a SchedulerSession that will be available in consequent requests for this user for the same ExtensionPoint execution.SchedulerSession
getSharedSchedulerSession()
Return a SchedulerSession that is being used on an edit page, and contains the objects being edited.String
getThemeCSSUrl()
Retrieve the URL to the CSS that will contain theming information that can be used to style the page like the rest of the product<T extends Exception>
voidperformUnitOfWorkActionSubjectSession(SchedulerSessionUnitOfWork<T> uow)
Perform a unit of work, by calling it with a new Action Subject session.<T extends Exception>
voidperformUnitOfWorkUserSession(SchedulerSessionUnitOfWork<T> uow)
Perform a unit of work, by calling it with a new User session.void
releaseSharedSchedulerSession()
Once an Extension Point is done with the shared SchedulerSession and no longer needs access to it, then this method can be called to release the SchedulerSession so it can be garbage collected.void
setMaxRetries(int newMaxRetries)
Set the maximum number of retries for units of work.void
setMaxSpins(int newMaxSpins)
Set the maximum number of spins for units of work.
-
-
-
Method Detail
-
executeActionWithLock
void executeActionWithLock(String name, Runnable action) throws InterruptedException
Execute the action when the lock with name has been acquired. Each extension point has its own lock that an Extension Point can use. Within each Extension Point, multiple locks can be created by giving them different names.- Parameters:
name
- of the lock to acquire before running the actionaction
- to run when the lock has been acquired.- Throws:
InterruptedException
- when the thread is interrupted while waiting for a lock.
-
getExtensionPointUniqueId
Long getExtensionPointUniqueId()
Get the extension point Unique Id that defined this action.- Returns:
- the Extension Point Unique Id that defined this action.
-
getExtensionPoint
ExtensionPoint getExtensionPoint()
Get the extension point that defined this action.- Returns:
- the Extension Point that defined this action.
-
createUserSchedulerSession
SchedulerSession createUserSchedulerSession()
Create an additional SchedulerSesison that has the context of the user performing the action. These SchedulerSessions are detached and invalidated after the execution of the request, and should therefore NOT be held on to (by storing them in the session or otherwise). Use getRetainedUserSchedulerSession() instead.- Returns:
- a user SchedulerSession
-
createActionSubjectSchedulerSession
SchedulerSession createActionSubjectSchedulerSession()
Create an additional SchedulerSesison that has the context of the Act ion Subject as defined by the Extension Point These SchedulerSessions are detached and invalidated after the execution of the request, and should therefore NOT be held on to (by storing them in the session or otherwise). Use getRetainedActionSubjectSchedulerSession() instead.- Returns:
- an Action Subject SchedulerSession, or null if Action Subject is not defined
-
getRetainedUserSchedulerSession
SchedulerSession getRetainedUserSchedulerSession()
Get (or create if one does not exist yet) a SchedulerSession that will be available in consequent requests for this user for the same ExtensionPoint execution. Unlike the SchedulerSession returned by createUserSchedulerSession(), this SchedulerSession is not invalidated after the execution has ended, and can be used to store modified Scheduler Entities that the user is editing.- Returns:
- a user SchedulerSession that can be used over multiple requests.
-
clearRetainedUserSchedulerSession
void clearRetainedUserSchedulerSession()
Clear an earlier requested retained SchedulerSessoin. The retained SchedulerSession will be invalidated, and SchedulerEntities retrieved from this SchedulerSession will not be usable anymore. All changes made to SchedulerEntities will also be discarded. Has no effect when getRetainedUserSchedulerSession() has not been called before for this user/ExtensionPoint combination
-
getRetainedActionSubjectSchedulerSession
SchedulerSession getRetainedActionSubjectSchedulerSession()
Get (or create if one does not exist yet) a SchedulerSession that will be available in consequent requests for this user for the same ExtensionPoint execution. Unlike the SchedulerSession returned by createUserSchedulerSession(), this SchedulerSession is not invalidated after the execution has ended, and can be used to store modified Scheduler Entities that the user is editing.- Returns:
- an Action Subject based SchedulerSession that can be used over multiple requests, or null if an Action Subject is not defined
-
clearRetainedActionSubjectSchedulerSession
void clearRetainedActionSubjectSchedulerSession()
Clear an earlier requested retained SchedulerSessoin. The retained SchedulerSession will be invalidated, and SchedulerEntities retrieved from this SchedulerSession will not be usable anymore. All changes made to SchedulerEntities will also be discarded. Has no effect when getRetainedActionSubjectSchedulerSession() has not been called before for this user/ExtensionPoint combination
-
getMaxRetries
int getMaxRetries()
Get maximum retries.- Returns:
- maximum retries.
-
getMaxSpins
int getMaxSpins()
Get maximum spins.- Returns:
- maximum spins.
-
setMaxRetries
void setMaxRetries(int newMaxRetries)
Set the maximum number of retries for units of work.- Parameters:
newMaxRetries
- the new maximum number of retries, must be > 1.
-
setMaxSpins
void setMaxSpins(int newMaxSpins)
Set the maximum number of spins for units of work.- Parameters:
newMaxSpins
- the new maximum number of spins, must be > 1.
-
performUnitOfWorkUserSession
<T extends Exception> void performUnitOfWorkUserSession(SchedulerSessionUnitOfWork<T> uow) throws com.redwood.scheduler.api.exception.SchedulerAPIPersistenceException, T extends Exception
Perform a unit of work, by calling it with a new User session. If the initial call fails with a no rows updated exception, call it again with a new session. If it fails with any other exception, or fails too many times with no rows updated, throw the last exception thrown. Retries can be configured withsetMaxRetries(int)
. Spins can be configured withsetMaxSpins(int)
.- Parameters:
uow
- the unit of work to perform. Generic in the type of Exception its performWork method it throws. SeeSchedulerSessionUnitOfWork
for the problems with using a raw type here.- Throws:
com.redwood.scheduler.api.exception.SchedulerAPIPersistenceException
- if the unit of work fails with a no rows updated exception maxretries times.T
- if the unit of work throws an exception.T extends Exception
-
performUnitOfWorkActionSubjectSession
<T extends Exception> void performUnitOfWorkActionSubjectSession(SchedulerSessionUnitOfWork<T> uow) throws com.redwood.scheduler.api.exception.SchedulerAPIPersistenceException, T extends Exception
Perform a unit of work, by calling it with a new Action Subject session. If the initial call fails with a no rows updated exception, call it again with a new session. If it fails with any other exception, or fails too many times with no rows updated, throw the last exception thrown. Retries can be configured withsetMaxRetries(int)
. Spins can be configured withsetMaxSpins(int)
.- Parameters:
uow
- the unit of work to perform. Generic in the type of Exception its performWork method it throws. SeeSchedulerSessionUnitOfWork
for the problems with using a raw type here.- Throws:
com.redwood.scheduler.api.exception.SchedulerAPIPersistenceException
- if the unit of work fails with a no rows updated exception maxretries times.T
- if the unit of work throws an exception.T extends Exception
-
addToCloseList
boolean addToCloseList(AutoCloseable o, String name, boolean log)
Close the object when the action completes.- Parameters:
o
- the object to close.name
- the name of the object.log
- should information about this object be logged by default.- Returns:
- true if the object was added, false if it was not closable.
-
forceCloseListLogging
void forceCloseListLogging()
Force logging of all objects in close list.
-
getThemeCSSUrl
String getThemeCSSUrl()
Retrieve the URL to the CSS that will contain theming information that can be used to style the page like the rest of the product- Returns:
- the URL to be used in a <link> tag
-
getOriginalValue
String getOriginalValue()
Return the original value of the field that initiated this ExtensionPoint- Returns:
- the original value
-
getSharedSchedulerSession
SchedulerSession getSharedSchedulerSession()
Return a SchedulerSession that is being used on an edit page, and contains the objects being edited. Depending on the type of Extension Point, this SchedulerSession has restrictions with regards to modifying objects or persisting the session. The Jobchain Editor Extension point gets a readonly copy of the session, any modifications will result in an exception. Object page extension points get a modifiable session, but persist is not allowed, exception for type window.- Returns:
- the SchedulerSession being used by the edit page that initiated the ExtensionPoint
-
releaseSharedSchedulerSession
void releaseSharedSchedulerSession()
Once an Extension Point is done with the shared SchedulerSession and no longer needs access to it, then this method can be called to release the SchedulerSession so it can be garbage collected. Keep in mind that after this call, the getSharedSchedulerSession will return null.
-
getBootStrapURL
String getBootStrapURL()
Retrieve the URL to the javascript that will contain the javascript api object jcsExtension to be used in javascript.- Returns:
- the URL to be used in the <script> tag
-
getJobDefinitionParameter
JobDefinitionParameter getJobDefinitionParameter()
Get the JobDefinitionParameter that this Extension Point was invoked from. The JobDefintionParameter will be attached to the shared SchedulerSession, and will be read only- Returns:
- the JobDefinitionParameter
-
getJobChainCalls
List<JobChainCall> getJobChainCalls()
Return a list of JobChainCalls that make up the path from the last call that points to the JobDefinition of which the JobDefinitionParameter is being edited to the call of the root chain. All objects are attached to the shared SchedulerSession but are read only.- Returns:
- the list of JobChainCalls
-
getJobDefinitionBootStrapURL
String getJobDefinitionBootStrapURL()
Retrieve the URL to the javascript that will contain the javascript api object jceJobDefinition extension to be used in javascript.- Returns:
- the URL to be used in the <script> tag
-
-