Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Registering Entity Beans

Registering Entity Beans

Elastic Path Core Commerce uses the Spring bean factory to create entity beans when required. Out-of-the-box beans are defined in core's src/main/resources/spring/prototypes/prototypes.xml. To register entity beans, you add the bean definition to your extension project's <webapp>-plugin.xml, located in src/main/resources/META-INF/conf. If you're overriding an existing bean definition, make sure the bean ID is the same as the original and that the class points to your extension class.


Be sure to set the bean's scope attribute to prototype.

For example, prototypes.xml contains the following definition for the product bean:

<bean id="product" scope="prototype" class="com.elasticpath.domain.catalog.impl.ProductImpl"/>

Suppose you override this class with com.extensions.domain.catalog.impl.MyExtProductImpl. You just need to add the following bean definition to to your JAR extension's src/main/resources/META-INF/conf/<webapp>-plugin.xml file:

<bean id="product" scope="prototype" class="com.extensions.domain.catalog.impl.MyExtProductImpl"/>
Note: Bean Definition Clutter

Continually adding bean definitions to <webapp>-plugin.xml can lead to clutter. By using the import mechanism, you can store your custom and override bean definitions in files within a directory structure that mirrors the out-of-the-box application. For example, to override, bean definitions in storefront's serviceSF.xml and url-mapping.xml, recreate the directory structure of the OOTB project under conf and create Spring configuration files with the same names in the appropriate locations. Then import them into ep-storefront-plugin.xml as follows:

    <import resource="classpath*:spring/service/serviceSF.xml"/>
    <import resource="classpath*:spring/web/url-mapping.xml"/>

Note that these files should only contain your custom and overriding bean definitions. Do not include any out-of-the-box bean definitions.