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.
ไม่มีความคิดเห็น:
แสดงความคิดเห็น