Cockpit Data Integration Layer of the Backoffice Framework
Backoffice Framework provides generic widgets for working with data, including the ability to perform CRUD operations, modify permissions, and run searches. Examples of such widgets include Editor Area, List View, and Text Search. These widgets are independent from the underlying platform through their use of the Cockpit Data Integration abstraction layer.
You do not have to use Cockpit Data Integration. You can still write widgets without this layer that, for example, perform CRUD operations in the Platform. However, because the backoffice extension is shipped with default implementations of Cockpit Data Integration, using them makes it easier to develop widgets that perform such operations.
Overview
One of the key features of the Cockpit Data Integration is its extensibility. You can plug in strategies to add support for your custom domain model. As shown in the following diagram, this layer can be a connection point between Backoffice Framework components and any data-related layer.
Figure: Cockpit Data Integration layer used in the Platform.
As shown in the following diagram, the Cockpit Data Integration is made up of the following parts:
- ObjectFacade: The actual CRUD logic.
- TypeFacade: Type meta information.
- PermissionFacade: Type and instance-based permission management.
- FieldSearchFacade: Search engine based on field conditions.
- PermissionManagementFacade: Permission description for principals.
Figure: Cockpit Data Integration Diagram
Façade strategies are the integration points between the Backoffice Framework and the data layer such as the Platform. The backoffice extension is shipped with the following default implementations of façade strategies interfaces:
|
Backoffice Framework Interface |
Platform Implementation |
|---|---|
|
TypeFacadeStrategy |
DefaultPlatformTypeFacadeStrategy |
|
ObjectFacadeStrategy |
DefaultPlatformObjectFacadeStrategy |
|
PermissionFacadeStrategy |
DefaultPlatformPermissionFacadeStrategy |
|
FieldSearchFacadeStrategy |
DefaultPlatformFieldSearchFacadeStrategy |
|
PermissionManagementFacadeStrategy |
DefaultPlatformPermissionManagementFacadeStrategy |
Defining and Registering Custom Strategies
To define custom strategies, you can extend the default strategy or you can create one through implementation of a Name FacadeStrategy interface. You can register one custom strategy per type.
For example, if you wanted to extend the default implementation for object management, and then replace the default implementation for types, you would do the following:
- Create your custom strategies. You need:
- A custom MyObjectFacadeStrategy class that extends DefaultPlatformObjectFacadeStrategy.
- A custom MyTypeFacadeStrategy class that implements TypeFacadeStrategy.
-
In the Spring application context, declare the beans and register the new strategies, as shown in the following example.
myextension-backoffice-spring.xml
<bean class="com.hybris.cockpitng.dataaccess.util.DataAccessStrategyExtender" lazy-init="false" init-method="addAll" destroy-method="removeAll"> <property name="objectFacadeStrategies"> <list> <bean class="org.training.services.MyObjectFacadeStrategy" parent="defaultPlatformObjectFacadeStrategy"/> </list> </property> <property name="typeFacadeStrategies"> <list> <bean class="org.training.services.MyTypeFacadeStrategy"/> </list> </property> <property name="objectFacadeStrategyRegistry" ref="objectFacadeStrategyRegistry"/> <property name="typeFacadeStrategyRegistry" ref="typeFacadeStrategyRegistry"/> </bean>