Has anyone ever found cause to obtain a Spring app context from a static class method with a ThreadLocal so that it could be obtained by objects that aren't managed via Spring and aren't in a web context? Anyone armed with reasons against such an approach? I can think of one or two possible reasons against doing this myself, but they might not be enough to stop me. Just curious...
Thanks
-
Get Spring AppCtx outside web context & w/o Spring (1 messages)
- Posted by: Terry Martin
- Posted on: December 20 2005 00:56 EST
Threaded Messages (1)
- Get Spring AppCtx outside web context & w/o Spring by Jeryl Cook on December 28 2005 12:14 EST
-
Get Spring AppCtx outside web context & w/o Spring[ Go to top ]
- Posted by: Jeryl Cook
- Posted on: December 28 2005 12:14 EST
- in response to Terry Martin
Check out AbstractTransactionalDataSourceSpringContextTests
if your trying to unit test.
otherwise..
ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"/daoContext.xml","/datasource-junit.xml"});
IUserDAO userDAO = (IUserDAO)context.getBean("userDAO");