Class BackgroundProcessManager

java.lang.Object
com.jalios.jcms.ChannelListener
com.jalios.jcms.backgroundprocess.BackgroundProcessManager
All Implemented Interfaces:
PluginComponent, JPropertiesListener, Comparable

public class BackgroundProcessManager extends ChannelListener implements JPropertiesListener
Since:
jcms-10.0.8 / JCMS-9179
  • Field Details

  • Method Details

    • getInstance

      public static BackgroundProcessManager getInstance()
    • init

      public void init()
    • propertiesChange

      public void propertiesChange(JProperties properties)
      Handle properties change.
      Specified by:
      propertiesChange in interface JPropertiesListener
      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 CompletableFuture<Void> start(Member author, BackgroundProcess process)
      Parameters:
      author - the member performing the operation
      process - the process to be started
      Returns:
      a future result
      Since:
      jcms-10.0.8
    • saveNotifyPreference

      public void saveNotifyPreference(BackgroundProcessInfo info, boolean isNotify)
      Parameters:
      info - process info
      isNotify - 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 member
      processAuthor - 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 List<BackgroundProcessInfo> getProcessList(BackgroundProcess.Scope scope, String domain, Member author)
      Deprecated.
      Lists all process (pending and completed) matching.
      Parameters:
      scope - the scope filter
      domain - the domain filter
      author - the author filter
      Returns:
      list of matching process
      Since:
      jcms-10.0.8
    • getProcessList

      @Deprecated public List<BackgroundProcessInfo> getProcessList(BackgroundProcess.Scope scope, String domain, Member author, Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
      Lists all process (pending and completed) matching.
      Parameters:
      scope - the scope filter
      domain - the domain filter
      author - the author filter
      queryBuildHook - a hook to customize the queryBuilder
      Returns:
      list of matching process
      Since:
      jcms-10.0.8
    • getProcessList

      public List<BackgroundProcessInfo> getProcessList(Member loggedMember, BackgroundProcess.Scope scope, String domain, Member author)
    • getProcessList

      public List<BackgroundProcessInfo> getProcessList(Member loggedMember, BackgroundProcess.Scope scope, String domain, Member author, Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
    • getPendingProcessList

      @Deprecated public List<BackgroundProcessInfo> getPendingProcessList(BackgroundProcess.Scope scope, String domain, Member author)
      Lists pending process matching.
      Parameters:
      scope - the scope filter
      domain - the domain filter
      author - the author filter
      Returns:
      list of matching process
      Since:
      jcms-10.0.8
    • getPendingProcessList

      public List<BackgroundProcessInfo> getPendingProcessList(Member loggedMember, BackgroundProcess.Scope scope, String domain, Member author)
      Lists pending process matching.
      Parameters:
      loggedMember - member to use for read rights
      scope - the scope filter
      domain - the domain filter
      author - the author filter
      Returns:
      list of matching process
      Since:
      jcms-10.0.8
    • getPendingProcessList

      @Deprecated public List<BackgroundProcessInfo> getPendingProcessList(BackgroundProcess.Scope scope, String domain, Member author, Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
      Lists pending process matching.
      Parameters:
      scope - the scope filter
      domain - the domain filter
      author - the author filter
      queryBuildHook - a hook to customize the queryBuilder
      Returns:
      list of matching process
      Since:
      jcms-10.0.8
    • getPendingProcessList

      public List<BackgroundProcessInfo> getPendingProcessList(Member loggedMember, BackgroundProcess.Scope scope, String domain, Member author, Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
      Lists pending process matching.
      Parameters:
      loggedMember - member to use for read rights
      scope - the scope filter
      domain - the domain filter
      author - the author filter
      queryBuildHook - a hook to customize the queryBuilder
      Returns:
      list of matching process
      Since:
      jcms-10.0.8
    • getPendingProcessCount

      public long getPendingProcessCount(BackgroundProcess.Scope scope, String domain, Member author)
      Return count of process that are not completed.
      Parameters:
      scope - the scope filter
      domain - the domain filter
      author - the author filter
      Returns:
      count of matching process
      Since:
      jcms-10.0.8
    • getPendingProcessCount

      public long getPendingProcessCount(BackgroundProcess.Scope scope, String domain, Member author, Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
      Return count of process matching that are not completed.
      Parameters:
      scope - the scope filter
      domain - the domain filter
      author - the author filter
      queryBuildHook - 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, String domain, Member author)
      Return count of all process matching.
      Parameters:
      loggedMember - member to use for read rights
      scope - the scope filter
      domain - the domain filter
      author - the author filter
      Returns:
      count of matching process
      Since:
      jcms-10.0.8
    • getProcessCount

      public long getProcessCount(Member loggedMember, BackgroundProcess.Scope scope, String domain, Member author, Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
      Return count of all process matching.
      Parameters:
      loggedMember - member to use for read rights
      scope - the scope filter
      domain - the domain filter
      author - the author filter
      queryBuildHook - 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 wether 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 using BackgroundProcess.allowNullAuthor();
      Parameters:
      author - author of process to run
      process - the process to check if it can be run
      scope - scope of the process to run, BackgroundProcess.Scope.WEBAPP used by default
      unique - true if no new same process can be run if another one is already running
      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(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