Author: violetagg
Date: Wed Feb 5 07:58:38 2014
New Revision: 1564660
URL: http://svn.apache.org/r1564660
Log:
Merged revision 1564461 from tomcat/trunk:
According to JavaEE specification (EE.5.4.1.3) when an env entry is specified
in the web deployment descriptor and with annotation then the definition in the
web deployment descriptor is with priority.
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/WebRuleSet.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfig.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TesterServletWithAnnotations.java
tomcat/tc7.0.x/trunk/test/webapp-3.0-fragments/WEB-INF/web.xml
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1564461
Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/WebRuleSet.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/WebRuleSet.java?rev=1564660&r1=1564659&r2=1564660&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/WebRuleSet.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/WebRuleSet.java Wed
Feb 5 07:58:38 2014
@@ -22,6 +22,7 @@ package org.apache.catalina.startup;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import org.apache.catalina.deploy.ContextEnvironment;
import org.apache.catalina.deploy.ContextHandler;
import org.apache.catalina.deploy.ContextService;
import org.apache.catalina.deploy.ResourceBase;
@@ -533,6 +534,7 @@ public class WebRuleSet extends RuleSetB
digester.addSetNext(fullPrefix + "/env-entry",
"addEnvEntry",
"org.apache.catalina.deploy.ContextEnvironment");
+ digester.addRule(fullPrefix + "/env-entry", new SetOverrideRule());
digester.addCallMethod(fullPrefix + "/env-entry/description",
"setDescription", 0);
digester.addCallMethod(fullPrefix + "/env-entry/env-entry-name",
@@ -1336,3 +1338,21 @@ final class LifecycleCallbackRule extend
super.end(namespace, name);
}
}
+
+final class SetOverrideRule extends Rule {
+
+ public SetOverrideRule() {
+ // no-op
+ }
+
+ @Override
+ public void begin(String namespace, String name, Attributes attributes)
+ throws Exception {
+ ContextEnvironment envEntry = (ContextEnvironment) digester.peek();
+ envEntry.setOverride(false);
+ if (digester.getLogger().isDebugEnabled()) {
+ digester.getLogger().debug(
+ envEntry.getClass().getName() + ".setOverride(false)");
+ }
+ }
+}
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfig.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfig.java?rev=1564660&r1=1564659&r2=1564660&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfig.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfig.java
Wed Feb 5 07:58:38 2014
@@ -143,7 +143,7 @@ public class TestContextConfig extends T
tomcat.start();
assertPageContains("/test/testServlet",
- "envEntry1: 1 envEntry2: 2 envEntry3: 33 envEntry4: 4");
+ "envEntry1: 1 envEntry2: 2 envEntry3: 33 envEntry4: 4
envEntry5: 55 envEntry6: 66");
}
@Test
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TesterServletWithAnnotations.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TesterServletWithAnnotations.java?rev=1564660&r1=1564659&r2=1564660&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TesterServletWithAnnotations.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TesterServletWithAnnotations.java
Wed Feb 5 07:58:38 2014
@@ -38,6 +38,11 @@ public class TesterServletWithAnnotation
private int envEntry4;
+ @Resource(name = "envEntry5", mappedName = "5")
+ private int envEntry5;
+
+ private int envEntry6;
+
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
@@ -46,6 +51,8 @@ public class TesterServletWithAnnotation
resp.getWriter().print(" envEntry2: " + envEntry2);
resp.getWriter().print(" envEntry3: " + envEntry3);
resp.getWriter().print(" envEntry4: " + envEntry4);
+ resp.getWriter().print(" envEntry5: " + envEntry5);
+ resp.getWriter().print(" envEntry6: " + envEntry6);
}
public void setEnvEntry2(int envEntry2) {
@@ -61,4 +68,9 @@ public class TesterServletWithAnnotation
public void setEnvEntry4(int envEntry4) {
this.envEntry4 = envEntry4;
}
+
+ @Resource(name = "envEntry6", mappedName = "6")
+ public void setEnvEntry6(int envEntry6) {
+ this.envEntry6 = envEntry6;
+ }
}
\ No newline at end of file
Modified: tomcat/tc7.0.x/trunk/test/webapp-3.0-fragments/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/webapp-3.0-fragments/WEB-INF/web.xml?rev=1564660&r1=1564659&r2=1564660&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/webapp-3.0-fragments/WEB-INF/web.xml (original)
+++ tomcat/tc7.0.x/trunk/test/webapp-3.0-fragments/WEB-INF/web.xml Wed Feb 5
07:58:38 2014
@@ -76,4 +76,14 @@
<injection-target-name>envEntry3</injection-target-name>
</injection-target>
</env-entry>
+ <env-entry>
+ <env-entry-name>envEntry5</env-entry-name>
+ <env-entry-type>java.lang.Integer</env-entry-type>
+ <env-entry-value>55</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>envEntry6</env-entry-name>
+ <env-entry-type>java.lang.Integer</env-entry-type>
+ <env-entry-value>66</env-entry-value>
+ </env-entry>
</web-app>
\ No newline at end of file
Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1564660&r1=1564659&r2=1564660&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Wed Feb 5 07:58:38 2014
@@ -136,6 +136,11 @@
constructing the address of a JMX API connector server. Patch is
provided by Jim Talbut. (violetagg)
</fix>
+ <fix>
+ When environment entry with one and the same name is defined in the web
+ deployment descriptor and with annotation then the one specified in the
+ web deployment descriptor is with priority. (violetagg)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]