Author: aadamchik
Date: Sun Mar 4 19:31:27 2012
New Revision: 1296860
URL: http://svn.apache.org/viewvc?rev=1296860&view=rev
Log:
ITS-1673 Running ROP and CayenneFilter on same project
while not fixing the issue, we'll be doing sanity checks for the Cayenne
configuration already present
to avoid unknowingly starting multiple stacks
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/rop/server/ROPHessianServlet.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/rop/server/ROPHessianServlet.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/rop/server/ROPHessianServlet.java?rev=1296860&r1=1296859&r2=1296860&view=diff
==============================================================================
---
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/rop/server/ROPHessianServlet.java
(original)
+++
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/rop/server/ROPHessianServlet.java
Sun Mar 4 19:31:27 2012
@@ -67,6 +67,8 @@ public class ROPHessianServlet extends H
*/
@Override
public void init(ServletConfig configuration) throws ServletException {
+
+ checkAlreadyConfigured(configuration.getServletContext());
this.servletContext = configuration.getServletContext();
@@ -104,6 +106,14 @@ public class ROPHessianServlet extends H
WebUtil.setCayenneRuntime(servletContext, runtime);
super.init(configuration);
}
+
+ protected void checkAlreadyConfigured(ServletContext context) throws
ServletException {
+ // sanity check
+ if (WebUtil.getCayenneRuntime(context) != null) {
+ throw new ServletException(
+ "CayenneRuntime is already configured in the servlet
environment");
+ }
+ }
@Override
public void destroy() {
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java?rev=1296860&r1=1296859&r2=1296860&view=diff
==============================================================================
---
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
(original)
+++
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
Sun Mar 4 19:31:27 2012
@@ -62,6 +62,8 @@ public class CayenneFilter implements Fi
public void init(FilterConfig config) throws ServletException {
+ checkAlreadyConfigured(config.getServletContext());
+
this.servletContext = config.getServletContext();
WebConfiguration configAdapter = new WebConfiguration(config);
@@ -69,12 +71,21 @@ public class CayenneFilter implements Fi
String configurationLocation =
configAdapter.getConfigurationLocation();
Collection<Module> modules = configAdapter.createModules(new
WebModule());
- ServerRuntime runtime = new ServerRuntime(configurationLocation,
modules
- .toArray(new Module[modules.size()]));
+ ServerRuntime runtime = new ServerRuntime(
+ configurationLocation,
+ modules.toArray(new Module[modules.size()]));
WebUtil.setCayenneRuntime(config.getServletContext(), runtime);
}
+ protected void checkAlreadyConfigured(ServletContext context) throws
ServletException {
+ // sanity check
+ if (WebUtil.getCayenneRuntime(context) != null) {
+ throw new ServletException(
+ "CayenneRuntime is already configured in the servlet
environment");
+ }
+ }
+
public void destroy() {
CayenneRuntime runtime = WebUtil.getCayenneRuntime(servletContext);