PDA

View Full Version : Need access to ApplicationContext from outside of Views


darabi
Oct 14th, 2004, 03:01 PM
I'm in the middle of porting an application to spring rich (and spring) and have places in my code, where I would like to instantiate beans which are defined in my xml context files.

When I'm inside of classes which extend ApplicationServicesAccessorSupport, there is no problem, I just use the protected getApplicationContext().getBean(String).

But, when I want to do the same in my 'legacy' code, I'm stuck. Or maybe I'm just too dumb to find the correct way.

A static method like Application.getContext() would help a lot, but Spring people don't use 'static', do they ? :wink:

Any hint is appreciated.

Thanks

Kambiz

Keith Donald
Oct 14th, 2004, 04:08 PM
Application.services().getApplicationContext() should work!

darabi
Oct 14th, 2004, 04:26 PM
... Or maybe I'm just too dumb to find the correct way.


I knew that :-)

Thank you, Keith

Kambiz