Spring ApplicationContext
Say i initialize the spring IOC container in web.xml as follows..
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
some files
</param-value>
</context-param>
<listener> <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
</listener>
How can i programmatically get a reference to that instance of ApplicationContext.. or better yet to the beans i defined in the list of files.
Only way i know of is to..
appCtx = new ClassPathXmlApplicationContext(SPRING_XML_FILES);
BeanFactory factory = (BeanFactory) appCtx;
SomeObject o = (SomeObject) appCtx.getBean("somebean");
But then im just duplicating code.:mad:
Whats the point of setting it up in web.xml then if i just have to put int he config files again?
Is there some static method like Spring.getCurrentInstance or ApplicationContext.getCurrentInstance etc.....