You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by sl...@apache.org on 2011/12/02 21:49:52 UTC
svn commit: r1209686 [2/2] - in /tomcat/trunk:
java/org/apache/catalina/core/ java/org/apache/catalina/loader/
java/org/apache/catalina/startup/ java/org/apache/naming/resources/
test/org/apache/catalina/loader/ test/webapp-3.0-virtual-webapp/ test/web...
Propchange: tomcat/trunk/test/webapp-3.0-virtual-webapp/src/main/webapp2/rsrc/resourceH.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/trunk/test/webapp-3.0-virtual-webapp/src/main/webapp2/rsrc2/resourceJ.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0-virtual-webapp/src/main/webapp2/rsrc2/resourceJ.properties?rev=1209686&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0-virtual-webapp/src/main/webapp2/rsrc2/resourceJ.properties (added)
+++ tomcat/trunk/test/webapp-3.0-virtual-webapp/src/main/webapp2/rsrc2/resourceJ.properties Fri Dec 2 20:49:50 2011
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+resourceJInWebapp=true
Propchange: tomcat/trunk/test/webapp-3.0-virtual-webapp/src/main/webapp2/rsrc2/resourceJ.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/webapps/docs/config/context.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/context.xml?rev=1209686&r1=1209685&r2=1209686&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/context.xml (original)
+++ tomcat/trunk/webapps/docs/config/context.xml Fri Dec 2 20:49:50 2011
@@ -539,6 +539,8 @@
<code>docBase</code> instead.</p>
<p>These external locations will not be emptied if the context
is un-deployed.</p>
+ <p>A more powerful feature (for development only) is
+ <a href="#Virtual_webapp">Virtual webapp</a>.</p>
</attribute>
<attribute name="allowLinking" required="false">
@@ -1251,6 +1253,82 @@
</subsection>
+ <subsection name="Virtual webapp">
+ <p>During development it may be more productive to avoid copying files (static
+ resources, JSPs, classes, jars...) and configure tomcat to use files from their
+ source locations. To do that, several customisations of the context configuration are
+ required:</p>
+ <ul>
+ <li>The <code>VirtualDirContext</code> implementation of
+ <a href="resources.html">Resources</a></li>
+ <li>The <code>VirtualWebappLoader</code> implementation of
+ <a href="loader.html">Loader</a></li>
+ <li><code>scanAllDirectories="true"</code> on the <a href="jar-scanner.html">JarScanner</a></li>
+ </ul>
+ <p>To illustrate this feature, here is an example of a standard maven webapp source tree:</p>
+<source>
+mywebapp/
+ src/
+ main/
+ java/
+ resources/
+ webapp/
+ WEB-INF/
+ classes/
+ target/
+ classes/
+</source>
+ <p>To deploy such an application (assuming it also uses the log4j maven artefact),
+ the context configuration looks like:</p>
+<source>
+<Context path="/mywebapp" docBase="/Users/theuser/mywebapp/src/main/webapp" >
+ <Resources className="org.apache.naming.resources.VirtualDirContext"
+ extraResourcePaths="/WEB-INF/classes=/Users/theuser/mywebapp/target/classes" />
+ <Loader className="org.apache.catalina.loader.VirtualWebappLoader"
+ virtualClasspath="/Users/theuser/mywebapp/target/classes;/Users/theuser/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15.jar" />
+ <JarScanner scanAllDirectories="true" />
+</Context>
+</source>
+
+ <p>Here is another example where the webapp serves pictures under /pictures and movies
+ under /movies and also depends on another maven project mylib that would normally
+ produce a jar to be packaged in WEB-INF/lib:</p>
+<source>
+mylib/
+ src/
+ main/
+ java/
+ resources/
+ META-INF/
+ resources/
+ target/
+ classes/
+mymovies/
+mypictures/
+mywebapp/
+ src/
+ main/
+ java/
+ resources/
+ webapp/
+ WEB-INF/
+ classes/
+ target/
+ classes/
+</source>
+ <p>The configuration is:</p>
+<source>
+<Context path="/mywebapp" docBase="/Users/theuser/mywebapp/src/main/webapp" >
+ <Resources className="org.apache.naming.resources.VirtualDirContext"
+ extraResourcePaths="/WEB-INF/classes=/Users/theuser/mywebapp/target/classes,/pictures=/Users/theuser/mypictures,/movies=/Users/theuser/mymovies" />
+ <Loader className="org.apache.catalina.loader.VirtualWebappLoader"
+ virtualClasspath="/Users/theuser/mywebapp/target/classes;/Users/theuser/mylib/target/classes;/Users/theuser/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15.jar" />
+ <JarScanner scanAllDirectories="true" />
+</Context>
+</source>
+ <p>Note that resources in mylib/target/classes/META-INF/resources/ are mapped to / as
+ required by servlet 3 specifications.</p>
+ </subsection>
</section>
Modified: tomcat/trunk/webapps/docs/config/resources.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/resources.xml?rev=1209686&r1=1209685&r2=1209686&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/resources.xml (original)
+++ tomcat/trunk/webapps/docs/config/resources.xml Fri Dec 2 20:49:50 2011
@@ -93,7 +93,28 @@
is configured by its parent Context element.</p>
</subsection>
-
+
+ <subsection name="VirtualDirContext implementation">
+ <p>This implementation of <strong>Resources</strong> is
+ <strong>org.apache.naming.resources.VirtualDirContext</strong> and is aimed to be used
+ during development to deploy a webapp without copying files to a webapp compliant
+ directory structure.
+ It extends <code>FileDirContext</code> and supports the following
+ additional attributes</p>
+
+ <attributes>
+ <attribute name="extraResourcePaths" required="false">
+ <p>Allows to map a path of the filesystem to a path in the webapp. Multiple
+ filesystem paths can be mapped to the same path in the webapp. Filesystem
+ path and virtual path must be separated by an equal signe (=). Pairs of paths
+ must be separated by a column.</p>
+ Example: <code>/=/Users/jdoe/mywebapp/src/main/webapp,/=/Users/jdoe/mywebapp/src/main/webapp2,/pictures=/Users/jdoe/sharedpictures</code>
+ <p>The path to the docBase (as declared in the Context) must not be added here.</p>
+ <p>This attribute enhances the feature provided by the <code>aliases</code>
+ attribute of the <strong>StandardContext</strong>.</p>
+ </attribute>
+ </attributes>
+ </subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org