loading table of contents...

4.1.1.3. Programmatic Access to Content Beans

In order to "bootstrap" yourself into the world of content beans from the CoreMedia Unified API, you need to use the content bean factory programmatically, for example from within a Controller. The factory API is simple, the most relevant method is ContentBeanFactory#createBeanFor(Content). For example:

Content content = ... // for example through a query
Article article =
  (Article)contentBeanFactory.createBeanFor(content);

The controller needs access to the content bean factory. Since the controller itself typically is a bean defined in the application context, you can inject the factory reference into the controller object:

<bean id="myController" class="...">
  <property name="contentBeanFactory" ref="contentBeanFactory"/>
  ...
</bean>

This fragment will invoke #setContentBeanFactory on the controller supplying an instance of the referenced factory.