The EJB 3.1: Singleton SessionBean

I was trying to find the standard way for initiating the global configuration for the EJB project as same it is done by using Servlet load-on-startup for the Web project. I finally found the following

The Class Annotation

@Singleton annotation which ensure the only on instance

@Startup annotation which ensure the loading will be done automatically when the container is being started.

The method annotation

@PostConstruct annotation which ensure it will be executed automatically after the instance has been initiated.

@PreDestroy annotation which ensure it will be executed automatically before the instance has been destroyed.

Please note, It is a session bean with no interface view and can be easily looked up via the JNDI or @EJB annotation as well. This approach is nice for me to load/unload my global configuration and hope it may be nice for you, too.

About Charlee Chitsuk

I've been working as a software developer since 1998. At the moment I focus on system integration including with SOA and Enterprise Security Solution.

Posted on July 1, 2010, in EJB and tagged . Bookmark the permalink. Leave a comment.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: