You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by re...@apache.org on 2001/06/13 06:39:42 UTC
cvs commit: jakarta-slide/src/wrappers/catalina manager.xml server.xml SlideHost.java WebdavHost.java SlideRealm.java
remm 01/06/12 21:39:42
Modified: src/wrappers/catalina SlideRealm.java
Added: src/wrappers/catalina manager.xml server.xml SlideHost.java
WebdavHost.java
Log:
- Complete the first part of the integration with Catalina, using custom hosts.
More details on this later.
Revision Changes Path
1.5 +22 -14 jakarta-slide/src/wrappers/catalina/SlideRealm.java
Index: SlideRealm.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/wrappers/catalina/SlideRealm.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SlideRealm.java 2001/04/11 16:57:35 1.4
+++ SlideRealm.java 2001/06/13 04:39:41 1.5
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/wrappers/catalina/SlideRealm.java,v 1.4 2001/04/11 16:57:35 remm Exp $
- * $Revision: 1.4 $
- * $Date: 2001/04/11 16:57:35 $
+ * $Header: /home/cvs/jakarta-slide/src/wrappers/catalina/SlideRealm.java,v 1.5 2001/06/13 04:39:41 remm Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/06/13 04:39:41 $
*
* ====================================================================
*
@@ -82,6 +82,7 @@
import org.apache.slide.content.NodeRevisionDescriptors;
import org.apache.slide.content.NodeRevisionDescriptor;
import org.apache.slide.content.NodeProperty;
+import org.apache.slide.structure.ObjectNode;
import org.apache.slide.authenticate.CredentialsToken;
import org.apache.slide.authenticate.SecurityToken;
import org.apache.slide.security.Security;
@@ -96,7 +97,7 @@
* to tomcat, webdav or default.
*
* @author Remy Maucherat
- * @version $Revision: 1.4 $ $Date: 2001/04/11 16:57:35 $
+ * @version $Revision: 1.5 $ $Date: 2001/06/13 04:39:41 $
*/
public final class SlideRealm
@@ -170,7 +171,7 @@
if (accessToken == null)
throw new IllegalStateException
("Invalid Slide Realm configuration : "
- + "Couldn't access namespace");
+ + "Couldn't access namespace " + namespace);
contentHelper = accessToken.getContentHelper();
securityHelper = accessToken.getSecurityHelper();
@@ -228,12 +229,22 @@
*/
protected String getPassword(String username) {
+ Principal userPrincipal = getPrincipal(username);
+ CredentialsToken credToken = new CredentialsToken(userPrincipal);
+ SlideToken slideToken = new SlideToken(credToken);
+
// Fetch the Slide object representing the user.
try {
- Principal userPrincipal = getPrincipal(username);
- CredentialsToken credToken = new CredentialsToken(userPrincipal);
- SlideToken slideToken = new SlideToken(credToken);
+ ObjectNode user = securityHelper.getPrincipal(slideToken);
+
+ } catch (SlideException e) {
+ return null;
+ }
+
+ String passwordValue = username;
+
+ try {
NodeRevisionDescriptors revisionDescriptors =
contentHelper.retrieve(slideToken, usersPath + "/" + username);
@@ -241,18 +252,15 @@
contentHelper.retrieve(slideToken, revisionDescriptors);
NodeProperty password =
revisionDescriptor.getProperty("password");
- if (password == null)
- return username;
- else
- return (String) password.getValue();
+ if (password != null)
+ passwordValue = (String) password.getValue();
} catch (SlideException e) {
// Whatever happens doesn't really matter
// The stack trace is displayed for now for debug purposes
- e.printStackTrace();
}
- return null;
+ return passwordValue;
}
1.1 jakarta-slide/src/wrappers/catalina/manager.xml
Index: manager.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
<web-app>
<!-- Define the Manager Servlet
Change servlet-class to: org.apache.catalina.servlets.HTMLManagerServlet
to get a Servlet with a more intuitive HTML interface, don't change if you
have software that is expected to parse the output from ManagerServlet
since they're not compatible.
-->
<servlet>
<servlet-name>Manager</servlet-name>
<servlet-class>org.apache.catalina.servlets.HTMLManagerServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
</servlet>
<!-- Define the Manager Servlet Mapping -->
<servlet-mapping>
<servlet-name>Manager</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- Define a Security Constraint on this Application -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<!-- NOTE: This role is not present in the default users file -->
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>
<!-- Define the Login Configuration for this Application -->
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Tomcat Manager Application</realm-name>
</login-config>
</web-app>
1.1 jakarta-slide/src/wrappers/catalina/server.xml
Index: server.xml
===================================================================
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Tomcat-Standalone">
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="60000"/>
<!-- Define an SSL HTTP/1.1 Connector on port 8443 -->
<!--
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8443" minProcessors="5" maxProcessors="75"
enableLookups="true"
acceptCount="10" debug="0" scheme="https" secure="true">
<Factory className="org.apache.catalina.net.SSLServerSocketFactory"
clientAuth="false" protocol="TLS"/>
</Connector>
-->
<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost" debug="0">
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<!-- Define the default virtual host -->
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="false"
className="wrappers.catalina.SlideHost">
<Realm className="org.apache.catalina.realm.MemoryRealm" />
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common"/>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<!-- Tomcat Root Context -->
<!--
<Context path="" docBase="ROOT" debug="0"/>
-->
</Host>
</Engine>
</Service>
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Slide WebDAV">
<!-- Define a non-SSL HTTP/1.1 Connector on port 8081 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8081" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="60000"/>
<!-- Define an SSL HTTP/1.1 Connector on port 8443 -->
<!--
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8443" minProcessors="5" maxProcessors="75"
enableLookups="true"
acceptCount="10" debug="0" scheme="https" secure="true">
<Factory className="org.apache.catalina.net.SSLServerSocketFactory"
clientAuth="false" protocol="TLS"/>
</Connector>
-->
<!-- Define the top level container in our container hierarchy -->
<Engine name="WebDAV" defaultHost="localhost" debug="0">
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_webdav_log." suffix=".txt"
timestamp="true"/>
<!-- Define the default virtual host -->
<Host name="localhost" debug="0" appBase="blank" unpackWARs="false"
className="wrappers.catalina.WebdavHost">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="webdav_access_log." suffix=".txt"
pattern="common"/>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="webdav_log." suffix=".txt"
timestamp="true"/>
<!-- Tomcat Root Context -->
<!--
<Context path="" docBase="ROOT" debug="0"/>
-->
</Host>
</Engine>
</Service>
<!-- Define the Slide Manager Service -->
<Service name="Slide Manager">
<!-- Define a non-SSL HTTP/1.1 Connector on port 8082 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8082" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="60000"/>
<!-- Define an SSL HTTP/1.1 Connector on port 8443 -->
<!--
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8443" minProcessors="5" maxProcessors="75"
enableLookups="true"
acceptCount="10" debug="0" scheme="https" secure="true">
<Factory className="org.apache.catalina.net.SSLServerSocketFactory"
clientAuth="false" protocol="TLS"/>
</Connector>
-->
<!-- Define the top level container in our container hierarchy -->
<Engine name="Manager" defaultHost="localhost" debug="0">
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_manager_log." suffix=".txt"
timestamp="true"/>
<!-- Define the default virtual host -->
<Host name="localhost" debug="0" appBase="manager" unpackWARs="false">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="manager_access_log." suffix=".txt"
pattern="common"/>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="manager_log." suffix=".txt"
timestamp="true"/>
<!-- Tomcat Root Context -->
<!--
<Context path="" docBase="ROOT" debug="0"/>
-->
</Host>
</Engine>
</Service>
</Server>
1.1 jakarta-slide/src/wrappers/catalina/SlideHost.java
Index: SlideHost.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/wrappers/catalina/SlideHost.java,v 1.1 2001/06/13 04:39:41 remm Exp $
* $Revision: 1.1 $
* $Date: 2001/06/13 04:39:41 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package wrappers.catalina;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Deployer;
import org.apache.catalina.Globals;
import org.apache.catalina.HttpRequest;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Request;
import org.apache.catalina.Response;
import org.apache.catalina.core.DefaultContext;
import org.apache.catalina.core.StandardHost;
import wrappers.jndi.SlideDirContext;
import org.apache.slide.common.Domain;
/**
* Slide implementation of Host.
*
* @author Remy Maucherat
* @version $Revision: 1.1 $ $Date: 2001/06/13 04:39:41 $
*/
public class SlideHost
extends StandardHost
implements Deployer, Host {
// ----------------------------------------------------------- Constructors
/**
* Create a new SlideHost component with the default basic Valve.
*/
public SlideHost() {
super();
}
// ----------------------------------------------------- Instance Variables
// ------------------------------------------------------------- Properties
// --------------------------------------------------------- Public Methods
/**
* Prepare for active use of the public methods of this Component.
*
* @exception IllegalStateException if this component has already been
* started
* @exception LifecycleException if this component detects a fatal error
* that prevents it from being started
*/
public synchronized void start() throws LifecycleException {
try {
File domainConfigFile = new File("Domain.xml");
Domain.init(domainConfigFile.toURL());
} catch (Exception e) {
e.printStackTrace();
}
Enumeration namespaceNames = Domain.enumerateNamespaces();
while (namespaceNames.hasMoreElements()) {
String name = (String) namespaceNames.nextElement();
try {
install("/" + name, new URL("http", "slide", name));
} catch (IOException e) {
// Can't happen
e.printStackTrace();
}
}
super.start();
}
// ------------------------------------------------------- Deployer Methods
/**
* Install a Slide context.
*/
public void install(String contextPath, URL war) throws IOException {
// Validate the format and state of our arguments
if (contextPath == null)
throw new IllegalArgumentException
(sm.getString("standardHost.pathRequired"));
if (war == null)
throw new IllegalArgumentException
(sm.getString("standardHost.warRequired"));
if (!(war.getProtocol().equals("http")
&& war.getHost().equals("slide"))) {
super.install(contextPath, war);
return;
}
// Prepare the local variables we will require
String docBase = war.getFile();
log(sm.getString("standardHost.installing", contextPath, war));
// Install this new web application
try {
Class clazz = Class.forName(getContextClass());
Context context = (Context) clazz.newInstance();
context.setPath(contextPath);
context.setDocBase(docBase);
SlideDirContext resources = new SlideDirContext();
resources.setNamespaceName(war.getFile());
context.setResources(resources);
SlideRealm slideRealm = new SlideRealm();
String namespaceName = contextPath;
while (namespaceName.startsWith("/")) {
namespaceName = namespaceName.substring(1);
}
slideRealm.setNamespace(namespaceName);
context.setRealm(slideRealm);
if (context instanceof Lifecycle) {
clazz = Class.forName(getConfigClass());
LifecycleListener listener =
(LifecycleListener) clazz.newInstance();
((Lifecycle) context).addLifecycleListener(listener);
}
addChild(context);
fireContainerEvent(INSTALL_EVENT, context);
} catch (Exception e) {
log(sm.getString("standardHost.installError", contextPath), e);
throw new IOException(e.toString());
}
}
}
1.1 jakarta-slide/src/wrappers/catalina/WebdavHost.java
Index: WebdavHost.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/wrappers/catalina/WebdavHost.java,v 1.1 2001/06/13 04:39:42 remm Exp $
* $Revision: 1.1 $
* $Date: 2001/06/13 04:39:42 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package wrappers.catalina;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Deployer;
import org.apache.catalina.Globals;
import org.apache.catalina.HttpRequest;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Request;
import org.apache.catalina.Response;
import org.apache.catalina.core.DefaultContext;
import org.apache.catalina.core.StandardHost;
import org.apache.slide.common.Domain;
/**
* Slide Webdav implementation of Host.
*
* @author Remy Maucherat
* @version $Revision: 1.1 $ $Date: 2001/06/13 04:39:42 $
*/
public class WebdavHost
extends StandardHost
implements Deployer, Host {
// ----------------------------------------------------------- Constructors
/**
* Create a new WebdavHost component with the default basic Valve.
*/
public WebdavHost() {
super();
}
// ----------------------------------------------------- Instance Variables
// ------------------------------------------------------------- Properties
// --------------------------------------------------------- Public Methods
/**
* Prepare for active use of the public methods of this Component.
*
* @exception IllegalStateException if this component has already been
* started
* @exception LifecycleException if this component detects a fatal error
* that prevents it from being started
*/
public synchronized void start() throws LifecycleException {
try {
File domainConfigFile = new File("Domain.xml");
Domain.init(domainConfigFile.toURL());
} catch (Exception e) {
e.printStackTrace();
}
Enumeration namespaceNames = Domain.enumerateNamespaces();
while (namespaceNames.hasMoreElements()) {
String name = (String) namespaceNames.nextElement();
try {
File webdavWar = new File("webdav/webdav.war");
System.out.println("Install: " + webdavWar.toURL() + " on "
+ "/" + name);
install("/" + name, webdavWar.toURL());
} catch (IOException e) {
// Can't happen
e.printStackTrace();
}
}
super.start();
}
// ------------------------------------------------------- Deployer Methods
/**
* Install a new web application, whose web application archive is at the
* specified URL, into this container with the specified context path.
* A context path of "" (the empty string) should be used for the root
* application for this container. Otherwise, the context path must
* start with a slash.
* <p>
* If this application is successfully installed, a ContainerEvent of type
* <code>INSTALL_EVENT</code> will be sent to all registered listeners,
* with the newly created <code>Context</code> as an argument.
*
* @param contextPath The context path to which this application should
* be installed (must be unique)
* @param war A URL of type "jar:" that points to a WAR file, or type
* "file:" that points to an unpacked directory structure containing
* the web application to be installed
*
* @exception IllegalArgumentException if the specified context path
* is malformed (it must be "" or start with a slash)
* @exception IllegalArgumentException if the specified context path
* is already attached to an existing web application
* @exception IOException if an input/output error was encountered
* during install
*/
public void install(String contextPath, URL war) throws IOException {
// Validate the format and state of our arguments
if (contextPath == null)
throw new IllegalArgumentException
(sm.getString("standardHost.pathRequired"));
if (!contextPath.equals("") && !contextPath.startsWith("/"))
throw new IllegalArgumentException
(sm.getString("standardHost.pathFormat", contextPath));
if (findDeployedApp(contextPath) != null)
throw new IllegalArgumentException
(sm.getString("standardHost.pathUsed", contextPath));
if (war == null)
throw new IllegalArgumentException
(sm.getString("standardHost.warRequired"));
// Prepare the local variables we will require
String url = war.toString();
String docBase = null;
log(sm.getString("standardHost.installing", contextPath, url));
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));
// Install this new web application
try {
Class clazz = Class.forName(getContextClass());
Context context = (Context) clazz.newInstance();
context.setPath(contextPath);
context.setDocBase(docBase);
SlideRealm slideRealm = new SlideRealm();
String namespaceName = contextPath;
while (namespaceName.startsWith("/")) {
namespaceName = namespaceName.substring(1);
}
slideRealm.setNamespace(namespaceName);
context.setRealm(slideRealm);
if (context instanceof Lifecycle) {
clazz = Class.forName(getConfigClass());
LifecycleListener listener =
(LifecycleListener) clazz.newInstance();
((Lifecycle) context).addLifecycleListener(listener);
}
addChild(context);
fireContainerEvent(INSTALL_EVENT, context);
} catch (Exception e) {
log(sm.getString("standardHost.installError", contextPath), e);
throw new IOException(e.toString());
}
}
}