Class BackgroundProcessManager
- java.lang.Object
-
- com.jalios.jcms.ChannelListener
-
- com.jalios.jcms.backgroundprocess.BackgroundProcessManager
-
- All Implemented Interfaces:
PluginComponent
,JPropertiesListener
,java.lang.Comparable
public class BackgroundProcessManager extends ChannelListener implements JPropertiesListener
- Since:
- jcms-10.0.8 / JCMS-9179
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
OPERATION_ACL
static java.lang.String
PROCESS_REQ_ATTR
-
Fields inherited from class com.jalios.jcms.ChannelListener
order
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
canBeNotified(Member loggedMember, Member processAuthor)
Only for author for now (see BackgroundProcessInfo.notify monovaluated boolean)protected ControllerStatus
canStart(Member author, BackgroundProcess process, BackgroundProcess.Scope scope, boolean unique)
Returns weither process can be run or not as a controller status.
Prevents unique process to be run simultaneously, depending on author, domain and scope.
Prevents null-author process to be run, unless it is explicitely allowed usingBackgroundProcess.allowNulLAuthor()
;protected void
createInfo(BackgroundProcess process)
Create a new BackgroundProcessInfo for the specified BackgroundProcess, and update BackgroundProcess to reference it.void
deleteInfo(java.lang.String infoId)
Delete the BackgroundProcessInfo specified by its id.BackgroundProcess
getCurrentBackgroundProcess()
Return the BackgroundProcess of the current thread if any.static BackgroundProcessManager
getInstance()
boolean
getNotifyPreference(BackgroundProcessInfo info)
long
getPendingProcessCount(BackgroundProcess.Scope scope, java.lang.String domain, Member author)
Return count of process that are not completed.long
getPendingProcessCount(BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
Return count of process matching that are not completed.java.util.List<BackgroundProcessInfo>
getPendingProcessList(BackgroundProcess.Scope scope, java.lang.String domain, Member author)
Deprecated.java.util.List<BackgroundProcessInfo>
getPendingProcessList(BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
Deprecated.java.util.List<BackgroundProcessInfo>
getPendingProcessList(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author)
Lists pending process matching.java.util.List<BackgroundProcessInfo>
getPendingProcessList(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
Lists pending process matching.long
getProcessCount(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author)
Return count of all process matching.long
getProcessCount(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
Return count of all process matching.java.util.List<BackgroundProcessInfo>
getProcessList(BackgroundProcess.Scope scope, java.lang.String domain, Member author)
Deprecated.java.util.List<BackgroundProcessInfo>
getProcessList(BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
Deprecated.java.util.List<BackgroundProcessInfo>
getProcessList(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author)
java.util.List<BackgroundProcessInfo>
getProcessList(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
boolean
hasBackgroundProcess(Member member)
Check if there is any BackgroundProcess started by specified membervoid
init()
void
propertiesChange(JProperties properties)
Handle properties change.void
saveNotifyPreference(BackgroundProcessInfo info, boolean isNotify)
protected java.util.concurrent.CompletableFuture<java.lang.Void>
start(Member author, BackgroundProcess process)
-
Methods inherited from class com.jalios.jcms.ChannelListener
compareTo, equals, handleFinalize, init, initAfterStartup, initAfterStoreLoad, initBeforeHibernateFactoryBuild, initBeforeStoreLoad
-
-
-
-
Field Detail
-
PROCESS_REQ_ATTR
public static final java.lang.String PROCESS_REQ_ATTR
-
OPERATION_ACL
public static final java.lang.String OPERATION_ACL
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static BackgroundProcessManager getInstance()
-
init
public void init()
-
propertiesChange
public void propertiesChange(JProperties properties)
Handle properties change.- Specified by:
propertiesChange
in interfaceJPropertiesListener
- Parameters:
properties
- the properties which have been submitted to change
-
getCurrentBackgroundProcess
public BackgroundProcess getCurrentBackgroundProcess()
Return the BackgroundProcess of the current thread if any.- Returns:
- a BackgroundProcess instance, or null if none
- Since:
- jcms-10.0.8
-
start
protected java.util.concurrent.CompletableFuture<java.lang.Void> start(Member author, BackgroundProcess process)
- Parameters:
process
- the process to be startedauthor
- the member performing the operation- Returns:
- a future result
- Since:
- jcms-10.0.8
-
saveNotifyPreference
public void saveNotifyPreference(BackgroundProcessInfo info, boolean isNotify)
- Parameters:
info
- process infoisNotify
- weither process author must be notified on process completed- Since:
- jcms-10.0.8
-
getNotifyPreference
public boolean getNotifyPreference(BackgroundProcessInfo info)
- Parameters:
info
- process info- Returns:
- weither process author must be notified on process completed
- Since:
- jcms-10.0.8
-
canBeNotified
public boolean canBeNotified(Member loggedMember, Member processAuthor)
Only for author for now (see BackgroundProcessInfo.notify monovaluated boolean)- Parameters:
loggedMember
- the memberprocessAuthor
- process author- Returns:
- true if member is info author
- Since:
- jcms-10.0.8
-
hasBackgroundProcess
public boolean hasBackgroundProcess(Member member)
Check if there is any BackgroundProcess started by specified member- Parameters:
member
- a member (return false if null)- Returns:
- true if there is at least one background process, false otherwise
- Since:
- jcms-10.0.8
-
getProcessList
@Deprecated public java.util.List<BackgroundProcessInfo> getProcessList(BackgroundProcess.Scope scope, java.lang.String domain, Member author)
Deprecated.Lists all process (pending and completed) matching.- Parameters:
scope
- the scope filterdomain
- the domain filterauthor
- the author filter- Returns:
- list of matching process
- Since:
- jcms-10.0.8
-
getProcessList
@Deprecated public java.util.List<BackgroundProcessInfo> getProcessList(BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
Deprecated.Lists all process (pending and completed) matching.- Parameters:
scope
- the scope filterdomain
- the domain filterauthor
- the author filterqueryBuildHook
- a hook to customize the queryBuilder- Returns:
- list of matching process
- Since:
- jcms-10.0.8
-
getProcessList
public java.util.List<BackgroundProcessInfo> getProcessList(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author)
-
getProcessList
public java.util.List<BackgroundProcessInfo> getProcessList(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
-
getPendingProcessList
@Deprecated public java.util.List<BackgroundProcessInfo> getPendingProcessList(BackgroundProcess.Scope scope, java.lang.String domain, Member author)
Deprecated.Lists pending process matching.- Parameters:
scope
- the scope filterdomain
- the domain filterauthor
- the author filter- Returns:
- list of matching process
- Since:
- jcms-10.0.8
-
getPendingProcessList
public java.util.List<BackgroundProcessInfo> getPendingProcessList(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author)
Lists pending process matching.- Parameters:
loggedMember
- member to use for read rightsscope
- the scope filterdomain
- the domain filterauthor
- the author filter- Returns:
- list of matching process
- Since:
- jcms-10.0.8
-
getPendingProcessList
@Deprecated public java.util.List<BackgroundProcessInfo> getPendingProcessList(BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
Deprecated.Lists pending process matching.- Parameters:
scope
- the scope filterdomain
- the domain filterauthor
- the author filterqueryBuildHook
- a hook to customize the queryBuilder- Returns:
- list of matching process
- Since:
- jcms-10.0.8
-
getPendingProcessList
public java.util.List<BackgroundProcessInfo> getPendingProcessList(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
Lists pending process matching.- Parameters:
loggedMember
- member to use for read rightsscope
- the scope filterdomain
- the domain filterauthor
- the author filterqueryBuildHook
- a hook to customize the queryBuilder- Returns:
- list of matching process
- Since:
- jcms-10.0.8
-
getPendingProcessCount
public long getPendingProcessCount(BackgroundProcess.Scope scope, java.lang.String domain, Member author)
Return count of process that are not completed.- Parameters:
scope
- the scope filterdomain
- the domain filterauthor
- the author filter- Returns:
- count of matching process
- Since:
- jcms-10.0.8
-
getPendingProcessCount
public long getPendingProcessCount(BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
Return count of process matching that are not completed.- Parameters:
scope
- the scope filterdomain
- the domain filterauthor
- the author filterqueryBuildHook
- a hook to customize the queryBuilder- Returns:
- count of matching process
- Since:
- jcms-10.0.8
-
getProcessCount
public long getProcessCount(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author)
Return count of all process matching.- Parameters:
loggedMember
- member to use for read rightsscope
- the scope filterdomain
- the domain filterauthor
- the author filter- Returns:
- count of matching process
- Since:
- jcms-10.0.8
-
getProcessCount
public long getProcessCount(Member loggedMember, BackgroundProcess.Scope scope, java.lang.String domain, Member author, java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
Return count of all process matching.- Parameters:
loggedMember
- member to use for read rightsscope
- the scope filterdomain
- the domain filterauthor
- the author filterqueryBuildHook
- a hook to customize the queryBuilder- Returns:
- count of matching process
- Since:
- jcms-10.0.8
-
canStart
protected ControllerStatus canStart(Member author, BackgroundProcess process, BackgroundProcess.Scope scope, boolean unique)
Returns weither process can be run or not as a controller status.
Prevents unique process to be run simultaneously, depending on author, domain and scope.
Prevents null-author process to be run, unless it is explicitely allowed usingBackgroundProcess.allowNulLAuthor()
;- Parameters:
process
- the process to check if it can be runscope
- scope of the process to run,BackgroundProcess.Scope.WEBAPP
used by defaultunique
- true if no new same process can be run if another one is already runningauthor
- author of process to run- Returns:
- a ControllerStatus
- Since:
- jcms-10.0.8
-
createInfo
protected void createInfo(BackgroundProcess process)
Create a new BackgroundProcessInfo for the specified BackgroundProcess, and update BackgroundProcess to reference it.The BackgroundProcessInfo create is performed in another hibernate session/transcation leaving your current transaction untouched.
- Parameters:
process
- the BackgroundProcess for which info must be created- Since:
- jcms-10.0.8
-
deleteInfo
public void deleteInfo(java.lang.String infoId)
Delete the BackgroundProcessInfo specified by its id.The BackgroundProcessInfo is deleted in a dedicated thread, in another hibernate session/transaction leaving your current transaction untouched.
- Parameters:
infoId
- the id of BackgroundProcessInfo- Since:
- jcms-10.0.8
-
-