Why there are two separate xml files - <extension>-beans.xml & <extension>-spring.xml in Hybris?

柔情痞子 提交于 2019-12-06 02:58:17

As we know Hybris is following layered architecture where we are fetching the data from the persistence layer (Database) in the form of Model and send the result to presentation layer in the form of DTO (data transfer object).

<extension>-beans.xml -

We create the Data objects in a declarative way, for eg define beans and enumerations in an xml file used as input for code generating. The main advantage is that you can merge attributes over several extensions

In short to create DTO, we are using -beans.xml which will then be used in controller to show the result in jsp.

<bean class="de.hybris.platform.test.data.CustomerData">
    <description>Data object representing CustomerData</description>
    <property name="name" type="String"/>
    <property name="email" type="String"/>
    <property name="phone" type="String" />
</bean>

Converter/Populators are being used to populate the DTO.

<extension>-spring.xml -

This file is used to defined your class beans (like facade, service, dao, strategy etc).

<bean id="defaultProductService" class="de.com.test.DefaultProductService"/>

Typically the *beans.xml files in Hybris are used to represent a data model (like has been mentioned above). These files are read by the platform and from this, the DTOs are auto generated.

Beans declared in a *spring.xml file are not auto generated.

https://wiki.hybris.com/display/release5/Generating+Beans+and+Enums has some more information on this.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!