Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 88219D7CE for ; Tue, 26 Jun 2012 22:02:33 +0000 (UTC) Received: (qmail 32776 invoked by uid 500); 26 Jun 2012 22:02:30 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 32685 invoked by uid 500); 26 Jun 2012 22:02:30 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 32617 invoked by uid 99); 26 Jun 2012 22:02:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jun 2012 22:02:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jun 2012 22:02:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 41F882388A4A for ; Tue, 26 Jun 2012 22:02:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1354255 - in /tomcat/trunk: java/org/apache/catalina/startup/WebRuleSet.java test/org/apache/naming/resources/TestNamingContext.java test/webapp-3.0/WEB-INF/web.xml Date: Tue, 26 Jun 2012 22:02:05 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120626220206.41F882388A4A@eris.apache.org> Author: markt Date: Tue Jun 26 22:02:04 2012 New Revision: 1354255 URL: http://svn.apache.org/viewvc?rev=1354255&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53465 Populate mapped-name property for resources defined in web.xml Based on a patch by Violeta Georgieva Modified: tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java tomcat/trunk/test/webapp-3.0/WEB-INF/web.xml Modified: tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java?rev=1354255&r1=1354254&r2=1354255&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java (original) +++ tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java Tue Jun 26 22:02:04 2012 @@ -24,6 +24,7 @@ import java.util.ArrayList; import org.apache.catalina.deploy.ContextHandler; import org.apache.catalina.deploy.ContextService; +import org.apache.catalina.deploy.ResourceBase; import org.apache.catalina.deploy.SecurityConstraint; import org.apache.catalina.deploy.ServletDef; import org.apache.catalina.deploy.WebXml; @@ -493,6 +494,8 @@ public class WebRuleSet extends RuleSetB "setLocal", 0); digester.addCallMethod(fullPrefix + "/ejb-local-ref/local-home", "setHome", 0); + digester.addRule(fullPrefix + "/ejb-local-ref/mapped-name", + new MappedNameRule()); configureInjectionRules(digester, "web-app/ejb-local-ref/"); //ejb-ref @@ -513,6 +516,8 @@ public class WebRuleSet extends RuleSetB "setHome", 0); digester.addCallMethod(fullPrefix + "/ejb-ref/remote", "setRemote", 0); + digester.addRule(fullPrefix + "/ejb-ref/mapped-name", + new MappedNameRule()); configureInjectionRules(digester, "web-app/ejb-ref/"); //env-entry @@ -529,6 +534,8 @@ public class WebRuleSet extends RuleSetB "setType", 0); digester.addCallMethod(fullPrefix + "/env-entry/env-entry-value", "setValue", 0); + digester.addRule(fullPrefix + "/env-entry/mapped-name", + new MappedNameRule()); configureInjectionRules(digester, "web-app/env-entry/"); //resource-env-ref @@ -541,6 +548,8 @@ public class WebRuleSet extends RuleSetB "setName", 0); digester.addCallMethod(fullPrefix + "/resource-env-ref/resource-env-ref-type", "setType", 0); + digester.addRule(fullPrefix + "/resource-env-ref/mapped-name", + new MappedNameRule()); configureInjectionRules(digester, "web-app/resource-env-ref/"); //message-destination @@ -559,6 +568,8 @@ public class WebRuleSet extends RuleSetB "setSmallIcon", 0); digester.addCallMethod(fullPrefix + "/message-destination/message-destination-name", "setName", 0); + digester.addRule(fullPrefix + "/message-destination/mapped-name", + new MappedNameRule()); //message-destination-ref digester.addObjectCreate(fullPrefix + "/message-destination-ref", @@ -576,7 +587,8 @@ public class WebRuleSet extends RuleSetB "setType", 0); digester.addCallMethod(fullPrefix + "/message-destination-ref/message-destination-usage", "setUsage", 0); - + digester.addRule(fullPrefix + "/message-destination-ref/mapped-name", + new MappedNameRule()); configureInjectionRules(digester, "web-app/message-destination-ref/"); //resource-ref @@ -595,6 +607,8 @@ public class WebRuleSet extends RuleSetB "setScope", 0); digester.addCallMethod(fullPrefix + "/resource-ref/res-type", "setType", 0); + digester.addRule(fullPrefix + "/resource-ref/mapped-name", + new MappedNameRule()); configureInjectionRules(digester, "web-app/resource-ref/"); //service-ref @@ -652,9 +666,9 @@ public class WebRuleSet extends RuleSetB "addSoapRole", 0); digester.addCallMethod(fullPrefix + "/service-ref/handler/port-name", "addPortName", 0); + digester.addRule(fullPrefix + "/service-ref/mapped-name", + new MappedNameRule()); configureInjectionRules(digester, "web-app/service-ref/"); - - } protected void configureInjectionRules(Digester digester, String base) { @@ -1246,6 +1260,31 @@ final class TaglibLocationRule extends R "taglib definition not consistent with specification version"); } } +} + +/** + * A Rule that sets mapped name on the ResourceBase. + */ +final class MappedNameRule extends Rule { + public MappedNameRule() { + // NO-OP + } + /** + * Process the body text of this element. + * + * @param namespace the namespace URI of the matching element, or an + * empty string if the parser is not namespace aware or the element has + * no namespace + * @param name the local name if the parser is namespace aware, or just + * the element name otherwise + * @param text The body text of this element + */ + @Override + public void body(String namespace, String name, String text) + throws Exception { + ResourceBase resourceBase = (ResourceBase) digester.peek(); + resourceBase.setProperty("mappedName", text.trim()); + } } \ No newline at end of file Modified: tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java?rev=1354255&r1=1354254&r2=1354255&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java (original) +++ tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java Tue Jun 26 22:02:04 2012 @@ -480,4 +480,29 @@ public class TestNamingContext extends T } } } + + @Test + public void testBug53465() throws Exception { + Tomcat tomcat = getTomcatInstance(); + tomcat.enableNaming(); + + File appDir = + new File("test/webapp-3.0"); + // app dir is relative to server home + org.apache.catalina.Context ctxt = + tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); + + tomcat.start(); + + ByteChunk bc = new ByteChunk(); + int rc = getUrl("http://localhost:" + getPort() + + "/test/bug53465.jsp", bc, null); + + Assert.assertEquals(HttpServletResponse.SC_OK, rc); + Assert.assertTrue(bc.toString().contains("

10

")); + + ContextEnvironment ce = + ctxt.getNamingResources().findEnvironment("bug53465"); + Assert.assertEquals("Bug53465MappedName", ce.getProperty("mappedName")); + } } Modified: tomcat/trunk/test/webapp-3.0/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/WEB-INF/web.xml?rev=1354255&r1=1354254&r2=1354255&view=diff ============================================================================== --- tomcat/trunk/test/webapp-3.0/WEB-INF/web.xml (original) +++ tomcat/trunk/test/webapp-3.0/WEB-INF/web.xml Tue Jun 26 22:02:04 2012 @@ -116,4 +116,13 @@ BASIC + + + Resource for testing bug 53465 + bug53465 + 10 + java.lang.Integer + Bug53465MappedName + + \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org