My application needs some meta data configuration to be loaded at server start up. Meta data are annotations and its do-it-once-forget it-and-use kind. So reading annotations and loading the MetaData objects involves lot of reflection hence I want to do it only once.
Is there any way other than using using Singletons ? I saw @Singleton EJBs which may serve the purpose. But I’m using EJB 3.0 hence that support is not available.
Do you see any other approach (efficient and simple) I can use for this purpose ?
To be more clear :
Using annotations on some classes we are building some configuration objects, that’ll be used throughout the application. Hence reading the annotations and building the config objects has to be done only once.
I have found solution for the problem.
I have a
@PostConstructannotated method which reads all the configuration meta data and create the objects. And in the EJB deployment descriptor I configure theinitial-number of beans in poolas 1 and alsomaximum number of beansas 1. Hence this would be a singleton and at the same time would be loaded on server startup.