My application requires access to certain Objects throughout the application. These objects are populated through the DB.
I would like to populate the objects on server startup , and then in the application on a need -to -do basis.
What is the best pattern to implement this, i have read about the Registry pattern, but not sure that is exactly what i want.
I am also using Spring 3.x in my application , is there something in Spring that can help me?
Since you say you are using Spring. The best solution is to use FactoryBean. What this class allows you to do is create a bean of whatever type you like and return it to the Spring context. Spring will manage this bean and expose it to other beans by making it a singleton. An example:
Above does two things. 1) Extends
SimpleJdbcSupportwhich allows you to have access to the databse, and 2) ImplementsFactoryBeanwhich returns the object to Spring’s context. After this is done, you can@Autowireit or use it in the xml file.