You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2001/01/20 20:41:30 UTC
cvs commit: jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core StandardContext.java StandardHost.java
remm 01/01/20 11:41:30
Modified: catalina/src/share/org/apache/catalina/core
StandardContext.java StandardHost.java
Log:
- StandardContext will now use the new WARDirContext if the url given ends
with ".war".
- Add a new "unpackWARs" flag in the StandardHost : if true, the host will
deploy WARs as before. If false, the WARs found in the host path won't
be unpacked and the WARDirContext will be used.
Revision Changes Path
1.37 +12 -6 jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core/StandardContext.java
Index: StandardContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- StandardContext.java 2001/01/14 19:58:30 1.36
+++ StandardContext.java 2001/01/20 19:41:29 1.37
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core/StandardContext.java,v 1.36 2001/01/14 19:58:30 remm Exp $
- * $Revision: 1.36 $
- * $Date: 2001/01/14 19:58:30 $
+ * $Header: /home/cvs/jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core/StandardContext.java,v 1.37 2001/01/20 19:41:29 remm Exp $
+ * $Revision: 1.37 $
+ * $Date: 2001/01/20 19:41:29 $
*
* ====================================================================
*
@@ -97,6 +97,7 @@
import org.apache.naming.ResourceEnvRef;
import org.apache.naming.TransactionRef;
import org.apache.naming.resources.FileDirContext;
+import org.apache.naming.resources.WARDirContext;
import org.apache.naming.resources.BaseDirContext;
import org.apache.catalina.Container;
import org.apache.catalina.ContainerListener;
@@ -136,7 +137,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.36 $ $Date: 2001/01/14 19:58:30 $
+ * @version $Revision: 1.37 $ $Date: 2001/01/20 19:41:29 $
*/
public class StandardContext
@@ -2911,7 +2912,10 @@
if (getResources() == null) { // (1) Required by Loader
if (debug >= 1)
log("Configuring default Resources");
- setResources(new FileDirContext());
+ if ((docBase != null) && (docBase.endsWith(".war")))
+ setResources(new WARDirContext());
+ else
+ setResources(new FileDirContext());
}
if (getLoader() == null) { // (2) Required by Manager
if (debug >= 1)
@@ -2924,6 +2928,9 @@
setManager(new StandardManager());
}
+ // Post work directory
+ postWorkDirectory();
+
// Standard container startup
if (debug >= 1)
log("Processing standard container startup");
@@ -2961,7 +2968,6 @@
if (debug >= 1)
log("Posting standard context attributes");
postWelcomeFiles();
- postWorkDirectory();
// Reload sessions from persistent storage if supported
try {
1.7 +64 -21 jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core/StandardHost.java
Index: StandardHost.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core/StandardHost.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StandardHost.java 2000/12/07 19:37:41 1.6
+++ StandardHost.java 2001/01/20 19:41:29 1.7
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core/StandardHost.java,v 1.6 2000/12/07 19:37:41 pier Exp $
- * $Revision: 1.6 $
- * $Date: 2000/12/07 19:37:41 $
+ * $Header: /home/cvs/jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core/StandardHost.java,v 1.7 2001/01/20 19:41:29 remm Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/01/20 19:41:29 $
*
* ====================================================================
*
@@ -97,7 +97,7 @@
* requests directed to a particular web application.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.6 $ $Date: 2000/12/07 19:37:41 $
+ * @version $Revision: 1.7 $ $Date: 2001/01/20 19:41:29 $
*/
public class StandardHost
@@ -173,6 +173,12 @@
"org.apache.catalina.core.StandardHostMapper";
+ /**
+ * Unpack WARs property.
+ */
+ private boolean unpackWARs = true;
+
+
// ------------------------------------------------------------- Properties
@@ -290,6 +296,26 @@
}
+ /**
+ * Unpack WARs flag accessor.
+ */
+ public boolean isUnpackWARs() {
+
+ return (unpackWARs);
+
+ }
+
+
+ /**
+ * Unpack WARs flag mutator.
+ */
+ public void setUnpackWARs(boolean unpackWARs) {
+
+ this.unpackWARs = unpackWARs;
+
+ }
+
+
// --------------------------------------------------------- Public Methods
@@ -513,22 +539,39 @@
log(sm.getString("standardHost.deploying", contextPath, url));
// Expand a WAR archive into an unpacked directory if needed
- if (url.startsWith("jar:"))
- docBase = expand(war);
- else if (url.startsWith("file://"))
- docBase = url.substring(7);
- else if (url.startsWith("file:"))
- docBase = url.substring(5);
- else
- throw new IllegalArgumentException
- (sm.getString("standardHost.warURL", url));
-
- // Make sure the document base directory exists and is readable
- File docBaseDir = new File(docBase);
- if (!docBaseDir.exists() || !docBaseDir.isDirectory() ||
- !docBaseDir.canRead())
- throw new IllegalArgumentException
- (sm.getString("standardHost.accessBase", docBase));
+ if (isUnpackWARs()) {
+
+ if (url.startsWith("jar:"))
+ docBase = expand(war);
+ else if (url.startsWith("file://"))
+ docBase = url.substring(7);
+ else if (url.startsWith("file:"))
+ docBase = url.substring(5);
+ else
+ throw new IllegalArgumentException
+ (sm.getString("standardHost.warURL", url));
+
+ // Make sure the document base directory exists and is readable
+ File docBaseDir = new File(docBase);
+ if (!docBaseDir.exists() || !docBaseDir.isDirectory() ||
+ !docBaseDir.canRead())
+ throw new IllegalArgumentException
+ (sm.getString("standardHost.accessBase", docBase));
+
+ } else {
+
+ if (url.startsWith("jar:")) {
+ url = url.substring(4, url.length() - 2);
+ }
+ if (url.startsWith("file://"))
+ docBase = url.substring(7);
+ else if (url.startsWith("file:"))
+ docBase = url.substring(5);
+ else
+ throw new IllegalArgumentException
+ (sm.getString("standardHost.warURL", url));
+
+ }
// Deploy this new web application
try {
@@ -544,7 +587,7 @@
}
addChild(context);
fireContainerEvent(DEPLOY_EVENT, context);
- if (url.startsWith("jar:")) {
+ if (isUnpackWARs() && (url.startsWith("jar:"))) {
synchronized (expanded) {
if (debug >= 1)
log("Recording expanded app at path " + contextPath);
Re: cvs commit: jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core StandardContext.java StandardHost.java
Posted by Remy Maucherat <re...@apache.org>.
> Remy Maucherat wrote:
>
> > > On 20 Jan 2001 remm@apache.org wrote:
> > >
> > > > - Add a new "unpackWARs" flag in the StandardHost : if true, the
host
> > will
> > > > deploy WARs as before. If false, the WARs found in the host path
> > won't
> > > > be unpacked and the WARDirContext will be used.
> > >
> > > Very very cool.
> >
> > :)
> > I guess I get the award for "Fanciest New Feature of the Week".
> > It breaks Jasper, so it's disabled by default.
> >
>
> Once we're satisfied that the new resources stuff works, I will vote for
> modifying Jasper to utilize it (via a JNDI InitialContext) so that it
won't
> matter whether or not you are running out of a WAR file.
As far as I know, Jasper breaks because of the compiler, which apparently
wants real files. Jasper itself can load the source of the pages from the
dir context just fine.
Perhaps I should just copy the /WEB-INF/classes/ directory and its contents
to the work directory ?
The directory context can be accessed by either :
- Doing (new InitialContext()).lookup("java:/comp/Resources") if naming is
enabled (it can be disabled)
- Getting them from the ServletContext :
getServletContext().getAttribute("org.apache.catalina.resources"). That can
be used as a backup to naming if it's disabled (it's also faster)
- With the standard Servlet API call, using
ServletContext.getResource(path).openConnection() and using the
URLConnection object (of course, you can't list the contents of a directory
using this)
Remy
Re: cvs commit:
jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core
StandardContext.java StandardHost.java
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Remy Maucherat wrote:
> > On 20 Jan 2001 remm@apache.org wrote:
> >
> > > - Add a new "unpackWARs" flag in the StandardHost : if true, the host
> will
> > > deploy WARs as before. If false, the WARs found in the host path
> won't
> > > be unpacked and the WARDirContext will be used.
> >
> > Very very cool.
>
> :)
> I guess I get the award for "Fanciest New Feature of the Week".
> It breaks Jasper, so it's disabled by default.
>
Once we're satisfied that the new resources stuff works, I will vote for
modifying Jasper to utilize it (via a JNDI InitialContext) so that it won't
matter whether or not you are running out of a WAR file.
>
> Remy
>
Craig McClanahan
Re: cvs commit: jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core StandardContext.java StandardHost.java
Posted by Remy Maucherat <re...@apache.org>.
> On 20 Jan 2001 remm@apache.org wrote:
>
> > - Add a new "unpackWARs" flag in the StandardHost : if true, the host
will
> > deploy WARs as before. If false, the WARs found in the host path
won't
> > be unpacked and the WARDirContext will be used.
>
> Very very cool.
:)
I guess I get the award for "Fanciest New Feature of the Week".
It breaks Jasper, so it's disabled by default.
Remy
Re: cvs commit: jakarta-tomcat-4.1/catalina/src/share/org/apache/catalina/core
StandardContext.java StandardHost.java
Posted by Nick Bauman <ni...@cortexity.com>.
On 20 Jan 2001 remm@apache.org wrote:
> - Add a new "unpackWARs" flag in the StandardHost : if true, the host will
> deploy WARs as before. If false, the WARs found in the host path won't
> be unpacked and the WARDirContext will be used.
Very very cool.