From: <st...@us...> - 2007-09-27 15:45:26
|
Revision: 5197 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=5197&view=rev Author: steve_l Date: 2007-09-27 08:45:25 -0700 (Thu, 27 Sep 2007) Log Message: ----------- SFOS-357 Move Jetty support up to Jetty6. Everything compiles; tests are failing. Modified Paths: -------------- trunk/core/components/jetty/.svnignore trunk/core/components/jetty/ivy.xml trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyHelper.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyIntf.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/SFJetty.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/SFJettyAdmin.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateApplicationContext.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateServletContext.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateWebApplicationContext.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/JettyServletDelegate.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/handlers/HTAccess.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/handlers/HandlerImpl.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/example2.sf trunk/core/components/jetty/src/org/smartfrog/services/jetty/jetty-core.sf trunk/core/components/jetty/src/org/smartfrog/services/jetty/listeners/Listener.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/listeners/Socketlistener.java trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/full/JettyTCPTest.java trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/full/components.sf trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/full/tcn57.sf trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/full/tcp19.sf trunk/core/components/libraries.properties Added Paths: ----------- trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyToSFLifecycle.java trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/full/JettyFunctionalTest.java trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/full/JettyTestBase.java trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/full/tcp19test.sf Removed Paths: ------------- trunk/core/components/jetty/build.example.properties trunk/core/components/jetty/buildRelease.xml trunk/core/components/jetty/releaseBuild.xml Modified: trunk/core/components/jetty/.svnignore =================================================================== --- trunk/core/components/jetty/.svnignore 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/.svnignore 2007-09-27 15:45:25 UTC (rev 5197) @@ -2,3 +2,6 @@ build dist version.properties +.classpath +.project +build.properties \ No newline at end of file Deleted: trunk/core/components/jetty/build.example.properties =================================================================== --- trunk/core/components/jetty/build.example.properties 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/build.example.properties 2007-09-27 15:45:25 UTC (rev 5197) @@ -1,9 +0,0 @@ -# -# These properties override properties defined in the build file. -# As these properties are set before the environment is read, they -# cannot make use of these. but htey may override the environmental -# settings. - -# example: - -# smartfrog.home=/cvs_smartfrog/core/smartfrog/dist Deleted: trunk/core/components/jetty/buildRelease.xml =================================================================== --- trunk/core/components/jetty/buildRelease.xml 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/buildRelease.xml 2007-09-27 15:45:25 UTC (rev 5197) @@ -1,193 +0,0 @@ -<?xml version="1.0"?> -<project name="jetty" default="process" basedir="."> - <!-- - /** (C) Copyright 1998-2006 Hewlett-Packard Development Company, LP - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - For more information: www.smartfrog.org - - */ - --> - - <description> - Build file to generate a release of a component. - </description> - - <property file="build.properties"/> - <property name="root.dir" location="../../"/> - - - <import file="${root.dir}/components/buildRelease-template.xml"/> - - - <!-- =================================================================== --> - <!-- release --> - <!-- =================================================================== --> - <target name="make-release-package" depends="ready-to-package"> - - <!-- ================================ --> - <zip destfile="releases/${Name.System}.${version}.${DSTAMP}_DIST.zip"> - <zipfileset dir="." prefix="${Name.System}.${version}"> - <include name="${dist}/**"/> - <exclude name="${dist}/docs/**"/> - <exclude name="${dist}/classes/**"/> - </zipfileset> - <zipfileset dir="." prefix="${Name.System}.${version}"> - <include name="${dist}/docs/jetty_readme*"/> - <include name="${dist}/docs/jdocs/**"/> - </zipfileset> - - </zip> - <!-- ================================ --> - <zip destfile="releases/${Name.System}.${version}.${DSTAMP}_ALL.zip"> - <zipfileset dir="." prefix="${Name.System}.${version}"> - <include name="bin/**"/> - <include name="doc/jetty_readme*"/> - <include name="lib/**"/> - <include name="src/**"/> - <include name="build.xml"/> - <include name="buildRelease.xml"/> - <include name="releaseBuild.xml"/> - <include name="rmitargets"/> - <include name="rmitargetsExamples"/> - <include name="parsertargets"/> - <include name="COPYRIGHT.txt"/> - <include name="LICENSE.txt"/> - <include name="changes.txt"/> - <include name="readme.txt"/> - <exclude name="**/SVN"/> - <exclude name="**/*.dfPackage"/> - <exclude name="**/Cvs"/> - <exclude name="**/.#*"/> - <exclude name="**/*.*~"/> - </zipfileset> - <zipfileset dir="." prefix="${Name.System}.${version}"> - <include name="${dist}/**"/> - <exclude name="${dist}/docs/**"/> - <exclude name="${dist}/classes/**"/> - </zipfileset> - <zipfileset dir="." prefix="${Name.System}.${version}"> - <include name="${dist}/docs/jetty_readme*"/> - <include name="${dist}/docs/jdocs/**"/> - </zipfileset> - </zip> - - - <tar tarfile="releases/${Name.System}.${version}.${DSTAMP}_DIST.tar" longfile="gnu"> - <tarfileset dir="." prefix="${Name.System}.${version}"> - <include name="${dist}/bin/**/*.sf"/> - <include name="${dist}/bin/**/*.bat"/> - <include name="${dist}/bin/**/*.ini"/> - </tarfileset> - <tarfileset dir="." prefix="${Name.System}.${version}"> - <exclude name="${dist}/bin/**"/> - <include name="${dist}/**"/> - <exclude name="${dist}/classes/**"/> - <exclude name="${dist}/docs/**"/> - </tarfileset> - <tarfileset dir="." prefix="${Name.System}.${version}"> - <include name="${dist}/docs/jetty_readme*"/> - <include name="${dist}/docs/jdocs/**"/> - </tarfileset> - <tarfileset dir="." mode="755" prefix="${Name.System}.${version}"> - <include name="${dist}/bin/**"/> - <exclude name="${dist}/bin/**/*.sf"/> - <exclude name="${dist}/bin/**/*.bat"/> - <exclude name="${dist}/bin/**/*.ini"/> - </tarfileset> - </tar> - - - <gzip src="releases/${Name.System}.${version}.${DSTAMP}_DIST.tar" - zipfile="releases/${Name.System}.${version}.${DSTAMP}_DIST.tar.gz"/> - <delete file="releases/${Name.System}.${version}.${DSTAMP}_DIST.tar"/> - - <tar tarfile="releases/${Name.System}.${version}.${DSTAMP}_ALL.tar" longfile="gnu"> - <tarfileset dir="." prefix="${Name.System}.${version}"> - - <include name="bin/**/*.sf"/> - <include name="bin/**/*.bat"/> - <include name="bin/**/*.ini"/> - <include name="doc/jetty_readme*"/> - <include name="lib/**"/> - <include name="src/**"/> - <include name="build.xml"/> - <include name="buildRelease.xml"/> - <include name="releaseBuild.xml"/> - <include name="rmitargets"/> - <include name="rmitargetsExamples"/> - <include name="parsertargets"/> - <include name="COPYRIGHT.txt"/> - <include name="LICENSE.txt"/> - <include name="changes.txt"/> - <include name="readme.txt"/> - <exclude name="**/SVN"/> - <exclude name="**/*.dfPackage"/> - <exclude name="**/Cvs"/> - <exclude name="bin/tools/**"/> - <exclude name="**/.#*"/> - <exclude name="**/*.*~"/> - </tarfileset> - <tarfileset dir="." prefix="${Name.System}.${version}" mode="755"> - <include name="bin/**"/> - <exclude name="bin/**/*.sf"/> - <exclude name="bin/**/*.bat"/> - <exclude name="bin/**/*.ini"/> - </tarfileset> - - <tarfileset dir="." prefix="${Name.System}.${version}"> - <include name="${dist}/bin/**/*.sf"/> - <include name="${dist}/bin/**/*.bat"/> - <include name="${dist}/bin/**/*.ini"/> - </tarfileset> - <tarfileset dir="." prefix="${Name.System}.${version}"> - <exclude name="${dist}/bin/**"/> - <include name="${dist}/**"/> - <exclude name="${dist}/classes/**"/> - <exclude name="${dist}/docs/**"/> - </tarfileset> - <tarfileset dir="." prefix="${Name.System}.${version}"> - <include name="${dist}/docs/jetty_readme*"/> - <include name="${dist}/docs/jdocs/**"/> - </tarfileset> - <tarfileset dir="." mode="755" prefix="${Name.System}.${version}"> - <include name="${dist}/bin/**"/> - <exclude name="${dist}/bin/**/*.sf"/> - <exclude name="${dist}/bin/**/*.bat"/> - <exclude name="${dist}/bin/**/*.ini"/> - </tarfileset> - </tar> - <gzip src="releases/${Name.System}.${version}.${DSTAMP}_ALL.tar" - zipfile="releases/${Name.System}.${version}.${DSTAMP}_ALL.tar.gz"/> - <delete file="releases/${Name.System}.${version}.${DSTAMP}_ALL.tar"/> - <!-- - <zip destfile="../${Name.System}.${version}.${DSTAMP}_JDOCS.zip"> - <zipfileset dir="." prefix="${Name.System}.${version}"> - <include name="${dist}/docs/jdocs/**"/> - </zipfileset> - </zip> - <tar tarfile="../${Name.System}.${version}.${DSTAMP}_JDOCS.tar" > - <tarfileset dir="." prefix="${Name.System}.${version}"> - <include name="${dist}/docs/jdocs/**"/> - </tarfileset> - </tar> - <gzip src="../${Name.System}.${version}.${DSTAMP}_JDOCS.tar" zipfile="../${Name.System}.${version}.${DSTAMP}_JDOCS.tar.gz"/> - <delete file="../${Name.System}.${version}.${DSTAMP}_JDOCS.tar"/> - --> - </target> -</project> - - <!-- End of file --> Modified: trunk/core/components/jetty/ivy.xml =================================================================== --- trunk/core/components/jetty/ivy.xml 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/ivy.xml 2007-09-27 15:45:25 UTC (rev 5197) @@ -61,30 +61,43 @@ changing="true" rev="latest.integration" conf="test->default"/> + <dependency org="javax.servlet" name="servlet-api" rev="${servletapi.version}" conf="compile->master;redist->default"/> + + <!-- + Core Jetty libraries + -we apply our own dependency logic to the components here + which is why the master is picked up. Everything else we need is asked for by hand + --> <dependency org="org.mortbay.jetty" name="jetty" rev="${jetty.version}" - conf="compile->default;redist->default"/> + conf="compile->master;redist->master"/> <dependency org="org.mortbay.jetty" - name="jetty" + name="jetty-util" rev="${jetty.version}" - conf="compile->default;redist->default"/> - <dependency org="tomcat" - name="jasper-runtime" - rev="${jetty.jasper.version}" - conf="jsp->default"/> - <dependency org="tomcat" - name="jasper-compiler" - rev="${jetty.jasper.version}" + conf="compile->master;redist->master"/> + + <!--JSP support --> + <dependency org="org.mortbay.jetty" + name="jsp-2.1" + rev="${jetty.version}" conf="jsp->master"/> - <dependency org="javax.servlet" - name="jsp-api" - rev="${jsp-api.version}" + <dependency org="org.mortbay.jetty" + name="jsp-api-2.1" + rev="${jetty.version}" conf="jsp->master"/> + <dependency org="org.apache.ant" + name="ant" + rev="${apache.ant.version}" + conf="jsp->master"/> + <dependency org="org.eclipse.jdt" + name="core" + rev="${org.eclipse.jdt.core.version}" + conf="jsp->master"/> <dependency org="commons-logging" name="commons-logging" rev="${commons-logging.version}" Deleted: trunk/core/components/jetty/releaseBuild.xml =================================================================== --- trunk/core/components/jetty/releaseBuild.xml 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/releaseBuild.xml 2007-09-27 15:45:25 UTC (rev 5197) @@ -1,199 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ ---> -<!DOCTYPE project [ - <!ENTITY security SYSTEM "private/buildSecurity.xml"> -]> -<!-- =========================================================================== - - - -Introduction -============ -To Be Written - - - - - -Installing the build tools -========================== -To Be Written - - - -Build targets -============= -These are the meaningful targets for this build file: - - build - - jdocs ---> - -<project name="JettyDist" default="help" basedir="."> - <!-- =================================================================== --> - <!-- Initialization target --> - <!-- =================================================================== --> - <target name="init"> - <property name="Name" value="Jetty Component"/> - <property name="name" value="(C) Copyright 1998-2006 Hewlett-Packard Development Company, LP"/> - <property name="version" value="DIST"/> - <loadproperties srcFile="version.properties"/> - <fail unless="sf.build.version">No property sf.build.version found in file version.properties</fail> - <property name="Version" value="${sf.build.version}" /> - <!--property name="Version" value="1.00.000_beta"/--> - <property name="year" value=""/> - <echo message=""/> - <echo message="==================================================================="/> - <echo message="= ${Name} ${version}"/> - <echo message="= ${name} "/> - <echo message="==================================================================="/> - </target> - - <!-- =================================================================== --> - <!-- Help on usage --> - <!-- =================================================================== --> - <target name="help" depends="init"> - <echo message=""/> - <echo message=""/> - <echo message="Jetty Component ${version} Build file"/> - <echo message="-------------------------------------------------------------"/> - <echo message=""/> - <echo message=" available targets are:"/> - <echo message=""/> - <echo message=" build --> compiles source files into sf-emailer-examples.jar"/> - <echo message=" jdocs --> creates jdocs for sources"/> - <echo message=""/> - <echo message=" See the comments inside the build.xml file for more details."/> - <echo message=""/> - <echo message=" -- ${Name}--"/> - <echo message=""/> - <echo message="-------------------------------------------------------------"/> - <echo message=""/> - <echo message=""/> - </target> - - <!-- =================================================================== --> - <!-- Global properties --> - <!-- =================================================================== --> - <property name="dist" value="."/> - <property name="bin" value="bin"/> - <property name="lib" value="lib"/> - <property name="docs" value="docs"/> - <property name="build" value="classes"/> <!-- all protected files --> - <property name="src" value="src"/> <!-- all protected files --> - <property name="debugmode" value="on"/> <!-- turn on compile -g --> - <property name="jdocs" value="${dist}/${docs}/jdocs"/> - - <!-- =================================================================== --> - <!-- Initialization path (Libs needed for compiling) --> - <!-- =================================================================== --> - <path id="jetty.class.path"> - <pathelement path="${classpath}"/> - <pathelement location="lib/**.jar"/> - <!--pathelement location="lib/jasper-compiler.jar"/> - <pathelement location="lib/jasper-runtime.jar"/> - <pathelement location="lib/javax.servlet.jar"/> - <pathelement location="lib/org.mortbay.jetty.jar"/> - <pathelement location="lib/org.mortbay.jmx.jar"/--> - </path> - - <!-- =================================================================== --> - <!-- Creates directories --> - <!-- =================================================================== --> - <target name="initbuild" depends="init"> - <mkdir dir="${build}"/> - </target> - - - <!-- =================================================================== --> - <!-- clean --> - <!-- =================================================================== --> - <target name="cleanBuild" depends="" description="Restores the distribution to its clean state"> - <!-- Delete the ${build} ${dist} ${jdocs} directory trees --> - <!-- remove parser source files --> - <delete dir="${build}"/> - <delete dir="${jdocs}"/> - </target> - - <!-- =================================================================== --> - <!-- Copy .sf files to "build" directories --> - <!-- =================================================================== --> - <target name="copyFiles" depends="initbuild"> - <copy todir="${build}"> - <fileset dir="${src}"> - <include name="**/*.sf*" /> - </fileset> - </copy> - </target> - - <!-- =================================================================== --> - <!-- Compiles source directory --> - <!-- =================================================================== --> - <target name="build" depends="copyFiles,initbuild" description="Compiles source code"> - <!-- Compile the java code from ${src} into ${build} --> - <javac srcdir="${src}" destdir="${build}" debug="${debugmode}" compiler="javac1.4" source="1.4"> - <classpath refid="jetty.class.path"/> - </javac> - <rmic base="${build}" includes="**/*.class"> - <classpath refid="jetty.class.path"/> - </rmic> - <!-- sfExamples.jar --> - <!-- Create sfExamples.jar file --> - <jar jarfile="${lib}/sf-jetty-examples.jar" - basedir="${build}" - includes="**/examples/**"/> - </target> - - <!-- =================================================================== --> - <!-- JDocs --> - <!-- =================================================================== --> - <target name="jdocs" depends="init" description="Generates the API documentation"> - <!-- Java Docs for all --> - <echo message=""/> - <echo message="------------------------------------------------------------------------"/> - <echo message=" Creating Java Docs for ${Name} examples [${jdocs}]"/> - <echo message="------------------------------------------------------------------------"/> - <mkdir dir="${jdocs}"/> - <javadoc packagenames="org.smartfrog.*" - sourcepath="${src}" - destdir="${jdocs}" - author="true" - version="true" - Header="${Name.System} ${Version}" - Footer="${Name.System} ${version} ${Version}" - use="true" - windowtitle="${Name}" - doctitle="${Name}" - bottom="${name}" - source="1.4"> - <group title="Jetty Examples Package" packages="org.smartfrog.*"/> - <classpath refid="jetty.class.path"/> - </javadoc> - </target> - -</project> - - - -<!-- End of file --> - Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyHelper.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyHelper.java 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyHelper.java 2007-09-27 15:45:25 UTC (rev 5197) @@ -21,10 +21,9 @@ package org.smartfrog.services.jetty; -import org.mortbay.http.HttpContext; -import org.mortbay.http.HttpListener; -import org.mortbay.http.HttpServer; -import org.mortbay.jetty.servlet.ServletHttpContext; +import org.mortbay.jetty.Connector; +import org.mortbay.jetty.Server; +import org.mortbay.jetty.servlet.Context; import org.smartfrog.services.jetty.contexts.JettyServletContextIntf; import org.smartfrog.services.www.ApplicationServerContext; import org.smartfrog.services.www.WebApplicationHelper; @@ -32,9 +31,7 @@ import org.smartfrog.sfcore.common.SmartFrogResolutionException; import org.smartfrog.sfcore.common.SmartFrogRuntimeException; import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.utils.ComponentHelper; -import java.net.InetAddress; import java.rmi.RemoteException; /** @@ -47,7 +44,7 @@ /** * the server */ - private HttpServer httpServer; + private Server httpServer; /** @@ -55,27 +52,8 @@ */ private Prim serverComponent = null; - /** - * Name of the interface of jetty component we look for. - * <p/> - * {@value} - */ - public static final String JETTY_INTERFACE_NAME = "org.smartfrog.services.jetty.JettyIntf"; - // - /** - * Name of the servlet interface of jetty component we look for. - * <p/> - * {@value} - */ - public static final String JETTY_SERVLET_INTERFACE = "org.smartfrog.services.jetty.contexts.JettyServletContextIntf"; /** - * max depth to recurse down - */ - - private static final int MAX_PARENT_DEPTH = 99999; - - /** * Error if we cannot locate an app server. * {@value} */ @@ -92,7 +70,7 @@ * @throws RemoteException network problems * */ - public HttpServer bindToServer() throws SmartFrogException, + public Server bindToServer() throws SmartFrogException, RemoteException { findJettyComponent(); httpServer = findJettyServer(); @@ -114,12 +92,12 @@ * @throws SmartFrogException smartfrog problems, including no server found * @throws RemoteException network problems */ - private HttpServer findJettyServer() throws SmartFrogException, + private Server findJettyServer() throws SmartFrogException, RemoteException { assert serverComponent != null; - HttpServer server = null; + Server server = null; server = - (HttpServer) serverComponent.sfResolve(JettyIntf.ATTR_JETTY_SERVER, + (Server) serverComponent.sfResolve(JettyIntf.ATTR_JETTY_SERVER, server, true); return server; @@ -151,7 +129,7 @@ * @throws SmartFrogException a failure of the operation to set the server * @throws RemoteException network problems */ - public void cacheJettyServer(HttpServer server) + public void cacheJettyServer(Server server) throws SmartFrogException, RemoteException { getOwner().sfReplaceAttribute(JettyIntf.ATTR_JETTY_SERVER, server); @@ -196,15 +174,15 @@ * @throws SmartFrogException * @throws RemoteException */ - public ServletHttpContext getServletContext(boolean mandatory) + public Context getServletContext(boolean mandatory) throws SmartFrogException, RemoteException { - ServletHttpContext jettyContext = null; + Context jettyContext = null; Prim contextImpl = findServletContext(); if (contextImpl != null) { - jettyContext = (ServletHttpContext) contextImpl. + jettyContext = (Context) contextImpl. sfResolve(JettyServletContextIntf.ATTR_CONTEXT); } if (mandatory && jettyContext == null) { @@ -219,6 +197,13 @@ /** * find whatever ancestor is a servlet context */ + /** + * Find the servlet context. + * This is done by resolving the owner and looking for its server attribute + * @return the owner server, null if there is no server, + * @throws RemoteException network trouble + * @throws SmartFrogResolutionException failure to resolve + */ public Prim findServletContext() throws RemoteException, SmartFrogResolutionException { return getOwner().sfResolve(ApplicationServerContext.ATTR_SERVER,(Prim)null,false); } @@ -227,19 +212,19 @@ /** * add a listener to the server * - * @param listener + * @param listener a listener */ - public void addListener(HttpListener listener) { - httpServer.addListener(listener); + public void addListener(Connector listener) { + httpServer.addConnector(listener); } /** * add a listener, then start it * - * @param listener - * @throws SmartFrogException + * @param listener a listener + * @throws SmartFrogException failue to start the listener */ - public void addAndStartListener(HttpListener listener) + public void addAndStartListener(Connector listener) throws SmartFrogException { addListener(listener); try { @@ -251,11 +236,11 @@ /** * remove a listener - * @param listener + * @param listener a listener */ - public void removeListener(HttpListener listener) { + public void removeListener(Connector listener) { if (httpServer != null) { - httpServer.removeListener(listener); + httpServer.removeConnector(listener); } } @@ -264,16 +249,16 @@ * * @return server or null if unbound. */ - public HttpServer getServer() { + public Server getServer() { return httpServer; } /** * terminate a context log failures but do not throw anything * - * @param context + * @param context context to terminate */ - public void terminateContext(HttpContext context) { + public void terminateContext(Context context) { if (context != null) { try { context.stop(); @@ -284,7 +269,7 @@ } } if (httpServer != null) { - httpServer.removeContext(context); + httpServer.removeLifeCycle(context); } } } @@ -292,9 +277,9 @@ /** * terminate a listener; log trouble but continue * - * @param listener + * @param listener a listener */ - public synchronized void terminateListener(HttpListener listener) { + public synchronized void terminateListener(Connector listener) { if (listener != null) { try { listener.stop(); @@ -303,12 +288,10 @@ getLogger().error(" Interrupted on listener termination ", ex); } - } catch (NullPointerException npe) { - if (getLogger().isErrorEnabled()) { - getLogger().warn( - " Dropping NPE caught during Jetty teardown", + } catch (Exception npe) { + getLogger().error( + " Ignoring caught during Jetty teardown", npe); - } } removeListener(listener); } Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyIntf.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyIntf.java 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyIntf.java 2007-09-27 15:45:25 UTC (rev 5197) @@ -62,6 +62,32 @@ */ public static final String ATTR_LOGPATTERN="logPattern"; - + /** + * timezone for log data + * {@value} + */ + + public static final String ATTR_LOG_TZ = "logTimezone"; + + /** + * max# of threads in the pool. + * {@value} + */ + public static final String ATTR_MAXTHREADS="maxThreads"; + + /** + * min# of threads in the pool. + * {@value} + */ + public static final String ATTR_MINTHREADS = "minThreads"; + + /** + * max idle time for a thread before it is closed + * {@value} + */ + + public static final String ATTR_MAXIDLETIME = "maxIdleTime"; + + } Added: trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyToSFLifecycle.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyToSFLifecycle.java (rev 0) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyToSFLifecycle.java 2007-09-27 15:45:25 UTC (rev 5197) @@ -0,0 +1,86 @@ +/** (C) Copyright 2007 Hewlett-Packard Development Company, LP + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +For more information: www.smartfrog.org + +*/ +package org.smartfrog.services.jetty; + +import org.mortbay.component.LifeCycle; +import org.smartfrog.sfcore.prim.Liveness; +import org.smartfrog.sfcore.common.SmartFrogLivenessException; +import org.smartfrog.sfcore.common.SmartFrogException; + +import java.rmi.RemoteException; + +/** + * + * Something to bridge ping and stop operations to jetty + * Created 27-Sep-2007 16:25:34 + * + */ + +public class JettyToSFLifecycle implements Liveness { + + private String name; + private LifeCycle jettyComponent; + /** Error string raised in liveness checks. {@value} */ + public static final String LIVENESS_ERROR_NOT_STARTED = " is not active"; + public static final String LIVENESS_ERROR_NOT_RUNNING = "is not running"; + public static final String LIVENESS_ERROR_FAILED = " has failed"; + + public JettyToSFLifecycle(String name, LifeCycle jettyComponent) { + this.name = name; + this.jettyComponent = jettyComponent; + } + + /** + * liveness test verifies the server is started + * + * @param source caller + * @throws SmartFrogLivenessException the server is not started + * @throws RemoteException network trouble + */ + public synchronized void sfPing(Object source) throws SmartFrogLivenessException, RemoteException { + if (jettyComponent == null) { + throw new SmartFrogLivenessException(name+LIVENESS_ERROR_NOT_STARTED); + } + if (jettyComponent.isFailed()) { + throw new SmartFrogLivenessException(name +LIVENESS_ERROR_FAILED); + } + if (!jettyComponent.isRunning()) { + throw new SmartFrogLivenessException(name +LIVENESS_ERROR_NOT_RUNNING); + } + } + + public synchronized void stop() throws Exception { + if(jettyComponent!=null) { + jettyComponent.stop(); + jettyComponent=null; + } + } + + public synchronized void start() throws SmartFrogException { + try { + if(jettyComponent!=null) { + jettyComponent.start(); + } + } catch (Exception e) { + throw SmartFrogException.forward(e); + } + } + +} Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/SFJetty.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/SFJetty.java 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/SFJetty.java 2007-09-27 15:45:25 UTC (rev 5197) @@ -1,27 +1,28 @@ /** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -For more information: www.smartfrog.org + For more information: www.smartfrog.org -*/ + */ package org.smartfrog.services.jetty; -import org.mortbay.http.HttpServer; -import org.mortbay.http.NCSARequestLog; +import org.mortbay.jetty.NCSARequestLog; +import org.mortbay.jetty.Server; +import org.mortbay.thread.BoundedThreadPool; import org.smartfrog.services.filesystem.FileSystem; import org.smartfrog.services.jetty.contexts.delegates.DelegateServletContext; import org.smartfrog.services.jetty.contexts.delegates.DelegateWebApplicationContext; @@ -50,52 +51,36 @@ private final Reference jettyhomeRef = new Reference(ATTR_JETTY_HOME); - /** - * Jetty home path - */ + /** Jetty home path */ private String jettyhome; - /** - * A jetty helper - */ + /** A jetty helper */ private JettyHelper jettyHelper = new JettyHelper(this); - /** - * The Http server - */ - private HttpServer server; + /** The Http server */ + private Server server; + private JettyToSFLifecycle serverBridge = new JettyToSFLifecycle("server", null); - /** - * flag to turn logging on. - */ + /** flag to turn logging on. */ private boolean enableLogging = false; private String logDir; private String logPattern; - /** - * log pattern. - * {@value} - */ + /** log pattern. {@value} */ public static final String LOG_PATTERN = "yyyy_mm_dd.request.log"; - /** - * log subdirectory. - * {@value} - */ + /** log subdirectory. {@value} */ public static final String LOG_SUBDIR = "/logs/"; - /** - * Error string raised in liveness checks. - * {@value} - */ - public static final String LIVENESS_ERROR_SERVER_NOT_STARTED = "Server is not started"; + /** Error string raised when EARs are deployed {@value} */ public static final String ERROR_EAR_UNSUPPORTED = "Jetty does not support EAR files"; /** * Standard RMI constructor - * @throws RemoteException In case of network/rmi error + * + * @throws RemoteException In case of network/rmi error */ public SFJetty() throws RemoteException { @@ -106,7 +91,7 @@ * * @return the server or null if not currently deployed. */ - public HttpServer getServer() { + public Server getServer() { return server; } @@ -119,7 +104,13 @@ public synchronized void sfDeploy() throws SmartFrogException, RemoteException { try { super.sfDeploy(); - server = new HttpServer(); + server = new Server(); + serverBridge = new JettyToSFLifecycle("server", server); + BoundedThreadPool pool = new BoundedThreadPool(); + pool.setMaxThreads(sfResolve(ATTR_MAXTHREADS, 0, true)); + pool.setMinThreads(sfResolve(ATTR_MINTHREADS, 0, true)); + pool.setMaxIdleTimeMs(sfResolve(ATTR_MAXIDLETIME, 0, true)); + server.setThreadPool(pool); jettyHelper.cacheJettyServer(server); jettyhome = sfResolve(jettyhomeRef, jettyhome, true); jettyHelper.cacheJettyHome(jettyhome); @@ -146,15 +137,12 @@ public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); - try { - server.start(); - } catch (Exception mexp) { - throw SmartFrogException.forward(mexp); - } + serverBridge.start(); } /** * Configure the http server + * * @throws SmartFrogException In case of error while starting */ public void configureLogging() throws SmartFrogException { @@ -168,30 +156,28 @@ requestlog.setAppend(true); requestlog.setExtended(true); //todo: make options - requestlog.setLogTimeZone("GMT"); + requestlog.setLogTimeZone(sfResolve(ATTR_LOG_TZ, "", true)); String[] paths = {"/jetty/images/*", "/demo/images/*", "*.css"}; requestlog.setIgnorePaths(paths); - server.setRequestLog(requestlog); + server.addLifeCycle(requestlog); } } catch (Exception ex) { throw SmartFrogException.forward(ex); } } - /** - * Termination phase - * Shut down the server, logging any errors that happen on the way - */ + /** Termination phase Shut down the server, logging any errors that happen on the way */ public synchronized void sfTerminateWith(TerminationRecord status) { + try { - if (server != null) { - server.stop(); - } + serverBridge.stop(); } catch (InterruptedException ie) { if (sfLog().isErrorEnabled()) { - sfLog().error(" Interrupted on server termination ", ie); + sfLog().error("Interrupted on server termination ", ie); } + } catch (Exception ie) { + sfLog().error("while terminating Jetty server", ie); } super.sfTerminateWith(status); } @@ -201,28 +187,25 @@ * * @param source caller * @throws SmartFrogLivenessException the server is not started - * @throws RemoteException network trouble + * @throws RemoteException network trouble */ public void sfPing(Object source) throws SmartFrogLivenessException, RemoteException { super.sfPing(source); - if (server == null || !server.isStarted()) { - throw new SmartFrogLivenessException(LIVENESS_ERROR_SERVER_NOT_STARTED); - } + serverBridge.sfPing(source); } /** - * deploy a web application. - * Deploys a web application identified by the component passed as a parameter; a component of arbitrary - * type but which must have the mandatory attributes identified in - * {@link org.smartfrog.services.www.JavaWebApplication}; - * possibly even extra types required by the particular application server. + * deploy a web application. Deploys a web application identified by the component passed as a parameter; a + * component of arbitrary type but which must have the mandatory attributes identified in {@link + * org.smartfrog.services.www.JavaWebApplication}; possibly even extra types required by the particular application + * server. * - * @param webApplication the web application. this must be a component whose attributes include the - * mandatory set of attributes defined for a JavaWebApplication component. Application-server specific attributes - * (both mandatory and optional) are also permitted + * @param webApplication the web application. this must be a component whose attributes include the mandatory set of + * attributes defined for a JavaWebApplication component. Application-server specific + * attributes (both mandatory and optional) are also permitted * @return an entry * @throws SmartFrogException errors thrown by the delegate - * @throws RemoteException network trouble + * @throws RemoteException network trouble */ public JavaWebApplication deployWebApplication(Prim webApplication) throws RemoteException, SmartFrogException { @@ -238,9 +221,10 @@ * @param enterpriseApplication the application * @return an entry referring to the application * @throws SmartFrogException always - * @throws RemoteException network trouble + * @throws RemoteException network trouble */ - public JavaEnterpriseApplication deployEnterpriseApplication(Prim enterpriseApplication) throws RemoteException, SmartFrogException { + public JavaEnterpriseApplication deployEnterpriseApplication(Prim enterpriseApplication) + throws RemoteException, SmartFrogException { throw new SmartFrogException(ERROR_EAR_UNSUPPORTED); } @@ -249,7 +233,7 @@ * * @param servletContext the servlet context * @return a token referring to the application - * @throws RemoteException network trouble + * @throws RemoteException network trouble * @throws SmartFrogException on any other problem */ public ServletContextIntf deployServletContext(Prim servletContext) throws RemoteException, SmartFrogException { Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/SFJettyAdmin.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/SFJettyAdmin.java 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/SFJettyAdmin.java 2007-09-27 15:45:25 UTC (rev 5197) @@ -21,13 +21,14 @@ package org.smartfrog.services.jetty; -import org.mortbay.http.BasicAuthenticator; -import org.mortbay.http.HashUserRealm; -import org.mortbay.http.HttpServer; -import org.mortbay.http.SecurityConstraint; -import org.mortbay.http.SocketListener; -import org.mortbay.http.handler.SecurityHandler; -import org.mortbay.jetty.servlet.ServletHttpContext; +import org.mortbay.jetty.Server; +import org.mortbay.jetty.bio.SocketConnector; +import org.mortbay.jetty.security.BasicAuthenticator; +import org.mortbay.jetty.security.Constraint; +import org.mortbay.jetty.security.ConstraintMapping; +import org.mortbay.jetty.security.HashUserRealm; +import org.mortbay.jetty.security.SecurityHandler; +import org.mortbay.jetty.servlet.Context; import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.PrimImpl; @@ -37,11 +38,9 @@ import java.rmi.RemoteException; /** - * A wrapper for a Jetty http server for admin configurations + * A wrapper for a Jetty HTTP server for admin configurations * - * Look at this, tehre's no reason why this shouldnt be donen from the normal - * Jetty component. If you cannot do it declaratively, then the components - * need improving. + * @TODO Revisit this and try and reimplement from SF itself. Its a good use case of the servlet mappings * * @author Ritu Sabharwal */ @@ -58,17 +57,17 @@ /** * The server */ - private HttpServer server; + private Server server; /** * The Socket listener */ - private SocketListener listener = new SocketListener(); + private SocketConnector listener = new SocketConnector(); /** * Realm context */ - private ServletHttpContext realmcontext = new ServletHttpContext(); + private Context realmcontext = new Context(); /** * User realm @@ -93,12 +92,12 @@ RemoteException { super.sfStart(); try { - server = new HttpServer(); + server = new Server(); listenerPort = sfResolve(listenerPortRef, listenerPort, true); httpserverHost = sfResolve(httpserverHostRef, httpserverHost, false); contextPath = sfResolve(contextPathRef, "/", false); - configureHttpServer(); + configureServer(); } catch (Exception ex) { throw SmartFrogDeploymentException.forward(ex); } @@ -113,29 +112,34 @@ * Configure the http server for admin configurations * @throws SmartFrogException In case of error while starting */ - public void configureHttpServer() throws SmartFrogException { + public void configureServer() throws SmartFrogException { try { listener.setPort(listenerPort); listener.setHost(httpserverHost); - server.addListener(listener); + server.addConnector(listener); admin_realm.put("admin", "admin"); admin_realm.addUserToRole("admin", "server-administrator"); - server.addRealm(admin_realm); + server.addUserRealm(admin_realm); realmcontext.setContextPath(contextPath); - realmcontext.setRealmName(ADMIN_REALM_NAME); - realmcontext.setAuthenticator(new BasicAuthenticator()); - realmcontext.addHandler(new SecurityHandler()); - realmcontext.addSecurityConstraint("/", - new SecurityConstraint("Admin", - "server-administrator")); - realmcontext.addServlet("Debug", "/Debug/*", - "org.mortbay.servlet.Debug"); - realmcontext.addServlet("Admin", "/", - "org.mortbay.servlet.AdminServlet"); - realmcontext.setAttribute("org.mortbay.http.HttpServer", - realmcontext.getHttpServer()); - server.addContext(realmcontext); - server.setAnonymous(true); + realmcontext.setDisplayName(ADMIN_REALM_NAME); + SecurityHandler security=new SecurityHandler(); + security.setAuthenticator(new BasicAuthenticator()); + realmcontext.addHandler(security); + Constraint constraint=new Constraint("Admin", + "server-administrator"); + ConstraintMapping[] constraints=new ConstraintMapping[1]; + constraints[0]=new ConstraintMapping(); + constraints[0].setConstraint(constraint); + constraints[0].setPathSpec("/"); + security.setConstraintMappings(constraints); + realmcontext.addServlet("/Debug/*", + "org.mortbay.servlet.Debug").setDisplayName("Debug"); + realmcontext.addServlet("/", + "org.mortbay.servlet.AdminServlet").setDisplayName("Admin"); + realmcontext.setAttribute("org.mortbay.http.Server", + realmcontext.getServer()); + server.addLifeCycle(realmcontext); + //server.setAnonymous(true); } catch (Exception ex) { throw SmartFrogException.forward(ex); } @@ -145,11 +149,11 @@ * Termination phase. shut the server and the listener */ public synchronized void sfTerminateWith(TerminationRecord status) { - server.removeListener(listener); - server.removeContext(realmcontext); + server.removeConnector(listener); + server.removeLifeCycle(realmcontext); try { server.stop(); - } catch (InterruptedException ie) { + } catch (Exception ie) { if (sfLog().isErrorEnabled()){ sfLog().error(" Interrupted on server termination " , ie); } Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateApplicationContext.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateApplicationContext.java 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateApplicationContext.java 2007-09-27 15:45:25 UTC (rev 5197) @@ -19,8 +19,8 @@ */ package org.smartfrog.services.jetty.contexts.delegates; -import org.mortbay.http.HttpContext; -import org.mortbay.http.HttpServer; +import org.mortbay.jetty.Server; +import org.mortbay.jetty.servlet.Context; import org.smartfrog.services.jetty.SFJetty; import org.smartfrog.services.www.ApplicationServerContext; import org.smartfrog.sfcore.common.SmartFrogException; @@ -41,7 +41,7 @@ * @param server jetty sever * @param context context */ - protected DelegateApplicationContext(SFJetty server, HttpContext context) { + protected DelegateApplicationContext(SFJetty server, Context context) { this.server = server; this.context = context; } @@ -57,7 +57,7 @@ /** * The actual context */ - private HttpContext context; + private Context context; /** @@ -74,7 +74,7 @@ * * @return the context; will be null if not running */ - public HttpContext getContext() { + public Context getContext() { return context; } @@ -83,7 +83,7 @@ * * @param context the jetty context */ - public void setContext(HttpContext context) { + public void setContext(Context context) { this.context = context; } @@ -105,7 +105,7 @@ */ public void start() throws SmartFrogException, RemoteException { if (context != null) { - getServer().getServer().addContext(getContext()); + getServer().getServer().addLifeCycle(getContext()); try { getContext().start(); } catch (RemoteException ex) { @@ -144,9 +144,9 @@ public void terminate() throws RemoteException, SmartFrogException { if (context != null) { try { - HttpServer httpServer = getServer().getServer(); + Server httpServer = getServer().getServer(); if (httpServer != null) { - httpServer.removeContext(context); + httpServer.removeLifeCycle(context); } else { //do nothing, the server is not alive any more } Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateServletContext.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateServletContext.java 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateServletContext.java 2007-09-27 15:45:25 UTC (rev 5197) @@ -19,10 +19,10 @@ */ package org.smartfrog.services.jetty.contexts.delegates; -import org.mortbay.http.HttpContext; -import org.mortbay.http.HttpHandler; -import org.mortbay.http.handler.ResourceHandler; -import org.mortbay.jetty.servlet.ServletHttpContext; +import org.mortbay.jetty.Handler; +import org.mortbay.jetty.MimeTypes; +import org.mortbay.jetty.handler.ResourceHandler; +import org.mortbay.jetty.servlet.Context; import org.smartfrog.services.jetty.JettyHelper; import org.smartfrog.services.jetty.SFJetty; import org.smartfrog.services.www.ServletComponent; @@ -30,10 +30,10 @@ import org.smartfrog.services.www.ServletContextIntf; import org.smartfrog.services.www.WebApplicationHelper; import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.logging.Log; +import org.smartfrog.sfcore.logging.LogFactory; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.reference.Reference; -import org.smartfrog.sfcore.logging.Log; -import org.smartfrog.sfcore.logging.LogFactory; import java.io.File; import java.rmi.RemoteException; @@ -61,11 +61,11 @@ * Get the context cast to a servlet context * @return the servlet context of jetty */ - public final ServletHttpContext getServletContext() { - return (ServletHttpContext)getContext(); + public final Context getServletContext() { + return (Context)getContext(); } - public DelegateServletContext(SFJetty server, HttpContext context) { + public DelegateServletContext(SFJetty server, Context context) { super(server, context); } @@ -81,7 +81,7 @@ public void deploy(Prim declaration) throws SmartFrogException, RemoteException { log = LogFactory.getOwnerLog(declaration); JettyHelper jettyHelper = new JettyHelper(declaration); - ServletHttpContext context = new ServletHttpContext(); + Context context = new Context(); setContext(context); jettyHelper.setServerComponent(getServer()); String jettyhome = jettyHelper.findJettyHome(); @@ -100,14 +100,14 @@ } //classpath stuff. //REVISIT: what does this bring to the table? - String classPath = declaration.sfResolve(classPathRef, (String) null, false); +/* String classPath = declaration.sfResolve(classPathRef, (String) null, false); if (classPath != null) { if (!new File(classPath).exists()) { classPath = jettyhome+classPath; } log.info("Jetty classpath="+classPath); context.setClassPath(classPath); - } + }*/ //configure the context log.debug("Jetty resource base ="+resourceBase); context.setResourceBase(resourceBase); @@ -137,8 +137,9 @@ * @throws RemoteException network problems */ public void addMimeMapping(String extension, String mimeType) throws RemoteException, SmartFrogException { - getServletContext().setMimeMapping(extension, mimeType); log.info("Adding mime mapping "+extension+" maps to "+mimeType); + MimeTypes mimes = getServletContext().getMimeTypes(); + mimes.addMimeMapping(extension,mimeType); } /** @@ -151,9 +152,13 @@ */ public boolean removeMimeMapping(String extension) throws RemoteException, SmartFrogException { - Map mimeMap = getServletContext().getMimeMap(); log.info("removing mime mapping " + extension); - return (mimeMap.remove(extension) != null); + Map mimeMap = getServletContext().getMimeTypes().getMimeMap(); + if(mimeMap!=null) { + return (mimeMap.remove(extension) != null); + } else { + return false; + } } /** @@ -177,9 +182,9 @@ * @throws SmartFrogException smartfrog problems * @throws RemoteException network problems */ - public void addHandler(HttpHandler handler) throws SmartFrogException, + public void addHandler(Handler handler) throws SmartFrogException, RemoteException { - ServletHttpContext context = getServletContext(); + Context context = getServletContext(); context.addHandler(handler); } @@ -190,16 +195,17 @@ * @throws SmartFrogException smartfrog problems * @throws RemoteException network problems */ - public void removeHandler(HttpHandler handler) throws SmartFrogException, RemoteException { - ServletHttpContext context = getServletContext(); + public void removeHandler(Handler handler) throws SmartFrogException, RemoteException { try { if(handler.isStarted()) { handler.stop(); } - } catch (InterruptedException ignore) { - //ignore + } catch (Exception ignore) { + log.info(ignore); } - context.removeHandler(handler); + //TODO: remove the handler? + Context context = getServletContext(); + //context.removeHandler(handler); } Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateWebApplicationContext.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateWebApplicationContext.java 2007-09-27 15:44:21 UTC (rev 5196) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateWebApplicationContext.java 2007-09-27 15:45:25 UTC (rev 5197) @@ -20,10 +20,8 @@ package org.smartfrog.services.jetty.contexts.delegates; -import org.mortbay.http.HttpServer; -import org.mortbay.jetty.servlet.AbstractSessionManager; import org.mortbay.jetty.servlet.ServletHandler; -import org.mortbay.jetty.se... [truncated message content] |