Chapter 36. Migration from Seam 2 to Java EE and Alternatives

This chapter details migration of Seam 2 to Java EE 6 and, where Java EE 6 is lacking, to alternatives such as DeltaSpike.

36.1. Initialization and life cycle callbacks

Seam 2 supports standard @PostConstruct and @PreDestroy annotations for designating post-initialization and pre-destruction callbacks. Seam 2 also provides Seam-specific alternatives (@Create and @Destroy) with identical semantics.

CDI only supports the standard annotations. If you are using the Seam-specific annotations in a legacy application, the easiest solution is to replace them with the standard ones.

The advantage of using CDI is that it provides richer initialization facilities such as:
  • dependency injection using the bean constructor (which allows for using dependency injection in immutable objects)
  • dependency injection using initializer methods

For more details, see the CDI specification.