SAP Knowledge Base Article - Preview

2020897 - Maintenance Framework - How to decide between Static or Dynamic Strategy

Symptom

Since hybris version 4.6, you are able to clean up instances of a specific type by using the maintenance framework. There are two ways to achieve this: statically or dynamically.

Statically

  • Create your own strategy class for searching and processing, which implements the MaintenanceCleanupStrategy interface.

public interface MaintenanceCleanupStrategy<T extends ItemModel, C extends CronJobModel>
{

FlexibleSearchQuery createFetchQuery(C cjm);

void process(List<T> elements);
}

Register the new bean in the Spring context. It must extend the abstractGenericMaintenanceJobPerformable bean.


<bean id="yourNewMaintenanceJobPerformable" parent="abstractGenericMaintenanceJobPerformable" scope="tenant">
        <property name="yourNewStrategy"> 
            <bean class="de.hybris.platform.jobs.maintenance.impl.YourNewStrategy" scope="tenant">
                <property name="flexibleSearchService" ref="flexibleSearchService"/>
                <property name="modelService" ref="modelService"/>
                                ...
            </bean>
        </property>
    </bean>

  • After rebuilding and updating your platform, you will have your new Performable job available and ready to assign to your cronjob.

 

Dynamically

The maintenance framework provides a ready-to-use dynamicallyMaintenancePerformable job. That means you don't need to create any new classes and you can perform the clean-up task in runtime by fulfilling two attributes: searchCode and cleanupCode. For each attribute, you have to provide a BeanShell script. The bean is called dynamicallyMaintenancePerformable in /platform/ext/platformservices/resources/jobs-spring.xml.

A small thing worth mentioning is if no cleanupCode is provided, the default behavior is iterating through the list and calling modelService.remove on each model.

 


Read more...

Environment

CPA-COR 4.6.0 and later.

Product

SAP hybris Commerce Suite 5.2 ; SAP hybris Commerce Suite 5.3 ; hybris Commerce Suite 4.6 ; hybris Commerce Suite 4.7 ; hybris Commerce Suite 4.8 ; hybris Commerce Suite 5.0 ; hybris Commerce Suite 5.1

Keywords

KBA , CEC-COM-CPS-COR , SAP Commerce Core , How To

About this page

This is a preview of a SAP Knowledge Base Article. Click more to access the full version on SAP for Me (Login required).

Search for additional results

Visit SAP Support Portal's SAP Notes and KBA Search.