Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Initializing a List in Interceptor (or EJB) in the deployment descripter

 
Markus Schmider
Ranch Hand
Posts: 130
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

is it possible to initialize a List in an Interceptor (or EJB) in the deployment descriptor?
I am trying to implement the Observer Pattern with an Interceptor as the Observable. The Observers must be injected into the Interceptor.
I thought I saw something like this but I cannot find an example. Perhaps I am confusing it with Spring.

I am using EJB 3.0.

Thanks,

Hans
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The spec doesn't have anything for initializing the state of the interceptors via deployment descriptors. Instead you can actually mark a specific method which would do the initialization (it's called a post-construct method). How you initiliaze that data in the post-construct method isn't governed by the spec.
 
Akshay Sahu
Greenhorn
Posts: 26
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

1. EJB 3 Interceptors can have method annotated @PostConstruct (Applicable for Stateless and Stateful Session Beans).

2. Write your observer update code into the post construct method that automatically updates the value at your desired location.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic