Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Components

Ron Smeral edited this page Feb 19, 2015 · 6 revisions

Model differences

Seam 2 uses as a basic building block a Component. While Java EE 6 and CDI defines a Managed Bean as basic building block.

While both Seam 2 and CDI supports definition of metadata with help of annotations, Seam 2 XML configuration was left uncovered in CDI specification.

Table 1. Differences in component model
Seam 2 CDI Note

Session Bean

Session Bean

Java Bean

Managed Bean

Factory method

Producer method/field

A producer can inject parameters into a method while Seam 2 Factory method can not

Message-driven Bean

Message-driven Bean

In Seam 2 MDB may not be bound to a Seam context

Entity Bean

Entity Bean

In Seam 2 Entity beans do not support bijection or context demarcation

Resource

Reference to a Java EE resource

Component

Portable Extension

It may provide other kinds of beans

Additionally there are some differences how a Managed Bean is defined in comparison to Seam 2 Component. Look in the following table.

Table 2. Component metadata differences
Seam 2 component CDI Managed Bean Note

must have @Name

no need to have it

do not have to have @Named

available in EL

only if @Named is defined

Bijection

no bijection

seam.properties or components.xml

beans.xml

explicit definition

implicit recognition

every Java class in the bean archive that meets certain conditions is implicitly recognized as a managed bean — no special declaration is required, while Seam 2 needs @Name or inclusion in XML descriptor

Table 3. Component/Managed Bean metadata
Seam 2 CDI

name → @Name

name (optional) @Named

scope → @Scope

scope → every scope has special annotation

roles → @Roles
– single Java class to act as a base for multiple components (comprises name and a scope)

Bean type and @Qualifier
 — used to distinguish between multiple components sharing the same bean type

conditional installation → @Install

conditional installation → @Alternative,@Specializes,@Veto,@Requires

Asynchronicity

Seam 2 supports asynchronous method invocation via Dispatcher available components. Several implementations are available, like TimerService or Quartz Scheduler.

In contrast CDI does not specify asynchronous method invocation and you need to rely on EJB @Asynchronous observer methods.

Seam Bijection

Bijection is performed dynamically via an Interceptor for every component method invocation. Bijection is bidirectional injection and outjection.

CDI doesn’t support bijection and does a static injection, which is performed only once per component lifecycle:

  • when creating contextual objects

  • injection points: constructor, field, initializer method

  • typesafe resolution — the process of matching a bean to an injection point

  • bean is assignable to a given injection point if it has a bean type that matches the required type has all the required qualifiers

  • ambiguous and unsatisfied dependency is an error

  • no outjection and disinjection

  • beans are initialized automatically

Clone this wiki locally