dain 2004/01/22 18:25:52
Added: sandbox/webdav .cvsignore LICENSE.txt project.properties
project.xml
sandbox/webdav/src/deploy/jetty jetty-config.xml
webdefault.xml
sandbox/webdav/src/java/org/apache/geronimo/webdav
AbstractConnector.java CatalinaDAVRepository.java
Connector.java DAVRepository.java DAVServer.java
sandbox/webdav/src/java/org/apache/geronimo/webdav/jetty
JettyConnector.java JettyConnectorImpl.java
JettyDAVServer.java
Log:
Moved from old web module
Revision Changes Path
1.1 incubator-geronimo/sandbox/webdav/.cvsignore
Index: .cvsignore
===================================================================
target
1.1 incubator-geronimo/sandbox/webdav/LICENSE.txt
Index: LICENSE.txt
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* 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/>.
*
* ====================================================================
*/
1.1 incubator-geronimo/sandbox/webdav/project.properties
Index: project.properties
===================================================================
##
## $Revision: 1.1 $ $Date: 2004/01/23 02:25:51 $
##
maven.repo.remote=http://www.apache.org/~dain/maven,
http://www.ibiblio.org/maven, http://www.apache.org/~gdamour/maven
1.1 incubator-geronimo/sandbox/webdav/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $Revision: 1.1 $ $Date: 2004/01/23 02:25:51 $ -->
<project>
<pomVersion>3</pomVersion>
<extend>${basedir}/../../etc/project.xml</extend>
<!-- ===================== -->
<!-- Module Identification -->
<!-- ===================== -->
<name>Geronimo :: Web</name>
<id>geronimo-web</id>
<shortDescription>Geronimo Web Container</shortDescription>
<description>Geronimo Web Container</description>
<url>http://incubator.apache.org/projects/geronimo/web/</url>
<siteDirectory>/www/incubator.apache.org/projects/geronimo/web</siteDirectory>
<distributionDirectory>/www/incubator.apache.org/projects/geronimo/builds/web</distributionDirectory>
<currentVersion>DEV</currentVersion>
<!-- ============ -->
<!-- Dependencies -->
<!-- ============ -->
<dependencies>
<dependency>
<groupId>geronimo</groupId>
<artifactId>geronimo-kernel</artifactId>
<version>DEV</version>
<properties>
<module>true</module>
</properties>
</dependency>
<dependency>
<id>commons-logging</id>
<version>1.0.3</version>
<url>http://jakarta.apache.org/commons/logging/</url>
<properties>
<runtime>false</runtime>
</properties>
</dependency>
<dependency>
<id>jetty</id>
<version>SNAPSHOT</version>
<properties>
<runtime>true</runtime>
</properties>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>catalina</artifactId>
<version>5.0.16</version>
<properties>
<runtime>true</runtime>
</properties>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>catalina-optional</artifactId>
<version>5.0.16</version>
<properties>
<runtime>true</runtime>
</properties>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>naming-common</artifactId>
<version>5.0.16</version>
<properties>
<runtime>true</runtime>
</properties>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>naming-resources</artifactId>
<version>5.0.16</version>
<properties>
<runtime>true</runtime>
</properties>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>servlets-common</artifactId>
<version>5.0.16</version>
<properties>
<runtime>true</runtime>
</properties>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>servlets-default</artifactId>
<version>5.0.16</version>
<properties>
<runtime>true</runtime>
</properties>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>servlets-webdav</artifactId>
<version>5.0.16</version>
<properties>
<runtime>true</runtime>
</properties>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>tomcat-util</artifactId>
<version>5.0.16</version>
<properties>
<runtime>true</runtime>
</properties>
</dependency>
</dependencies>
<!-- =================== -->
<!-- Build Specification -->
<!-- =================== -->
<build>
<resources>
<resource>
<directory>${basedir}/src/conf</directory>
<includes>
<include>*.properties</include>
</includes>
</resource>
</resources>
</build>
</project>
1.1
incubator-geronimo/sandbox/webdav/src/deploy/jetty/jetty-config.xml
Index: jetty-config.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.2//EN"
"http://jetty.mortbay.org/configure_1_2.dtd">
<Configure class="org.mortbay.jetty.Server">
<!-- =============================================================== -->
<!-- Configure the Request Listeners -->
<!-- =============================================================== -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Add and configure a HTTP listener to port 8080
-->
<!-- The default port can be changed using: java -Djetty.port=80 -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Call name="addListener">
<Arg>
<New class="org.mortbay.http.SocketListener">
<Set name="Port">
<SystemProperty name="jetty.port" default="8080"/>
</Set>
<Set name="MinThreads">10</Set>
<Set name="MaxThreads">100</Set>
<Set name="MaxIdleTimeMs">30000</Set>
<Set name="LowResourcePersistTimeMs">5000</Set>
</New>
</Arg>
</Call>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Add a HTTPS SSL listener on port 8843 -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- UNCOMMENT TO ACTIVATE
<Call name="addListener">
<Arg>
<New class="org.mortbay.http.SunJsseListener">
<Set name="Port">8443</Set>
<Set name="MinThreads">5</Set>
<Set name="MaxThreads">100</Set>
<Set name="MaxIdleTimeMs">30000</Set>
<Set name="LowResourcePersistTimeMs">2000</Set>
<Set name="Keystore"><SystemProperty
name="jetty.home.dir"/>/conf/demokeystore</Set>
<Set name="Password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
<Set name="KeyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
</New>
</Arg>
</Call>
-->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Add a AJP13 listener on port 8009 -->
<!-- This protocol can be used with mod_jk in apache, IIS etc. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!--
<Call name="addListener">
<Arg>
<New class="org.mortbay.http.ajp.AJP13Listener">
<Set name="Port">8009</Set>
<Set name="MinThreads">5</Set>
<Set name="MaxThreads">20</Set>
<Set name="MaxIdleTimeMs">0</Set>
<Set name="confidentialPort">443</Set>
</New>
</Arg>
</Call>
-->
<!-- =============================================================== -->
<!-- Configure the Request Log -->
<!-- =============================================================== -->
<Set name="RequestLog">
<New class="org.mortbay.http.NCSARequestLog">
<Arg>
<SystemProperty name="jetty.home.dir"/>/yyyy_mm_dd.request.log
</Arg>
<Set name="retainDays">90</Set>
<Set name="append">true</Set>
<Set name="extended">true</Set>
<Set name="buffered">false</Set>
<Set name="LogTimeZone">GMT</Set>
</New>
</Set>
<Call name="addWebApplication">
<Arg></Arg>
<Arg>console</Arg>
<Arg>
<SystemProperty name="jetty.home.dir"/>/geronimo-web-console.war
</Arg>
<Call name="setDefaultsDescriptor">
<Arg>
<SystemProperty name="jetty.home.dir"/>/webdefault.xml
</Arg>
</Call>
<Call name="setExtractWAR">
<Arg type="boolean">true</Arg>
</Call>
</Call>
</Configure>
1.1
incubator-geronimo/sandbox/webdav/src/deploy/jetty/webdefault.xml
Index: webdefault.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<!-- ===================================================================== -->
<!-- This file contains the default descriptor for web applications. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- The original of this file is included as a resource in the -->
<!-- org.mortbay.jetty.jar file and is loaded by default for all web -->
<!-- applications before there own WEB-INF/web.xml file is loaded -->
<!-- -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- THE COPY OF THIS FILE in $JETTY_HOME/etc IS NOT USED BY DEFAULT! -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- If the version in $JETTY_HOME/etc/ is to be used, then the -->
<!-- setDefaultsDescriptor method must be called on each context, -->
<!-- giving the location of the default web.xml file to use. -->
<!-- eg of setting the defaultsDescriptor in jetty.xml:
<Call name="addWebApplication">
<Arg>/mycontext</Arg>
<Arg><SystemProperty name="jetty.home"
default=".">/webapps/mywebapp</Arg>
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home"
default="."/>/etc/webdefault.xml</Set>
</Call>
-->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- ===================================================================== -->
<web-app>
<description>
Default web.xml file.
This file is applied to a Web application before it's own WEB_INF/web.xml
file
</description>
<!-- ====================================================================
-->
<!-- Context params to control Session Cookies
-->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<!-- UNCOMMENT TO ACTIVATE
<context-param>
<param-name>org.mortbay.jetty.servlet.SessionDomain</param-name>
<param-value>127.0.0.1</param-value>
</context-param>
<context-param>
<param-name>org.mortbay.jetty.servlet.SessionPath</param-name>
<param-value>/</param-value>
</context-param>
<context-param>
<param-name>org.mortbay.jetty.servlet.MaxAge</param-name>
<param-value>-1</param-value>
</context-param>
-->
<!-- ====================================================================
-->
<!-- The default servlet.
-->
<!-- This servlet, normally mapped to /, provides the handling for static
-->
<!-- content, OPTION and TRACE methods for the context.
-->
<!-- The following initParameters are supported:
-->
<!--
-->
<!-- acceptRanges If true, range requests and responses are
-->
<!-- supported
-->
<!--
-->
<!-- dirAllowed If true, directory listings are returned if no
-->
<!-- welcome file is found. Else 403 Forbidden.
-->
<!--
-->
<!-- putAllowed If true, the PUT method is allowed
-->
<!--
-->
<!-- delAllowed If true, the DELETE method is allowed
-->
<!--
-->
<!-- redirectWelcome If true, redirect welcome file requests
-->
<!-- else use request dispatcher forwards
-->
<!--
-->
<!-- minGzipLength If set to a positive integer, then static content
-->
<!-- larger than this will be served as gzip content
-->
<!-- encoded if a matching resource is found ending
-->
<!-- with ".gz"
-->
<!--
-->
<!-- resoureBase Can be set to replace the context resource base
-->
<!--
-->
<!-- The MOVE method is allowed if PUT and DELETE are allowed
-->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.mortbay.jetty.servlet.Default</servlet-class>
<init-param>
<param-name>acceptRanges</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>dirAllowed</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>putAllowed</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>delAllowed</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>redirectWelcome</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>minGzipLength</param-name>
<param-value>8192</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<!-- ====================================================================
-->
<!-- JSP Servlet
-->
<!-- This is the jasper JSP servlet from the jakarta project
-->
<!-- The following initParameters are supported:
-->
<!--
-->
<!-- classpath What class path should I use while compiling
-->
<!-- generated servlets? [Created dynamically
-->
<!-- based on the current web application]
-->
<!--
-->
<!-- classdebuginfo Should the class file be compiled with
-->
<!-- debugging information? [false]
-->
<!--
-->
<!-- ieClassId The class-id value to be sent to Internet
-->
<!-- Explorer when using <jsp:plugin> tags.
-->
<!-- [clsid:8AD9C840-044E-11D1-B3E9-00805F499D93]
-->
<!--
-->
<!-- jspCompilerPlugin The fully qualified class name of the JSP
-->
<!-- compiler plug-in to be used. See below for
-->
<!-- more information.
-->
<!-- [Use internal JDK compiler]
-->
<!--
-->
<!-- keepgenerated Should we keep the generated Java source code
-->
<!-- for each page instead of deleting it? [true]
-->
<!--
-->
<!-- largefile Should we store the static content of JSP
-->
<!-- pages in external data files, to reduce the
-->
<!-- size of the generated servlets? [false]
-->
<!--
-->
<!-- logVerbosityLevel The level of detailed messages to be produced
-->
<!-- by this servlet. Increasing levels cause the
-->
<!-- generation of more messages. Valid values are
-->
<!-- FATAL, ERROR, WARNING, INFORMATION, and DEBUG.
-->
<!-- [WARNING]
-->
<!--
-->
<!-- mappedfile Should we generate static content with one
-->
<!-- print statement per input line, to ease
-->
<!-- debugging? [false]
-->
<!--
-->
<!-- scratchdir What scratch directory should we use when
-->
<!-- compiling JSP pages? [default work directory
-->
<!-- for the current web application]
-->
<!--
-->
<!-- If you wish to use Jikes to compile JSP pages:
-->
<!-- * Set the "classpath" initialization parameter appropriately
-->
<!-- for this web application.
-->
<!-- * Set the "jspCompilerPlugin" initialization parameter to
-->
<!-- "org.apache.jasper.compiler.JikesJavaCompiler".
-->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<!-- ====================================================================
-->
<!-- Dynamic Servlet Invoker.
-->
<!-- This servlet invokes anonymous servlets that have not been defined
-->
<!-- in the web.xml or by other means. The first element of the pathInfo
-->
<!-- of a request passed to the envoker is treated as a servlet name for
-->
<!-- an existing servlet, or as a class name of a new servlet.
-->
<!-- This servlet is normally mapped to /servlet/*
-->
<!-- This servlet support the following initParams:
-->
<!--
-->
<!-- nonContextServlets If false, the invoker can only load
-->
<!-- servlets from the contexts classloader.
-->
<!-- This is false by default and setting this
-->
<!-- to true may have security implications.
-->
<!--
-->
<!-- verbose If true, log dynamic loads
-->
<!--
-->
<!-- * All other parameters are copied to the
-->
<!-- each dynamic servlet as init parameters
-->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>org.mortbay.jetty.servlet.Invoker</servlet-class>
<init-param>
<param-name>verbose</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>nonContextServlets</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>dynamicParam</param-name>
<param-value>anyValue</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<!-- ====================================================================
-->
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- ====================================================================
-->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<!-- ====================================================================
-->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jspf</url-pattern>
</servlet-mapping>
<!-- ====================================================================
-->
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
<!-- ====================================================================
-->
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<!-- ====================================================================
-->
<!-- Default MIME mappings
-->
<!-- The default MIME mappings are provided by the mime.properties
-->
<!-- resource in the org.mortbay.jetty.jar file. Additional or modified
-->
<!-- mappings may be specified here
-->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<!-- UNCOMMENT TO ACTIVATE
<mime-mapping>
<extension>mysuffix</extension>
<mime-type>mymime/type</mime-type>
</mime-mapping>
-->
<!-- ====================================================================
-->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
1.1
incubator-geronimo/sandbox/webdav/src/java/org/apache/geronimo/webdav/AbstractConnector.java
Index: AbstractConnector.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* 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/>.
*
* ====================================================================
*/
package org.apache.geronimo.webdav;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gbean.GAttributeInfo;
import org.apache.geronimo.gbean.GBean;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoFactory;
import org.apache.geronimo.gbean.GConstructorInfo;
/**
* Base implementation for the Connector contracts.
*
* @version $Revision: 1.1 $ $Date: 2004/01/23 02:25:51 $
*/
public abstract class AbstractConnector implements Connector, GBean {
protected final Log log = LogFactory.getLog(getClass());
/**
* Port.
*/
protected int port;
/**
* Protocol.
*/
protected String protocol;
/**
* Host.
*/
private String host;
/**
* Maximum number of connections.
*/
protected int maxCon;
/**
* Maximum idle time.
*/
protected int maxIdle;
/**
* Creates a connector having the specified specificities.
*
* @param aProtocol Protocol.
* @param anHost Host.
* @param aPort Port.
* @param aMaxCon Maximum number of connections.
* @param aMaxIdle Maximum idle time.
*/
public AbstractConnector(String aProtocol, String anHost, int aPort, int
aMaxCon, int aMaxIdle) {
protocol = aProtocol;
host = anHost;
port = aPort;
maxCon = aMaxCon;
maxIdle = aMaxIdle;
}
public void setPort(int aPort) {
port = aPort;
}
public int getPort() {
return port;
}
public void setProtocol(String aProtocol) {
protocol = aProtocol;
}
public String getProtocol() {
return protocol;
}
public void setInterface(String anInterface) {
host = anInterface;
}
/**
* Gets the interface/host of this Connector.
* <BR>
* If it has not been set explicitely, then the host name of the localhost
* is set and returned.
*
* @return Interface.
*/
public synchronized String getInterface() {
if (null != host) {
return host;
}
try {
host = InetAddress.getLocalHost().getHostName();
return host;
} catch (UnknownHostException e) {
// Should not happen.
log.error(e);
throw new RuntimeException(e);
}
}
public void setMaxConnections(int aMaxConnects) {
maxCon = aMaxConnects;
}
public int getMaxConnections() {
return maxCon;
}
public void setMaxIdleTime(int aMaxIdleTime) {
maxIdle = aMaxIdleTime;
}
public int getMaxIdleTime() {
return maxIdle;
}
private final static GBeanInfo GBEAN_INFO;
static {
GBeanInfoFactory infoFactory = new GBeanInfoFactory("Abstract
Connector", AbstractConnector.class.getName());
infoFactory.addAttribute(new GAttributeInfo("Port", true));
infoFactory.addAttribute(new GAttributeInfo("Protocol", true));
infoFactory.addAttribute(new GAttributeInfo("Interface", true));
infoFactory.addAttribute(new GAttributeInfo("MaxConnections", true));
infoFactory.addAttribute(new GAttributeInfo("MaxIdleTime", true));
infoFactory.setConstructor(new GConstructorInfo(
new String[]{"Protocol", "Interface", "Port",
"MaxConnections", "MaxIdleTime"},
new Class[]{String.class, String.class, Integer.TYPE,
Integer.TYPE, Integer.TYPE}));
GBEAN_INFO = infoFactory.getBeanInfo();
}
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
}
1.1
incubator-geronimo/sandbox/webdav/src/java/org/apache/geronimo/webdav/CatalinaDAVRepository.java
Index: CatalinaDAVRepository.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* 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/>.
*
* ====================================================================
*/
package org.apache.geronimo.webdav;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.naming.directory.DirContext;
import org.apache.catalina.Globals;
import org.apache.catalina.servlets.WebdavServlet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gbean.GAttributeInfo;
import org.apache.geronimo.gbean.GBean;
import org.apache.geronimo.gbean.GBeanContext;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoFactory;
import org.apache.geronimo.gbean.GConstructorInfo;
import org.apache.geronimo.gbean.WaitingException;
import org.apache.naming.resources.FileDirContext;
/**
* DAVRepository implementation using the Tomcat WebDAV servlet as the
* processing servlet.
*
* @version $Revision: 1.1 $ $Date: 2004/01/23 02:25:51 $
*/
public class CatalinaDAVRepository implements DAVRepository, GBean {
private static final Log log =
LogFactory.getLog(CatalinaDAVRepository.class);
private static final Class HANDLING_SERVLET = WebdavServlet.class;
private final static GBeanInfo GBEAN_INFO;
/**
* DirContext abstracting the repository exposed by this repository.
*/
private final DirContext dirContext;
/**
* Root of the repository.
*/
private final File root;
/**
* Host filter.
*/
private final String host;
/**
* Servlet context.
*/
private final String context;
/**
* Servlet context attribute name to value.
*/
private final Map servletContextAttr;
/**
* Servlet init parameter name to value.
*/
private final Map servletInitParam;
/**
* Builds a DAVRepository relying on Tomcat WebDAV servlet in order to
* process the WebDAV request.
*
* @param aRoot Root of the directory/DirContext exposed by this
repository.
* @param aContext Context within which the servlet should be mounted.
* @param anHost Host filter, if any.
*/
public CatalinaDAVRepository(File aRoot, String aContext, String anHost) {
if (null == aRoot) {
throw new IllegalArgumentException("Root MUST be specified.");
} else if (null == aContext) {
throw new IllegalArgumentException("Context MUST be specified.");
}
context = aContext;
host = anHost;
if (!aRoot.isDirectory()) {
throw new IllegalArgumentException(aRoot.getAbsolutePath() +
" does not exist.");
}
root = aRoot;
dirContext = new FileDirContext();
((FileDirContext) dirContext).setDocBase(root.getAbsolutePath());
servletContextAttr = new HashMap();
servletContextAttr.put(Globals.RESOURCES_ATTR, dirContext);
servletInitParam = new HashMap();
servletInitParam.put("readonly", "false");
servletInitParam.put("listings", "true");
}
public Class getHandlingServlet() {
return HANDLING_SERVLET;
}
public String getHost() {
return host;
}
public String getContext() {
return context;
}
/**
* Gets the root of the directory exposed by this repository.
*
* @return Root of the exposed directory.
*/
public File getRoot() {
return root;
}
public DirContext getDirContext() {
return dirContext;
}
public Map getServletContextAttr() {
return Collections.unmodifiableMap(servletContextAttr);
}
public Map getServletInitParam() {
return Collections.unmodifiableMap(servletInitParam);
}
public void setGBeanContext(GBeanContext context) {
}
public void doStart() throws WaitingException, Exception {
log.info("Starting Catalina DAV Repository");
}
public void doStop() throws WaitingException {
log.info("Stopping Catalina DAV Repository");
}
public void doFail() {
log.info("Failing Catalina DAV Repository");
}
static {
GBeanInfoFactory infoFactory =
new GBeanInfoFactory("DAV Repository - Catalina WebDAV
Servlet",
CatalinaDAVRepository.class.getName());
infoFactory.addAttribute(new GAttributeInfo("Root", true));
infoFactory.addAttribute(new GAttributeInfo("Context", true));
infoFactory.addAttribute(new GAttributeInfo("Host", true));
infoFactory.addAttribute(new GAttributeInfo("HandlingServlet"));
infoFactory.addAttribute(new GAttributeInfo("ServletContextAttr"));
infoFactory.addAttribute(new GAttributeInfo("ServletInitParam"));
infoFactory.setConstructor(new GConstructorInfo(
Arrays.asList(new Object[]{"Root", "Context", "Host"}),
Arrays.asList(new Object[]{File.class, String.class,
String.class})));
GBEAN_INFO = infoFactory.getBeanInfo();
}
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
}
1.1
incubator-geronimo/sandbox/webdav/src/java/org/apache/geronimo/webdav/Connector.java
Index: Connector.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* 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/>.
*
* ====================================================================
*/
package org.apache.geronimo.webdav;
/**
* A Connector is a request listener and response broker.
*
* @version $Revision: 1.1 $ $Date: 2004/01/23 02:25:51 $
*/
public interface Connector {
/**
* Gets listening port number.
*/
int getPort();
/**
* Sets listening port number.
*/
void setPort(int ort);
/**
* Gets the protocol name.
*/
String getProtocol();
/**
* Sets the protocol name.
*/
void setProtocol(String protocol);
/**
* Gets the network interface name.
*/
String getInterface();
/**
* Sets the network interface name.
*/
void setInterface(String networkInterface);
/**
* Gets the maximum number of connections.
*/
int getMaxConnections();
/**
* Sets the maximum number of connections.
*/
void setMaxConnections(int maxConnects);
/**
* Sets the maximum idle time.
*/
int getMaxIdleTime();
/**
* Gets the maximum idle time.
*/
void setMaxIdleTime(int maxIdleTime);
}
1.1
incubator-geronimo/sandbox/webdav/src/java/org/apache/geronimo/webdav/DAVRepository.java
Index: DAVRepository.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* 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/>.
*
* ====================================================================
*/
package org.apache.geronimo.webdav;
import java.util.Map;
/**
* A DAVRepository defines a WebDAV servlet along with its execution context.
* <BR>
* A WebDAV servlet is a servlet, which implements the WebDAV specific methods
* , e.g. PROPFIND. This servlet is deployed and managed by the DAVServer,
* which has mounted this repository.
*
* @version $Revision: 1.1 $ $Date: 2004/01/23 02:25:51 $
*/
public interface DAVRepository {
/**
* Gets the host name filter.
* <BR>
* If defined, only the requests for this host are forwarded to this
* repository.
*
* @return Host name filter.
*/
String getHost();
/**
* Gets the context of the WebDAV servlet.
* <BR>
*
* @return Context name.
*/
String getContext();
/**
* Gets the WebDAV servlet Class.
*
* @return WebDAV servlet class.
*/
Class getHandlingServlet();
/**
* Gets the servlet context attributes.
*
* @return Map of attribute name to value.
*/
Map getServletContextAttr();
/**
* Gets the servlet initialization parameters.
*
* @return Map of parameter name to value.
*/
Map getServletInitParam();
}
1.1
incubator-geronimo/sandbox/webdav/src/java/org/apache/geronimo/webdav/DAVServer.java
Index: DAVServer.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* 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/>.
*
* ====================================================================
*/
package org.apache.geronimo.webdav;
import java.util.Collection;
/**
* A DAVServer is an HTTP server providing WebDAV capabilities. It allows to
* expose, edit and manage a set of repositories remotely via a WebDAV client.
* <BR>
* The WebDAV protocol could "potentially" be the preferred transport to
* distribute a component as its base protocol, HTTP, can usually
* traverse firewalls.
* <BR>
* It is a composition of connectors and repositories.
*
* @version $Revision: 1.1 $ $Date: 2004/01/23 02:25:51 $
*/
public interface DAVServer {
/**
* Gets the connectors of this server.
*
* @return Collection of Connector instances associated to this server.
*/
public Collection getConnectors();
/**
* Gets the repositories of this server.
*
* @return Collection of DAVRepository instances associated to this
server.
*/
public Collection getRepositories();
}
1.1
incubator-geronimo/sandbox/webdav/src/java/org/apache/geronimo/webdav/jetty/JettyConnector.java
Index: JettyConnector.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* 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/>.
*
* ====================================================================
*/
package org.apache.geronimo.webdav.jetty;
import org.apache.geronimo.webdav.Connector;
import org.mortbay.http.HttpListener;
/**
* This interface is required by the IoC framework: JettyConnector is an
* endpoint, whose implementation JettyConnectorImpl does not define a
* constructor without parameters.
* <BR>
* This interface captures the operations and attributes, which are exposed
* as GBean operations and attributes.
*
* @version $Revision: 1.1 $ $Date: 2004/01/23 02:25:51 $
*/
public interface JettyConnector extends Connector {
HttpListener getListener();
}
1.1
incubator-geronimo/sandbox/webdav/src/java/org/apache/geronimo/webdav/jetty/JettyConnectorImpl.java
Index: JettyConnectorImpl.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* 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/>.
*
* ====================================================================
*/
package org.apache.geronimo.webdav.jetty;
import java.lang.reflect.Constructor;
import org.apache.geronimo.gbean.GAttributeInfo;
import org.apache.geronimo.gbean.GBean;
import org.apache.geronimo.gbean.GBeanContext;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoFactory;
import org.apache.geronimo.gbean.WaitingException;
import org.apache.geronimo.webdav.AbstractConnector;
import org.mortbay.http.HttpListener;
import org.mortbay.http.SocketListener;
import org.mortbay.http.SunJsseListener;
import org.mortbay.http.ajp.AJP13Listener;
import org.mortbay.util.ThreadedServer;
/**
* Connector using under the cover a Jetty HttpListener.
*
* @version $Revision: 1.1 $ $Date: 2004/01/23 02:25:51 $
*/
public class JettyConnectorImpl extends AbstractConnector implements GBean,
JettyConnector {
private static final String HTTP_PROTOCOL = "http";
private static final String HTTPS_PROTOCOL = "https";
private static final String AJP13_PROTOCOL = "ajp13";
private final static GBeanInfo GBEAN_INFO;
private final static Class[] EMPTY_FORMAL_PARAM = new Class[]{};
private final static Object[] EMPTY_ARGS = new Object[]{};
/**
* When the underlying listener is undefined, the GBean operations are
* delegated to this state.
*/
private final GBean undefinedListenerState;
/**
* When the underlying listener is defined, the GBean operations are
* delegated to this state.
*/
private final GBean definedListenerState;
private HttpListener listener;
private GBean lifeCycleState;
public JettyConnectorImpl(String aProtocol, String anHost, int aPort,
int aMaxCon, int aMaxIdle) {
super(aProtocol, anHost, aPort, aMaxCon, aMaxIdle);
undefinedListenerState = new UndefinedListenerState();
definedListenerState = new DefinedListenerState();
setListener(null);
}
public HttpListener getListener() {
return listener;
}
private void setListener(HttpListener aListener) {
listener = aListener;
if (null == listener) {
lifeCycleState = undefinedListenerState;
} else {
lifeCycleState = definedListenerState;
}
}
public void setGBeanContext(GBeanContext context) {
}
public void doStart() throws WaitingException, Exception {
log.info("Starting Jetty Connector");
lifeCycleState.doStart();
}
public void doStop() throws WaitingException, Exception {
log.info("Stopping Jetty Connector");
lifeCycleState.doStop();
}
public void doFail() {
log.info("Failing Jetty Connector");
lifeCycleState.doFail();
}
static {
GBeanInfoFactory infoFactory =
new GBeanInfoFactory("Connector - Jetty",
JettyConnectorImpl.class.getName(),
AbstractConnector.getGBeanInfo());
infoFactory.addAttribute(new GAttributeInfo("Listener"));
GBEAN_INFO = infoFactory.getBeanInfo();
}
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
private class DefinedListenerState implements GBean {
public void setGBeanContext(GBeanContext context) {
}
public void doStart() throws WaitingException, Exception {
if (listener.isStarted()) {
return;
}
listener.start();
}
public void doStop() throws WaitingException {
try {
listener.stop();
} catch (Exception e) {
log.error("Problem stopping Jetty Connector", e);
setListener(null);
}
}
public void doFail() {
try {
if (listener.isStarted()) {
listener.stop();
}
} catch (Exception e) {
log.error("Can not fail Jetty Connector", e);
}
setListener(null);
}
}
private class UndefinedListenerState implements GBean {
public void setGBeanContext(GBeanContext context) {
}
public void doStart() throws WaitingException, Exception {
HttpListener tmpListener;
try {
if (null == protocol ||
protocol.equalsIgnoreCase(HTTP_PROTOCOL)) {
tmpListener = new SocketListener();
} else if (protocol.equalsIgnoreCase(AJP13_PROTOCOL)) {
tmpListener = new AJP13Listener();
} else if (protocol.equalsIgnoreCase(HTTPS_PROTOCOL)) {
tmpListener = new SunJsseListener();
} else {
Class listenerClass =
Thread.currentThread().getContextClassLoader().loadClass(
protocol);
Constructor constructor =
listenerClass.getConstructor(EMPTY_FORMAL_PARAM);
tmpListener =
(HttpListener)
constructor.newInstance(EMPTY_ARGS);
}
tmpListener.setPort(getPort());
if (getInterface() != null) {
tmpListener.setHost(getInterface());
}
if (getMaxConnections() > 0) {
((ThreadedServer)
tmpListener).setMaxThreads(getMaxConnections());
}
if (getMaxIdleTime() > 0) {
((ThreadedServer)
tmpListener).setMaxIdleTimeMs(getMaxIdleTime());
}
((ThreadedServer) tmpListener).open();
tmpListener.start();
} catch (Exception e) {
log.error("Problem starting Connector", e);
throw e;
}
setListener(tmpListener);
}
public void doStop() throws WaitingException {
}
public void doFail() {
}
}
}
1.1
incubator-geronimo/sandbox/webdav/src/java/org/apache/geronimo/webdav/jetty/JettyDAVServer.java
Index: JettyDAVServer.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* 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/>.
*
* ====================================================================
*/
package org.apache.geronimo.webdav.jetty;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gbean.EndpointCollection;
import org.apache.geronimo.gbean.EndpointCollectionEvent;
import org.apache.geronimo.gbean.EndpointCollectionListener;
import org.apache.geronimo.gbean.GBean;
import org.apache.geronimo.gbean.GBeanContext;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoFactory;
import org.apache.geronimo.gbean.GEndpointInfo;
import org.apache.geronimo.gbean.WaitingException;
import org.apache.geronimo.webdav.DAVRepository;
import org.apache.geronimo.webdav.DAVServer;
import org.mortbay.http.HttpListener;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.jetty.servlet.ServletHttpContext;
/**
* DAVServer using under the cover a light Jetty servlet container.
*
* @version $Revision: 1.1 $ $Date: 2004/01/23 02:25:51 $
*/
public class JettyDAVServer implements DAVServer, GBean {
private static final Log log = LogFactory.getLog(JettyDAVServer.class);
/**
* Jetty Server doing the actual work.
*/
private final Server server;
/**
* DAVRepository to ServletHolder map.
*/
private final Map repToServletHolder;
/**
* Connector to HttpListener map.
*/
private final Map conToListener;
/**
* Repositories served by this server.
*/
private EndpointCollection repositories;
private final EndpointCollectionListener repositoryListener = new
EndpointCollectionListener() {
public void memberAdded(EndpointCollectionEvent event) {
addRepository((DAVRepository) event.getMember());
}
public void memberRemoved(EndpointCollectionEvent event) {
removeRepository((DAVRepository) event.getMember());
}
};
/**
* Connectors injecting requests to this server.
*/
private EndpointCollection connectors;
private final EndpointCollectionListener connectorListener = new
EndpointCollectionListener() {
public void memberAdded(EndpointCollectionEvent event) {
addConnector((JettyConnector) event.getMember());
}
public void memberRemoved(EndpointCollectionEvent event) {
removeConnector((JettyConnector) event.getMember());
}
};
public JettyDAVServer() throws Exception {
server = new Server();
repToServletHolder = new HashMap();
conToListener = new HashMap();
}
public void setConnectors(Collection aCollOfConnectors) {
if (null == aCollOfConnectors) {
connectors.removeEndpointCollectionListener(connectorListener);
for (Iterator iter = connectors.iterator(); iter.hasNext();) {
removeConnector((JettyConnector) iter.next());
}
}
connectors = (EndpointCollection) aCollOfConnectors;
if (null != connectors) {
connectors.addEndpointCollectionListener(connectorListener);
for (Iterator iter = connectors.iterator(); iter.hasNext();) {
addConnector((JettyConnector) iter.next());
}
}
}
public void addConnector(JettyConnector aConnector) {
// The Connector MUST be running at this stage, otherwise a null
// listener is returned. This is enforced by the endpoint mechanism,
// which publishes only running endpoints.
if (null == aConnector.getListener()) {
throw new IllegalStateException("No defined listener.");
}
server.addListener(aConnector.getListener());
synchronized (conToListener) {
conToListener.put(aConnector, aConnector.getListener());
}
}
public void removeConnector(JettyConnector aConnector) {
// At this stage, the connector could be failed. In this later case
// the underlying listener is undefined. Hence the conToListener Map.
HttpListener httpListener;
synchronized (conToListener) {
httpListener = (HttpListener) conToListener.remove(aConnector);
}
if (null == httpListener) {
throw new IllegalStateException("Connector not registered.");
}
server.removeListener(httpListener);
}
public void setRepositories(Collection aCollOfRepositories) {
if (null == aCollOfRepositories) {
repositories.removeEndpointCollectionListener(repositoryListener);
for (Iterator iter = repositories.iterator(); iter.hasNext();) {
removeRepository((DAVRepository) iter.next());
}
}
repositories = (EndpointCollection) aCollOfRepositories;
if (null != repositories) {
repositories.addEndpointCollectionListener(repositoryListener);
for (Iterator iter = repositories.iterator(); iter.hasNext();) {
addRepository((DAVRepository) iter.next());
}
}
}
/**
* Adds a DAVRepository to this server.
*
* @param aRepository DAVRepository to be served by this server.
*/
public void addRepository(DAVRepository aRepository) {
// Gets the context associated to this repository.
ServletHttpContext context = (ServletHttpContext)
server.getContext(aRepository.getHost(), aRepository.getContext());
// Defines the servlet context attributes.
Map attributes = aRepository.getServletContextAttr();
for (Iterator iter = attributes.entrySet().iterator();
iter.hasNext();) {
Map.Entry attribute = (Map.Entry) iter.next();
context.setAttribute((String) attribute.getKey(),
attribute.getValue());
}
ServletHolder holder = null;
try {
// Defines the WebDAV servlet.
holder = context.addServlet("DAVRepository", "/*",
aRepository.getHandlingServlet().getName());
// Defines the servlet init parameters.
attributes = aRepository.getServletInitParam();
for (Iterator iter = attributes.entrySet().iterator();
iter.hasNext();) {
Map.Entry attribute = (Map.Entry) iter.next();
holder.setInitParameter((String) attribute.getKey(), (String)
attribute.getValue());
}
context.start();
} catch (Exception e) {
log.error(e);
throw new RuntimeException(e);
}
synchronized (repToServletHolder) {
repToServletHolder.put(aRepository, holder);
}
}
public void removeRepository(DAVRepository aRepository) {
ServletHolder holder;
synchronized (repToServletHolder) {
holder = (ServletHolder) repToServletHolder.remove(aRepository);
if (null == holder) {
throw new IllegalArgumentException(aRepository +
" is not contained by " + this);
}
}
holder.getHttpHandler().getHttpContext().removeHandler(holder.getHttpHandler());
// Undefined the servlet context attributes.
Map attributes = aRepository.getServletContextAttr();
for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();)
{
String attribute = (String) iter.next();
holder.getHttpHandler().getHttpContext().removeAttribute(attribute);
}
}
public Collection getRepositories() {
return repositories;
}
public Collection getConnectors() {
return connectors;
}
public void setGBeanContext(GBeanContext context) {
}
public void doStart() throws WaitingException, Exception {
log.info("Starting Jetty DAV Server");
try {
server.start();
} catch (Exception e) {
log.error("Can not start Jetty DAV Server", e);
throw e;
}
}
public void doStop() throws WaitingException {
log.info("Stopping Jetty DAV Server");
try {
server.stop();
} catch (Exception e) {
log.error("Can not start Jetty DAV server", e);
}
}
public void doFail() {
log.info("Failing Jetty DAV Server");
try {
if (server.isStarted()) {
server.stop();
}
} catch (Exception e) {
log.error("Can not start Jetty DAV server", e);
}
}
private final static GBeanInfo GBEAN_INFO;
static {
GBeanInfoFactory infoFactory = new GBeanInfoFactory("DAV Server -
Jetty", JettyDAVServer.class.getName());
infoFactory.addEndpoint(new GEndpointInfo("Connectors",
JettyConnector.class.getName()));
infoFactory.addEndpoint(new GEndpointInfo("Repositories",
DAVRepository.class.getName()));
GBEAN_INFO = infoFactory.getBeanInfo();
}
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
}