Magnolia 5.3 reached end of life on June 30, 2017. This branch is no longer supported, see End-of-life policy.

Page tree
Skip to end of metadata
Go to start of metadata

Magnolia can be integrated in various ways ranging from filters and servlets to full Java framework integration.

Custom filter

Additional filters can be added in the filter chain or web.xml file. If you add them in the filter chain you benefit from Magnolia features such as security and caching. The additional filter can take over the handling of the request or delegate it to the remaining filter chain.

Custom servlet

An independent servlet can be registered in the servlet filter. The easiest way to do so is to register the servlet in the module descriptor. If the servlet maps to the request it will be responsible for rendering.

Forwarding a request

As the Magnolia main filter is registered on forward, any servlet or filter can internally forward to a Magnolia page. This is normally used if the servlet executes some business logic but the result should be rendered in a Magnolia page. This strategy is often used to combine Magnolia with other frameworks. The servlet typically puts the results into the request attributes which are exposed in Magnolia through the context.

Custom renderer

A custom renderer is needed if you like to support different template script languages or want to perform additional processing. The template definition will then be of custom type. If you need to delegate the rendering to a servlet you can use a template definition of type servlet.

Model class

Model is a Java program that holds your business logic. The model can do any task required (such as execute a Google search or calculate an insurance policy).
A template definition can be used to further define a modelClass.

Process:

  • The model holds the results of the logic execution and passes them to a renderer.
  • The renderer includes the results on the page as instructed by the template script.
  • The script contains placeholders for content attributes (such as headings, images and the results of the business logic execution) and tells the renderer where to place the content.

See also Templates.

Blossom Spring integration module

Probably the most advanced integration mechanism is provided by the Blossom module which is an integration with the Spring application framework. The Blossom module provides:

  • Programmatic registration. Dialogs, page templates and paragraphs can be registered by code or annotations rather than by configuring them.
  • Spring MVC or WebFlow for page templates and paragraphs. This allows you to combine Spring with the authoring facilities of Magnolia.
  • Pre-execution of paragraphs. Enables the use of redirects and forwards in the execution of a paragraph. The execution is bound to a specific paragraph which allows you to have multiple instances of the same paragraph on the same page.

For more information see Blossom module.

Direct calls to rendering engine

Any Java code can call the rendering engine to let it render pages or paragraph snippets. The caller will pass a Writer object to which the result is written. If you use a ByteArrayOutputStream the result can be read into a String.

This is only possible if all involved template scripts are FreeMarker scripts. JSP scripts depend on a request.

Web services, AJAX and snippets

External applications can make requests to Magnolia to get rendered content/snippets. Magnolia supports for instance direct requests to components.
For example, to render just the teasers on the About page, request the teaser component's own URL: http://demopublic.magnolia-cms.com/demo-project/about/content/0.html.

Reading content directly

If the Magnolia context is initialized, which is for instance the case if the context filter was executed, you can read content directly from it: MgnlContext.getJCRSession(String workspaceName).

REST API

Magnolia's REST Web service allows you to manipulate content through a Web API. You can create, read, update and delete nodes in the JCR. The nodes can be pages, components, contacts or anything else that is stored in a named workspace. You can also execute commands to activate, export and import content.

The REST service is similar to the Data module in Magnolia 4.5 which pulled data from other sources into Magnolia. However, REST works with the push principle where your application communicates with a Magnolia REST endpoint and exchanges a representation of a resource such as an XML of a page. REST is useful for connection tasks. Use REST to push product data from a third party system into Magnolia and let editors enrich it in a Magnolia app, for example.

See: REST API