Does spring (spring mvc) have an event that gets fired once, on application startup, where I can hook in and load some objects?
+1
A:
Can't you just use the normal initialization mechanisms of a singleton bean, e.g. @PostConstruct
or InitializingBean
? A singleton bean will only be created/initialized once at context startup.
Alternatively, you can implement the Lifecycle
interface, which gets callbacks from Spring when the context itself start up or shuts down, rather than the bean itself.
skaffman
2010-07-19 14:43:29
ah ok, that's perfect thanks for the suggestion.
Blankman
2010-07-19 14:59:12
+1
A:
If you are not going to refresh your application context, you can simply listen to
org.springframework.context.event.ContextRefreshedEvent
Adrian Shum
2010-07-19 14:47:53