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 java.lang.Object implements SelfHealingService, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Default implementation of self healing service
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDefaultSelfHealingService.TestListener
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCFG_SELF_HEALING_BATCH_LIMITstatic java.lang.StringCFG_SELF_HEALING_ENABLEDstatic java.lang.StringCFG_SELF_HEALING_INTERVALstatic intDEFAULT_SELF_HEALING_BATCH_LIMITstatic booleanDEFAULT_SELF_HEALING_ENABLEDstatic intDEFAULT_SELF_HEALING_INTERVAL_SECONDS
-
Constructor Summary
Constructors Constructor Description DefaultSelfHealingService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddItemToHeal(ItemToHeal itemToHeal)Adds items to heal.voidafterPropertiesSet()voidapplyWorkerSettings()Applies current background process settings.voidbatchItems()The method that is scheduled and run in thread in this bean.voiddestroy()intgetBatchLimit()intgetInterval()booleanisEnabled()Tells whether the self healing process is enabled.voidremoveTestListener()voidsetBatchLimit(int batchLimit)voidsetEnabled(boolean enableSchedulerGlobal)Flag enabling global Spring Scheduler task execution in this servicevoidsetInterval(int interval)voidsetTestListener(DefaultSelfHealingService.TestListener listener)protected voidsetupFromConfig()protected voidsetupWorkerViaTenantListener()voidsetWritePersistenceGateway(WritePersistenceGateway writePersistenceGateway)protected voidstartWorkerIfNotRunning()protected voidstopWorkerIfRunning()
-
-
-
Field Detail
-
CFG_SELF_HEALING_INTERVAL
public static final java.lang.String CFG_SELF_HEALING_INTERVAL
- See Also:
- Constant Field Values
-
CFG_SELF_HEALING_BATCH_LIMIT
public static final java.lang.String CFG_SELF_HEALING_BATCH_LIMIT
- See Also:
- Constant Field Values
-
CFG_SELF_HEALING_ENABLED
public static final java.lang.String CFG_SELF_HEALING_ENABLED
- See Also:
- Constant Field Values
-
DEFAULT_SELF_HEALING_INTERVAL_SECONDS
public static final int DEFAULT_SELF_HEALING_INTERVAL_SECONDS
- See Also:
- Constant Field Values
-
DEFAULT_SELF_HEALING_BATCH_LIMIT
public static final int DEFAULT_SELF_HEALING_BATCH_LIMIT
- See Also:
- Constant Field Values
-
DEFAULT_SELF_HEALING_ENABLED
public static final boolean DEFAULT_SELF_HEALING_ENABLED
- See Also:
- Constant Field Values
-
-
Method Detail
-
setTestListener
public void setTestListener(DefaultSelfHealingService.TestListener listener)
-
removeTestListener
public void removeTestListener()
-
addItemToHeal
public void addItemToHeal(ItemToHeal itemToHeal)
Description copied from interface:SelfHealingServiceAdds 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:
addItemToHealin interfaceSelfHealingService- Parameters:
itemToHeal- item for later scheduled processing
-
isEnabled
public boolean isEnabled()
Description copied from interface:SelfHealingServiceTells whether the self healing process is enabled.- Specified by:
isEnabledin interfaceSelfHealingService
-
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.propertiesself.healing.intervalandself.healing.enabledSessionService is needed for disabling scheduler calls for this method during junit tests. When Spring makes a call it will only get global
scheduler.selfhealing.enabledflag. 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 java.lang.Exception- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
java.lang.Exception
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.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
-
-