close

Filter

loading table of contents...

Content Application Developer Manual / Version 2406.0

Table Of Contents

4.1.3 Spring Configuration

In order for the CoreMedia CAE to instantiate the right classes at runtime, they need to be configured with the factory. The engine's default factory implementation uses the Spring application context to instantiate content beans. This way content beans can participate in Spring's dependency injection mechanism - for example, they can receive references to other services without having to resort to service lookups in JNDI or the servlet context.

The content type to content beans mapping is defined using Spring’s XML notation. It should contain a prototype definition for each class corresponding to a content type.

Prototype definitions follow a specific naming scheme. In order to be found by the factory, they must be given the same name as the factory, followed by a colon ‘:’ and the name of the content type for which they were used. For example, a class com.company.Article that represents Article content items is registered with the factory as follows:

<bean
   name="contentBeanFactory:Article"
   parent="abstractContentBean"
   scope="prototype"
   class="com.company.ArticleImpl "/>

This line is a template for the content bean factory; it says:

  • This is a definition for a content factory bean for the content type Article

  • The bean might inherit configuration settings from a parent bean. This can simplify the configuration but is not mandatory.

  • This definition is a prototype, not a singleton, it must be newly instantiated for every article content item

  • The implementation class is com.company.ArticleImpl

In short this reads as: "for content items of type Article, return a new instance of class com.company.ArticleImpl".

Note

Note

Important: using scope="prototype" is vital, otherwise Spring would cache one instance and return the same object every time.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.