为什么有两个单独的xml文件 - < extension> -beans.xml& hybris中< extension> -spring.xml? [英] Why there are two separate xml files - <extension>-beans.xml & <extension>-spring.xml in Hybris?

查看:162
本文介绍了为什么有两个单独的xml文件 - < extension> -beans.xml& hybris中< extension> -spring.xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Hybris的新手并且对其中的扩展结构感到困惑。
每当我们创建任何扩展时,它都包含两个XML文件:
-beans.xml和-spring.xml

I am new to Hybris and was little confused about the structure of an extension in it. Whenever we create any extension, it contains two XML files : -beans.xml and -spring.xml

< extension> -beans.xml 文件包含bean及其属性的定义,换句话说就是DTO。

<extension>-beans.xml file contains definition for beans and their attributes or in other words, the DTOs.

< extension> -spring.xml 还包含一些bean及其属性的定义。

<extension>-spring.xml also contains definition for some beans and their attributes.

这是我目前所理解的。如果我错了,请纠正我。

This is what I understood so far. Please correct me if I am wrong.

当我们可以在 spring.xml 中定义bean时,为什么会有需要另一个XML文件 beans.xml

When we can define beans in spring.xml, why there is a need for another XML file "beans.xml" ?

请提供一些澄清。
谢谢。

Please provide some clarification on this. Thanks.

推荐答案

我们知道Hybris遵循分层架构,我们从持久层获取数据(数据库)以模型的形式,并以DTO(数据传输对象)的形式将结果发送到表示层。

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 -

我们以声明的方式创建Data对象,例如在xml文件中定义bean和枚举用作代码生成的输入。主要的优点是你可以在几个扩展名上合并属性

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

简而言之,为了创建DTO,我们使用-beans。然后将在控制器中使用xml以在jsp中显示结果。

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>

转换器/ Populator正用于填充DTO。

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 =defaultProductServiceclass =de.com.test.DefaultProductService/>

这篇关于为什么有两个单独的xml文件 - &lt; extension&gt; -beans.xml&amp; hybris中&lt; extension&gt; -spring.xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆