Class DefaultSelfHealingService

java.lang.Object
de.hybris.platform.directpersistence.selfhealing.impl.DefaultSelfHealingService
All Implemented Interfaces:
SelfHealingService, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean

public class DefaultSelfHealingService extends Object implements SelfHealingService, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Default implementation of self healing service
  • Field Details

    • CFG_SELF_HEALING_INTERVAL

      public static final String CFG_SELF_HEALING_INTERVAL
      See Also:
    • CFG_SELF_HEALING_BATCH_LIMIT

      public static final String CFG_SELF_HEALING_BATCH_LIMIT
      See Also:
    • CFG_SELF_HEALING_ENABLED

      public static final String CFG_SELF_HEALING_ENABLED
      See Also:
    • DEFAULT_SELF_HEALING_INTERVAL_SECONDS

      public static final int DEFAULT_SELF_HEALING_INTERVAL_SECONDS
      See Also:
    • DEFAULT_SELF_HEALING_BATCH_LIMIT

      public static final int DEFAULT_SELF_HEALING_BATCH_LIMIT
      See Also:
    • DEFAULT_SELF_HEALING_ENABLED

      public static final boolean DEFAULT_SELF_HEALING_ENABLED
      See Also:
  • Constructor Details

    • DefaultSelfHealingService

      public DefaultSelfHealingService()
  • Method Details

    • setTestListener

      public void setTestListener(DefaultSelfHealingService.TestListener listener)
    • removeTestListener

      public void removeTestListener()
    • addItemToHeal

      public void addItemToHeal(ItemToHeal itemToHeal)
      Description copied from interface: SelfHealingService
      Adds items to heal.

      Accumulates those items for scheduled processing through WritePersistenceGateway.persist(ChangeSet changeSet).

      The scheduled method is batchItems().

      Item will be only passed to WritePersistenceGateway when current transaction is committed.

      Specified by:
      addItemToHeal in interface SelfHealingService
      Parameters:
      itemToHeal - item for later scheduled processing
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: SelfHealingService
      Tells whether the self healing process is enabled.
      Specified by:
      isEnabled in interface SelfHealingService
    • batchItems

      public void batchItems()
      The method that is scheduled and run in thread in this bean.

      Takes accumulated items and persist the changes that they represent.

      Schedule setting can be overridden in local.properties

      self.healing.interval and self.healing.enabled

      SessionService is needed for disabling scheduler calls for this method during junit tests. When Spring makes a call it will only get global scheduler.selfhealing.enabled flag. When junit test make a call they will get the flag set in session service. That way scheduler wont interfere with manual junit calls.

    • destroy

      public void destroy() throws Exception
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean
      Throws:
      Exception
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • setupWorkerViaTenantListener

      protected void setupWorkerViaTenantListener()
    • applyWorkerSettings

      public void applyWorkerSettings()
      Applies current background process settings. If enabled it will ensure that the worker is started (if not running yet). If disabled it will stop the worker (if it was running before).
    • setupFromConfig

      protected void setupFromConfig()
    • startWorkerIfNotRunning

      protected void startWorkerIfNotRunning()
    • stopWorkerIfRunning

      protected void stopWorkerIfRunning()
    • setInterval

      public void setInterval(int interval)
    • getInterval

      public int getInterval()
    • setWritePersistenceGateway

      public void setWritePersistenceGateway(WritePersistenceGateway writePersistenceGateway)
    • setBatchLimit

      public void setBatchLimit(int batchLimit)
    • getBatchLimit

      public int getBatchLimit()
    • setEnabled

      public void setEnabled(boolean enableSchedulerGlobal)
      Flag enabling global Spring Scheduler task execution in this service