From: funkman Date: Wed, 3 Jan 2007 11:59:32 +0000 (+0000) Subject: Update on http://issues.apache.org/bugzilla/show_bug.cgi?id=41260 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f31bae12641e24cc359125ad5b1f32622719db18;p=tomcat7.0 Update on issues.apache.org/bugzilla/show_bug.cgi?id=41260 Added warnings this should be for dev IDEs, not production. git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@492112 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/loader/VirtualWebappLoader.java b/java/org/apache/catalina/loader/VirtualWebappLoader.java index d58bb7082..7b8661fb4 100755 --- a/java/org/apache/catalina/loader/VirtualWebappLoader.java +++ b/java/org/apache/catalina/loader/VirtualWebappLoader.java @@ -34,6 +34,14 @@ import org.apache.catalina.LifecycleException; * virtualClasspath="\dir\classes;\somedir\somejar.jar"/> * </Context> * + * + * + * This is not meant to be used for production. + * Its meant to ease development with IDE's without the + * need for fully republishing jars in WEB-INF/lib + * + * + * * @author Fabrizio Giustina * @version $Id: $ */ diff --git a/java/org/apache/naming/resources/VirtualDirContext.java b/java/org/apache/naming/resources/VirtualDirContext.java index fef63a4d9..03873ee3c 100755 --- a/java/org/apache/naming/resources/VirtualDirContext.java +++ b/java/org/apache/naming/resources/VirtualDirContext.java @@ -45,6 +45,13 @@ import org.apache.naming.NamingEntry; * virtualClasspath="\dir\classes;\somedir\somejar.jar"/> * </Resources> * + * + * + * This is not meant to be used for production. + * Its meant to ease development with IDE's without the + * need for fully republishing jars in WEB-INF/lib + * + * * @author Fabrizio Giustina * @version $Id: $ */ @@ -57,6 +64,12 @@ public class VirtualDirContext extends FileDirContext { private Map virtualMappings; /** + * Map containing a mapping for tag files that should be loaded from the + * META-INF dir of referenced jar files. + */ + private Map tagfileMappings; + + /** * ; separated list of virtual path elements. */ private String virtualClasspath; @@ -79,6 +92,7 @@ public class VirtualDirContext extends FileDirContext { super.allocate(); virtualMappings = new Hashtable(); + tagfileMappings = new Hashtable(); // looks into any META-INF dir found in classpath entries for tld files. StringTokenizer tkn = new StringTokenizer(virtualClasspath, ";"); @@ -110,6 +124,23 @@ public class VirtualDirContext extends FileDirContext { if (virtualMappings.containsKey(tldName)) { return new FileResourceAttributes(virtualMappings.get(tldName)); } + } else if (name.startsWith("/META-INF/tags") && name.endsWith(".tag") + || name.endsWith(".tagx")) { + + // already loaded tag file + if (tagfileMappings.containsKey(name)) { + return new FileResourceAttributes(tagfileMappings.get(name)); + } + + // unknown tagfile, search for it in virtualClasspath + StringTokenizer tkn = new StringTokenizer(virtualClasspath, ";"); + while (tkn.hasMoreTokens()) { + File file = new File(tkn.nextToken(), name); + if (file.exists()) { + tagfileMappings.put(name, file); + return new FileResourceAttributes(file); + } + } } return super.getAttributes(name); @@ -137,6 +168,15 @@ public class VirtualDirContext extends FileDirContext { if (virtualMappings.containsKey(tldName)) { return new FileResource(virtualMappings.get(tldName)); } + } else if (name.startsWith("/META-INF/tags") && name.endsWith(".tag") + || name.endsWith(".tagx")) { + + // already loaded tag file: we are sure that getAttributes() has + // already been called if we are here + File tagFile = tagfileMappings.get(name); + if (tagFile != null) { + return new FileResource(tagFile); + } } return super.lookup(name);