I searched for a while, but cannot find the right solution to my problem.
I have one WAR web application, and I want 2 spring applications for the web part to work in it, one of which performed the scheduled task. There are many beans in both applications, so I would like these two applications to share an instance of beans.
I would like to split my contexts into:
-shared-context.xml
-web-context.xml
-task-context.xml
The web context and the task context must be isolated and not see each other. They need to create several beans that are the same but have different configurations.
Is it possible? And how do I do this?
I tried first to put <import resource="classpath:shared-context.xml" />in the context of the web context and tasks and configure my web.xml as
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>web-context.xml task-context.xml</param-value>
</context-param>
but the problem is that there is no isolation between the network and the task. They all share all the beans, even those defined in web-context.xml and task-context.xml
For information, here is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/web-context.xml /WEB-INF/task-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.gwtrpcspring.RemoteServiceDispatcher</servlet-class>
</servlet>
<servlet>
<servlet-name>contentDownloadServlet</servlet-name>
<servlet-class>ch.olator.servlet.MyContentDownloadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.rpc</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>contentDownloadServlet</servlet-name>
<url-pattern>/download</url-pattern>
</servlet-mapping>
... some irrelevant filters ...
</web-app>
UPDATED
To make things clearer, I need this isolation between the task and the network, because the task context that is used to run the scheduled task is to identify some beans that are in the web context, but in different ways. For instance. I have scoped-session beans that are in a web context, but I need to define them differently for tasks, since a scheduled task cannot use scoped-session beans.