开发者

Custom Context in Spring-WS

I am trying to customize the spring-ws servlet context in a similar manner as I did for my spring context. For the initial context (initialized when the server starts), I have extended the ContextLoader and implemented the ServletContextListener class, which is similar to what the org.springframework.web.context.ContextLoaderListener class does. I am able to customize the initial context by overriding the customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) method, and add/remove optional context xml files based on properties. I was able to set this class as the listener in my web.xml file instead of the default ContextLoaderListener from Spring, and it works as expected.

I am looking to take a similar approach for the spring-ws servlet context (all of the beans defined in WEB-INF\spring-ws-servlet.xml), but I have not been able to find any solution to this. The only thing I can think of doing is having my custom context loader also generate an xml file with the 'optional' beans to include, and have the spring-ws-servlet context import this. However, this is a hack-job of a solution and I think there has to be a better approach. Does anyone have any suggestions on how to customize the spring-ws servlet context when the f开发者_JAVA技巧irst web service is called?

I am using Spring 2.5.6 & Spring-WS 1.5.9

Thanks in advance.


I was able to find a solution to this. I created a class that extended the MessageDispatcherServlet, and overrode the postProcessWebApplicationContext method. In that method, I conditionally add in my optional context locations according to my properties. After this method is called, the parent calls the refresh() method on the context, and the additional contexts will be loaded.

Another solution someone suggested to me was creating a custom namespace, and create a namespace handler to perform the imports if the conditions were met.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜