I found it simple enough to implement SpringMVC's strategy for initializing a context by initializing with an empty context. In normal application contexts, there is nothing that uses ApplicationContextInitializer, so you have to execute it yourself.
There is no problem, though, since in the framework of a regular J2SE application, if you have rights to the context loader block, you will have access to each stage of the life cycle.
// Create context, but dont initialize with configuration by calling // the empty constructor. Instead, initialize it with the Context Initializer. AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); MyAppContextInitializer initializer = new MyAppContextInitializer(); initializer.initialize( ctx ); // Now register with your standard context ctx.register( com.my.classpath.StackOverflowConfiguration.class ); ctx.refresh() // Get Beans as normal (eg Spring Batch) JobLauncher launcher = context.getBean(JobLauncher.class);
Hope this helps!
ring0Nerd
source share