SeamFramework.orgCommunity Documentation

Chapter 80. Seam Spring - Architecture and Usage

80.1. Accessing Spring artifacts from CDI
80.1.1. Accessing Spring application contexts
80.1.2. Exposing Spring beans as CDI beans
80.2. Importing CDI beans into Spring applications
80.2.1. Registering a BeanManager
80.2.2. Importing a CDI bean as a Spring bean

The functionality of the Seam Spring module is provided by two sets of components:

The Seam Spring module uses the resource producer pattern for accessing Spring contexts and beans from within CDI. The Spring extension is responsible for producing the actual instances. This mechanism allows the Spring beans to participate in regular CDI injection and the injection targets to be agnostic of the provenience of the injected references, enforcing true separation of concerns. Through this mechanisms Spring contexts can be injected as Spring beans too, if necessary.

The resource producer pattern is used for:

The registration of Spring application contexts as CDI beans is a prerequisite for accessing the Spring beans that are created by them.

The Seam Spring module can access two types of contexts:

CDI applications can install Spring contexts as CDI beans by defining producer fields with the following general pattern:


ApplicationContext context;

This will create a CDI bean of the ApplicationContext type. The nature of the context (bootstrapped by the extension, or looked up elsewhere) is controlled by a specific annotation. The supported annotations are detailed in the following subsections.

The Seam Spring module also supports the registration of CDI beans as Spring beans as well. Once CDI beans are imported into a Spring ApplicationContext, they can be injected as regular Spring beans, either via XML or by annotations.

This can be done by using the dedicated CDI namespace, which can be defined as in the following example:

<beans xmlns=""

   <!-- bean definitions -->