[CVS spice] initial import out of the sandbox
proyal-yCVjj/[email protected] 5 Jul 2005 13:32:16 -0000
| Newsgroups | gmane.comp.java.spice.cvs |
|---|---|
| Message-ID | <[email protected]> |
<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>spice/components/jervlet</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt>lib/<span id="added">avalon-framework-api-4.1.5.jar</span></tt></td><td colspan="2" align="center"><small id="info">[binary]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<span id="added">avalon-framework-impl-4.1.5.jar</span></tt></td><td colspan="2" align="center"><small id="info">[binary]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<span id="added">dna-api-1.1.jar</span></tt></td><td colspan="2" align="center"><small id="info">[binary]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<span id="added">dna-impl-1.1.jar</span></tt></td><td colspan="2" align="center"><small id="info">[binary]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<span id="added">org.mortbay.jetty.jar</span></tt></td><td colspan="2" align="center"><small id="info">[binary]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<span id="added">picocontainer-1.0.jar</span></tt></td><td colspan="2" align="center"><small id="info">[binary]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<span id="added">servlet.jar</span></tt></td><td colspan="2" align="center"><small id="info">[binary]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>src/java/org/codehaus/spice/jervlet/containers/jetty/avalon/<a href="#file8"><span id="added">AvalonJettyContainer.java</span></a></tt></td><td align="right" id="added">+266</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>src/java/org/codehaus/spice/jervlet/containers/jetty/<a href="#file9"><span id="added">DefaultJettyContainer.java</span></a></tt></td><td align="right" id="added">+317</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file10"><span id="added">JettyContainer.java</span></a></tt></td><td align="right" id="added">+68</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file11"><span id="added">JettyContextHandler.java</span></a></tt></td><td align="right" id="added">+293</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file12"><span id="added">JettyFilterHolder.java</span></a></tt></td><td align="right" id="added">+105</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file13"><span id="added">JettyServer.java</span></a></tt></td><td align="right" id="added">+465</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file14"><span id="added">JettyServletHolder.java</span></a></tt></td><td align="right" id="added">+106</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file15"><span id="added">JettyWebApplicationHandler.java</span></a></tt></td><td align="right" id="added">+147</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file16"><span id="added">ShieldingJettyContainer.java</span></a></tt></td><td align="right" id="added">+525</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>src/java/org/codehaus/spice/jervlet/impl/avalon/<a href="#file17"><span id="added">AvalonContextMonitor.java</span></a></tt></td><td align="right" id="added">+256</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file18"><span id="added">AvalonInstantiator.java</span></a></tt></td><td align="right" id="added">+144</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file19"><span id="added">AvalonInstantiatorComponent.java</span></a></tt></td><td align="right" id="added">+98</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file20"><span id="added">AvalonListenerMonitor.java</span></a></tt></td><td align="right" id="added">+313</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file21"><span id="added">SimpleAvalonDeployer.java</span></a></tt></td><td align="right" id="added">+192</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>src/java/org/codehaus/spice/jervlet/impl/dna/<a href="#file22"><span id="added">DNAInstantiator.java</span></a></tt></td><td align="right" id="added">+80</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>src/java/org/codehaus/spice/jervlet/impl/pico/<a href="#file23"><span id="added">PicoInstantiator.java</span></a></tt></td><td align="right" id="added">+104</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>src/java/org/codehaus/spice/jervlet/impl/<a href="#file24"><span id="added">AbstractDeploymentHelper.java</span></a></tt></td><td align="right" id="added">+161</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file25"><span id="added">AbstractInstantiator.java</span></a></tt></td><td align="right" id="added">+85</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file26"><span id="added">DefaultContext.java</span></a></tt></td><td align="right" id="added">+111</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file27"><span id="added">DefaultListener.java</span></a></tt></td><td align="right" id="added">+66</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file28"><span id="added">NoopContextMonitor.java</span></a></tt></td><td align="right" id="added">+172</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file29"><span id="added">NoopListenerMonitor.java</span></a></tt></td><td align="right" id="added">+168</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file30"><span id="added">StandardServletInstantiator.java</span></a></tt></td><td align="right" id="added">+35</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>src/java/org/codehaus/spice/jervlet/tools/isolate/<a href="#file31"><span id="added">DemuxProperties.java</span></a></tt></td><td align="right" id="added">+240</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file32"><span id="added">SysPropertiesRedirector.java</span></a></tt></td><td align="right" id="added">+115</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>src/java/org/codehaus/spice/jervlet/<a href="#file33"><span id="added">Container.java</span></a></tt></td><td align="right" id="added">+51</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file34"><span id="added">Context.java</span></a></tt></td><td align="right" id="added">+64</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file35"><span id="added">ContextException.java</span></a></tt></td><td align="right" id="added">+53</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file36"><span id="added">ContextHandler.java</span></a></tt></td><td align="right" id="added">+71</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file37"><span id="added">ContextMonitor.java</span></a></tt></td><td align="right" id="added">+130</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file38"><span id="added">Instantiator.java</span></a></tt></td><td align="right" id="added">+35</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file39"><span id="added">Listener.java</span></a></tt></td><td align="right" id="added">+53</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file40"><span id="added">ListenerException.java</span></a></tt></td><td align="right" id="added">+53</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file41"><span id="added">ListenerHandler.java</span></a></tt></td><td align="right" id="added">+58</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file42"><span id="added">ListenerMonitor.java</span></a></tt></td><td align="right" id="added">+134</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>src/test/org/codehaus/spice/jervlet/containers/jetty/avalon/<a href="#file43"><span id="added">AvalonJettyContainerTestCase.java</span></a></tt></td><td align="right" id="added">+134</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>src/test/org/codehaus/spice/jervlet/containers/jetty/<a href="#file44"><span id="added">ShieldingJettyContainerTestCase.java</span></a></tt></td><td align="right" id="added">+69</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>testdata/jetty/logs/<span id="added">2005_03_11.request.log</span></tt></td><td colspan="2" align="center"><small id="info">[empty]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<span id="added">2005_03_17.request.log</span></tt></td><td colspan="2" align="center"><small id="info">[empty]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<span id="added">2005_03_22.request.log</span></tt></td><td colspan="2" align="center"><small id="info">[empty]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<span id="added">2005_06_20.request.log</span></tt></td><td colspan="2" align="center"><small id="info">[empty]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>testdata/jetty/<a href="#file49"><span id="added">jetty.xml</span></a></tt></td><td align="right" id="added">+216</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file50"><span id="added">webdefault.xml</span></a></tt></td><td align="right" id="added">+367</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>testdata/webapps/template/WEB-INF/<a href="#file51"><span id="added">web.xml</span></a></tt></td><td align="right" id="added">+45</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>testdata/webapps/template/src/com/acme/<a href="#file52"><span id="added">DemoFilter.java</span></a></tt></td><td align="right" id="added">+44</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file53"><span id="added">DumpServlet.java</span></a></tt></td><td align="right" id="added">+100</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>testdata/webapps/template/<a href="#file54"><span id="added">build.xml</span></a></tt></td><td align="right" id="added">+71</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file55"><span id="added">index.html</span></a></tt></td><td align="right" id="added">+46</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<span id="added">jetty_banner.gif</span></tt></td><td colspan="2" align="center"><small id="info">[binary]</small></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td></td><td align="right" id="added">+6426</td><td></td><td></td></tr>
</table>
<small id="info">56 added files</small><br />
<div class="tasklist"><ul>
<li><a href="#task1">TODO: Add support for Instantiators.</a></li>
<li><a href="#task2">TODO: Actually, we want to synch m_server and m_contextMap</a></li>
<li><a href="#task3">TODO: Actually, we want to sync m_server and m_contextMap</a></li>
<li><a href="#task4">TODO: Should this instantiator extend AbstractInstantiator? Would it be nice to use setter injection too? Perhaps create different Instantiators for all possibilities? At least an AvalonSetterInstantiator should be created.</a></li>
<li><a href="#task5">TODO: Should we remove the context? It could be easier for back compatibility in the future. Not sure a Servlet really needs the Avalon context.</a></li>
<li><a href="#task6">TODO: Throw exception?</a></li>
<li><a href="#task7">TODO: Do something useful...</a></li>
<li><a href="#task8">TODO: Verify that this method is really needed, perhaps just as a convenience...</a></li>
</ul></div>
<pre class="comment">
initial import out of the sandbox
</pre>
<hr /><a name="file8" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty/avalon<br /></span>
<div class="fileheader" id="added"><big><b>AvalonJettyContainer.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N AvalonJettyContainer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AvalonJettyContainer.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,266 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.containers.jetty.avalon;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.activity.Startable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfigurationSerializer;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+
+import org.codehaus.spice.jervlet.ContextMonitor;
+import org.codehaus.spice.jervlet.ListenerMonitor;
+import org.codehaus.spice.jervlet.containers.jetty.DefaultJettyContainer;
+import org.codehaus.spice.jervlet.containers.jetty.JettyContainer;
+import org.codehaus.spice.jervlet.containers.jetty.ShieldingJettyContainer;
+
+/**
+ * Avalon component wrapping a Jetty Server
+ *
+ * @author Johan Sjoberg
+ * @dna.component
+ */
+public class AvalonJettyContainer
+ implements LogEnabled, Configurable, Serviceable, Initializable, Startable
+{
+ private Logger m_logger;
+ private JettyContainer m_container;
+
+ /**
+ * Recieve a logger
+ *
+ * @param logger The Avalon <code>Logger</code>
+ * @dna.logger
+ */
+ public void enableLogging( final Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ /**
+ * Configure the class
+ *
+ * @param configuration The Avalon <code>Configuration</code>
+ * @throws ConfigurationException if the configuration was incorrect
+ * @dna.configuration
+ */
+ public void configure( final Configuration configuration ) throws ConfigurationException
+ {
+ m_logger.debug( "Configuring..." );
+ if( configuration.getChild( "shield-jetty" ).getValueAsBoolean( true ) )
+ {
+ final Properties jettyProperties = getJettyProperties( configuration );
+ m_container = new ShieldingJettyContainer();
+ ((ShieldingJettyContainer)m_container).addJettyProperties( jettyProperties );
+ }
+ else
+ {
+ m_container = new DefaultJettyContainer();
+ }
+ m_container.setJettyConfiguration( getJettyConfiguration( configuration ) );
+ }
+
+ /**
+ * Get the Service Manager.
+ *
+ * @param manager The service manager.
+ *
+ * @dna.dependency type="org.codehaus.spice.jervlet.ContextMonitor" optional=true
+ * @dna.dependency type="org.codehaus.spice.jervlet.listenerMonitor" optional=true
+ */
<a name="task1" />+ public void service( final ServiceManager manager ) throws ServiceException //<span class="task">TODO</span>: Add support for Instantiators.
+ {
+ if( manager.hasService( ContextMonitor.class.getName() ) )
+ {
+ final ContextMonitor contextMonitor =
+ (ContextMonitor)manager.lookup( ContextMonitor.class.getName() );
+ if( null == contextMonitor )
+ {
+ m_logger.error( "ContextMonitor was null, leaving it unset." );
+ }
+ m_container.setContextMonitor( contextMonitor );
+ }
+ else
+ {
+ m_logger.info( "Got no ContextMonitor, leaving it unset." );
+ m_container.setContextMonitor( null );
+ }
+
+ if( manager.hasService( ListenerMonitor.class.getName() ) )
+ {
+ final ListenerMonitor listenerMonitor =
+ (ListenerMonitor)manager.lookup( ListenerMonitor.class.getName() );
+ if( null == listenerMonitor )
+ {
+ m_logger.error( "ListenerMonitor was null, leaving it unset." );
+ }
+ m_container.setListenerMonitor( listenerMonitor );
+ }
+ else
+ {
+ m_logger.info( "Got no ListenerMonitor, leaving it unset." );
+ m_container.setListenerMonitor( null );
+ }
+ }
+
+ /**
+ * Initialize the component
+ *
+ * @throws Exception on all errors
+ */
+ public void initialize() throws Exception
+ {
+ m_logger.info( "Initializing..." );
+ m_container.initialize();
+ }
+
+ /**
+ * Start the Jetty container
+ *
+ * @throws Exception on all errors
+ */
+ public void start() throws Exception
+ {
+ m_logger.info( "Starting..." );
+ m_container.start();
+ }
+
+ /**
+ * Stop the Jetty container
+ *
+ * @throws Exception on all errors
+ */
+ public void stop() throws Exception
+ {
+ m_logger.info( "Stopping..." );
+ m_container.stop();
+ }
+
+ /**
+ * Populate a new <code>Properties</code> object with values from
+ * a configuration. The format is:
+ * <br/><br/>
+ * &lt;system-properties&gt;
+ * &lt;property key="the key" value="the value"/&gt;
+ * ...
+ * &lt;/system-properties&gt;
+ * <br/><br/>
+ * If no properties were configured the returned
+ * <code>Properties</code> object will be empty.
+ *
+ * @param configuration Avalon configuration
+ * @return a new <code>Properties</code> object, filled with
+ * given system properties
+ */
+ private Properties getJettyProperties( final Configuration configuration )
+ {
+ final Properties properties = new Properties();
+ final Configuration[] propertyElements =
+ configuration.getChild( "jetty-system-properties" ).getChildren( "property" );
+
+ for( int i = 0; i < propertyElements.length; i++ )
+ {
+ properties.setProperty( propertyElements[i].getAttribute( "key", "" ),
+ propertyElements[i].getAttribute( "value", "" ) );
+ }
+
+ return properties;
+ }
+
+ /**
+ * Create a configuration object to instantiate Jetty with.
+ * <br/></br>
+ * There are four possible return values;
+ * (i) a <code>String</code> representing a Jetty configuration file,
+ * (ii) a <code>String</code> that IS the Jetty configuration,
+ * (iii) a <code>URL</code> pointing at a Jetty configuration and
+ * (iv) null.
+ * Note that no checks about the configuration's correctness are
+ * done here.
+ * <br/></br>
+ * Accepted configuration elements are
+ * <b>jetty-configuration-file</b>,
+ * <b>jetty-configuration</b> and
+ * <b>jetty-configuration-url</b>. Note that the Jetty
+ * configuration always starts with a <b>&lt;Configure&gt;</b>
+ * element.
+ *
+ * @param configuration Avalon configuration
+ * @return <code>String</code>, <code>URL</code> or <code>null</code>
+ */
+ private Object getJettyConfiguration( final Configuration configuration )
+ throws ConfigurationException
+ {
+ String configurationFile = configuration.getChild(
+ "jetty-configuration-file" ).getValue( null );
+ if( null != configurationFile )
+ {
+ configurationFile = configurationFile.replace( '\\', File.separatorChar );
+ configurationFile = configurationFile.replace( '/', File.separatorChar );
+ m_logger.info( "Using Jetty configuration from file [" + configurationFile + "]." );
+ return configurationFile;
+ }
+
+ if( null != configuration.getChild( "jetty-configuration" ).getValue( null ) )
+ {
+ String configurationString;
+ try
+ {
+ final DefaultConfigurationSerializer serializer =
+ new DefaultConfigurationSerializer();
+ configurationString = serializer.serialize(
+ configuration.getChild( "jetty-configuration" ).getChild( "Configure" ) );
+ }
+ catch( Exception e )
+ {
+ final String message = "Serialization of Jetty's configuration failed.";
+ m_logger.error( message, e );
+ throw new ConfigurationException( message, e );
+ }
+ if( configurationString.indexOf( "?>" ) > 0 )
+ {
+ configurationString = configurationString.substring(
+ configurationString.indexOf( "?>" ) + 2 );
+ }
+ m_logger.info( "Using embedded Jetty configuration." );
+ return configurationString;
+ }
+
+ final String urlString = configuration.getChild(
+ "jetty-configuration-url", true ).getValue( null );
+ if( null != urlString )
+ {
+ final URL urlConfiguration;
+ try
+ {
+ urlConfiguration = new URL( urlString );
+ }
+ catch( MalformedURLException mue )
+ {
+ final String message = "Bad Jetty configuration URL.";
+ m_logger.error( message, mue );
+ throw new ConfigurationException( message, mue );
+ }
+ m_logger.info( "Using Jetty configuration from URL ["
+ + urlConfiguration.getPath() + "]." );
+ return urlConfiguration;
+ }
+ return null;
+ }
+}
</pre></div>
<hr /><a name="file9" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader" id="added"><big><b>DefaultJettyContainer.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DefaultJettyContainer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DefaultJettyContainer.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,317 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) 2005 The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.containers.jetty;
+
+import java.net.URL;
+import java.util.List;
+
+import org.codehaus.spice.jervlet.ContextMonitor;
+import org.codehaus.spice.jervlet.ListenerMonitor;
+import org.codehaus.spice.jervlet.ContextHandler;
+import org.codehaus.spice.jervlet.Listener;
+import org.codehaus.spice.jervlet.ListenerException;
+import org.codehaus.spice.jervlet.Context;
+import org.codehaus.spice.jervlet.ContextException;
+import org.codehaus.spice.jervlet.impl.NoopContextMonitor;
+import org.codehaus.spice.jervlet.impl.NoopListenerMonitor;
+import org.mortbay.jetty.Server;
+
+/**
+ * Component representing a plain Jetty container. It wraps a Jetty
+ * <code>Server</code> class through an internal
+ * <code>JettyServer</code> member.
+ *
+ * @author Peter Royal
+ * @author Johan Sjoberg
+ */
+public class DefaultJettyContainer implements JettyContainer
+{
+ /** Context monitor for the underlaying Jetty container */
+ private ContextMonitor m_contextMonitor;
+
+ /** Listener monitor for the underlaying Jetty container */
+ private ListenerMonitor m_listenerMonitor;
+
+ /** Some type of Jetty configuration (can be null) */
+ private Object m_jettyConfiguration;
+
+ /** Underlaying Jetty container */
+ private JettyServer m_jettyServer;
+
+ /** Default and unshielded context handler */
+ private ContextHandler m_defaultContextHandler;
+
+ /**
+ * Create a new DefaultJettyContainer
+ */
+ public DefaultJettyContainer()
+ {
+ m_contextMonitor = new NoopContextMonitor();
+ m_listenerMonitor = new NoopListenerMonitor();
+ }
+
+ /**
+ * Give the component a context monitor. If none is goven, a
+ * <code>NoopContextMonitor</code> will be used.
+ *
+ * @param contextMonitor the context monitor
+ */
+ public void setContextMonitor( final ContextMonitor contextMonitor )
+ {
+ m_contextMonitor = contextMonitor;
+ if( null != m_jettyServer )
+ {
+ m_jettyServer.setContextMonitor( contextMonitor );
+ }
+ }
+
+ /**
+ * Give the component a listener monitor. If none is goven, a
+ * <code>NoopListenerMonitor</code> will be used.
+ *
+ * @param listenerMonitor the listener monitor
+ */
+ public void setListenerMonitor( final ListenerMonitor listenerMonitor )
+ {
+ m_listenerMonitor = listenerMonitor;
+ if( null != m_jettyServer )
+ {
+ m_jettyServer.setListenerMonitor( listenerMonitor );
+ }
+ }
+
+ /**
+ * Give the underlaying Jetty implementation a configuration.
+ * This is only useful before initialization as an empty
+ * jetty <code>Server</code> will be created if no configuration
+ * was available.
+ *
+ * @param configuration The configuration, <code>String</code> or
+ * <code>URL</code>
+ */
+ public void setJettyConfiguration( final Object configuration )
+ {
+ m_jettyConfiguration = configuration;
+ }
+
+ /**
+ * Initialize the component. This implementation is not
+ * operational before <code>initialize</code> has been called.
+ *
+ * @throws Exception on all errors
+ */
+ public void initialize() throws Exception
+ {
+ final Server jettyServer;
+ if( null != m_jettyServer )
+ {
+ if( m_jettyConfiguration instanceof String )
+ {
+ jettyServer = new Server( (String)m_jettyConfiguration );
+ }
+ else if( m_jettyConfiguration instanceof URL )
+ {
+ jettyServer = new Server( (URL)m_jettyConfiguration );
+ }
+ else
+ {
+ throw new Exception(
+ "Unknown configuration type. Only String, URL or null are supported." );
+ }
+ }
+ else
+ {
+ jettyServer = new Server();
+ }
+ m_jettyServer = new JettyServer( jettyServer,
+ m_listenerMonitor,
+ m_contextMonitor );
+ }
+
+ /**
+ * Start the Jetty server.
+ *
+ * @throws Exception on all errors
+ */
+ public void start() throws Exception
+ {
+ if( !m_jettyServer.isServerStarted() )
+ {
+ m_jettyServer.startServer();
+ m_defaultContextHandler = m_jettyServer.createContextHandler();
+ }
+ }
+
+ /**
+ * Stop the Jetty server.
+ *
+ * @throws Exception on all errors
+ */
+ public void stop() throws Exception
+ {
+ if( m_jettyServer.isServerStarted() )
+ {
+ m_jettyServer.stopServer();
+ }
+ }
+
+ /**
+ * Create a new context handler.
+ *
+ * @return A new <code>ContextHandler</code> instance
+ */
+ public ContextHandler createContextHandler()
+ {
+ return m_jettyServer.createContextHandler();
+ }
+
+ /**
+ * Destroy a context handler. If the given context
+ * handler still has contexts, they will be stopped
+ * and removed before destruction.
+ *
+ * @param contextHandler <code>ContextHandler</code> to destroy
+ */
+ public void destroyContextHandler( final ContextHandler contextHandler )
+ {
+ m_jettyServer.destroyContextHandler( contextHandler );
+ }
+
+ /**
+ * Add a <code>Listener</code> the container.
+ *
+ * @param listener the listener to add
+ * @throws ListenerException rethrown from
+ * <code>JettyServler.addListener</code>
+ */
+ public void addListener( final Listener listener ) throws ListenerException
+ {
+ m_jettyServer.addListener( listener );
+ }
+
+ /**
+ * Remove a <code>Listener</code> from the container.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeListener( final Listener listener )
+ {
+ m_jettyServer.removeListener( listener );
+ }
+
+ /**
+ * Start a <code>Listener</code>.
+ *
+ * @param listener the listener to start
+ * @throws ListenerException if the listener couldn't be started
+ */
+ public void startListener( final Listener listener ) throws ListenerException
+ {
+ m_jettyServer.startListener( listener );
+ }
+
+ /**
+ * Stop a <code>Listener</code>.
+ *
+ * @param listener the listener to stop
+ * @throws ListenerException if the listener couldn't be stopped
+ */
+ public void stopListener( final Listener listener ) throws ListenerException
+ {
+ m_jettyServer.stopListener( listener );
+ }
+
+ /**
+ * Fetch a list of all current <code>Listener</code>s. If there
+ * are no listeners the returned list will be empty, but never
+ * null.
+ *
+ * @return a <b>new</b> list containing all current listeners.
+ */
+ public List getListeners()
+ {
+ return m_jettyServer.getListeners();
+ }
+
+ /**
+ * Check if a <code>Listener</code> is started or not.
+ *
+ * @param listener The listener
+ * @return true if the listener is started, else false.
+ */
+ public boolean isStarted( final Listener listener )
+ {
+ return m_jettyServer.isStarted( listener );
+ }
+
+ /**
+ * Add a context to the container.
+ *
+ * @param context The context to add
+ */
+ public void addContext( final Context context )
+ {
+ m_defaultContextHandler.addContext( context );
+ }
+
+ /**
+ * Remove a context from the container.
+ *
+ * @param context The context to remove
+ */
+ public void removeContext( final Context context )
+ {
+ m_defaultContextHandler.removeContext( context );
+ }
+
+ /**
+ * Start a context.
+ *
+ * @param context The context to start
+ * @throws ContextException rethrown from
+ * <code>ContextHandler.startContext</code>
+ */
+ public void startContext( final Context context ) throws ContextException
+ {
+ m_defaultContextHandler.startContext( context );
+ }
+
+ /**
+ * Stop a context.
+ *
+ * @param context The context to stop
+ * @throws ContextException if the context couldn't be stopped
+ */
+ public void stopContext( final Context context ) throws ContextException
+ {
+ m_defaultContextHandler.startContext( context );
+ }
+
+ /**
+ * List the <code>Context</code>s that this <code>ContextHandler</code>
+ * can manage.
+ *
+ * @return a new list of contexts holding all JervletContexts
+ */
+ public List getContexts()
+ {
+ return m_defaultContextHandler.getContexts();
+ }
+
+ /**
+ * Check if <code>Context</context> owned by this handler
+ * is started on not.
+ *
+ * @param context The context to check
+ * @return true if the given context is started, else false
+ */
+ public boolean isStarted( final Context context )
+ {
+ return m_defaultContextHandler.isStarted( context );
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file10" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader" id="added"><big><b>JettyContainer.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N JettyContainer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ JettyContainer.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,68 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) 2005 The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.containers.jetty;
+
+import org.codehaus.spice.jervlet.Container;
+import org.codehaus.spice.jervlet.ContextHandler;
+import org.codehaus.spice.jervlet.ListenerHandler;
+import org.codehaus.spice.jervlet.ContextMonitor;
+import org.codehaus.spice.jervlet.ListenerMonitor;
+
+/**
+ * Interface common for Jetty servlet containers
+ *
+ * @author Peter Royal
+ * @author Johan Sjoberg
+ */
+public interface JettyContainer extends Container, ContextHandler, ListenerHandler
+{
+ /**
+ * Initialize the Jetty container
+ *
+ * @throws Exception on all errors, most probably a IOException,
+ * rethrown from the creation of Jetty's Server.
+ */
+ void initialize() throws Exception;
+
+ /**
+ * Start the Jetty container
+ *
+ * @throws Exception on all errors
+ */
+ void start() throws Exception;
+
+ /**
+ * Stop the container
+ *
+ * @throws Exception on all errors
+ */
+ void stop() throws Exception;
+
+ /**
+ * Set configuration for the Jetty <code>Server</code>. The
+ * underlaying Jetty server will be created with this
+ * configuration.
+ *
+ * @param configuration the configuration to pass to Jetty
+ */
+ void setJettyConfiguration( Object configuration );
+
+ /**
+ * Set a context monitor
+ *
+ * @param contextMonitor a context monitor.
+ */
+ void setContextMonitor( ContextMonitor contextMonitor );
+
+ /**
+ * Set the context monitor
+ *
+ * @param listenerMonitor a context monitor
+ */
+ void setListenerMonitor( ListenerMonitor listenerMonitor );
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file11" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader" id="added"><big><b>JettyContextHandler.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N JettyContextHandler.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ JettyContextHandler.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,293 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.containers.jetty;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.codehaus.spice.jervlet.Context;
+import org.codehaus.spice.jervlet.ContextException;
+import org.codehaus.spice.jervlet.ContextHandler;
+import org.codehaus.spice.jervlet.ContextMonitor;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.WebApplicationContext;
+
+/**
+ * Contex hander for a Jetty container. The context handler is really
+ * the heart of the Jetty implementation. It is responsible for
+ * adding, removing, starting and stopping web contexts
+ * (web applications). A JettyContextHandler is always linked to a
+ * JettyServer.
+ *
+ * @author Johan Sjoberg
+ */
+public class JettyContextHandler implements ContextHandler
+{
+ /** Jetty server */
+ private Server m_server;
+ /** Context monitor to send monitor events to */
+ private ContextMonitor m_contextMonitor;
+ /** Map of current contexts */
+ private HashMap m_contextMap = new HashMap();
+
+ /**
+ * Create a new <code>ContextHandler</code> for Jetty servers.
+ *
+ * @param server the Jetty server
+ * @param contextMonitor a context monitor
+ * @throws IllegalArgumentException if an argument was null
+ */
+ public JettyContextHandler( Server server, ContextMonitor contextMonitor )
+ {
+ if( null == server )
+ {
+ throw new IllegalArgumentException(
+ "Server given to constructor was null." );
+ }
+ if( null == contextMonitor )
+ {
+ throw new IllegalArgumentException(
+ "ContextMonitor given to constructor was null." );
+ }
+ m_server = server;
+ m_contextMonitor = contextMonitor;
+ }
+
+ /**
+ * Add a context to the container.
+ * <br/><br/>
+ * This is done by creating a new <code>WebApplicationContext</code>
+ * and giving it a special handler that uses the
+ * <code>Instantiator</code> from the given <code>Context</code>
+ * to create new Servlet or Filter class instances.
+ *
+ * @param context The context to add
+ * @throws IllegalArgumentException if the given context was bad
+ */
+ public void addContext( Context context )
+ {
+ verifyContext( context );
+
+ WebApplicationContext webApplicationContext =
+ new WebApplicationContext( context.getResource().getPath() );
+ webApplicationContext.addHandler( 0,
+ new JettyWebApplicationHandler( context.getInstantiator() ) );
+ webApplicationContext.setContextPath( context.getPath() );
+ webApplicationContext.setExtractWAR( context.extractWebArchive() );
+
+ if( null != context.getVirtualHosts() )
+ {
+ webApplicationContext.setVirtualHosts( context.getVirtualHosts() );
+ }
<a name="task2" />+ synchronized( this ) //<span class="task">TODO</span>: Actually, we want to synch m_server and m_contextMap
+ {
+ if( !isLegalContext( context ) )
+ {
+ m_contextMap.put( context, webApplicationContext );
+ m_server.addContext( webApplicationContext );
+ }
+ }
+ m_contextMonitor.addContextNotification( this.getClass(), context );
+ }
+
+ /**
+ * Remove a context from the container.
+ *
+ * @param context The context to remove.
+ */
+ public void removeContext( Context context )
+ {
+ if( isLegalContext( context ) )
+ {
+ final WebApplicationContext webApplicationContext;
<a name="task3" />+ synchronized( this ) //<span class="task">TODO</span>: Actually, we want to sync m_server and m_contextMap
+ {
+ try
+ {
+ stopContext( context );
+ }
+ catch( ContextException ce )
+ {
+ final String message =
+ "Context didn't stop cleanely. Message was [" + ce.getMessage() + "].";
+ m_contextMonitor.removeContextWarning( this.getClass(), context, message );
+ }
+ webApplicationContext =
+ (WebApplicationContext)m_contextMap.get( context );
+ m_server.removeContext( webApplicationContext );
+ m_contextMap.remove( context );
+ }
+ webApplicationContext.destroy();
+ m_contextMonitor.removeContextNotification( this.getClass(), context );
+ }
+ }
+
+ /**
+ * List the <code>Context</code>s that this
+ * <code>ContextHandler</code> currently manages.
+ *
+ * @return A new list of contexts holding all JervletContexts
+ */
+ public List getContexts()
+ {
+ ArrayList contextList = new ArrayList( m_contextMap.values() );
+ return (List)contextList;
+ }
+
+ /**
+ * Start a context.
+ *
+ * @param context The context to start.
+ */
+ public void startContext( Context context ) throws ContextException
+ {
+ if( isLegalContext( context ) )
+ {
+ WebApplicationContext webApplicationContext =
+ getWebApplicationContext( context );
+ if( !webApplicationContext.isStarted() )
+ {
+ try
+ {
+ webApplicationContext.start();
+ m_contextMonitor.startContextNotification( this.getClass(), context );
+ }
+ catch( Exception e )
+ {
+ m_contextMonitor.startContextException( this.getClass(), context, e );
+ }
+ }
+ }
+ }
+
+ /**
+ * Stop a context
+ *
+ * @param context The context to stop.
+ */
+ public void stopContext( Context context ) throws ContextException
+ {
+ if( isLegalContext( context ) )
+ {
+ WebApplicationContext webApplicationContext =
+ getWebApplicationContext( context );
+ if( webApplicationContext.isStarted() )
+ {
+ try
+ {
+ webApplicationContext.stop();
+ m_contextMonitor.stopContextNotification( this.getClass(), context );
+ }
+ catch( InterruptedException ie )
+ {
+ m_contextMonitor.stopContextException( this.getClass(), context, ie );
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if <code>Context</context> owned by this handler
+ * is started on not.
+ *
+ * @param context The context to check
+ * @return true if the given context is owned by this context
+ * handler and started, else false
+ */
+ public boolean isStarted( Context context )
+ {
+ if( isLegalContext( context ) )
+ {
+ WebApplicationContext webApplicationContext =
+ getWebApplicationContext( context );
+ return webApplicationContext.isStarted();
+ }
+ return false;
+ }
+
+ /**
+ * Check if a context belongs to this <code>ContextHandler</code>
+ *
+ * @return true if the context is legal for this ContextHandler
+ */
+ private boolean isLegalContext( Context context )
+ {
+ if( null == context )
+ {
+ return false;
+ }
+ return m_contextMap.containsKey( context );
+ }
+
+ /**
+ * Fetch a Jetty <code>WebApplicationContext</code> representing
+ * a Jervlet <code>Context</code>.
+ *
+ * @param context The Context
+ * @return The WebApplicationContext for the given Context or null.
+ */
+ private WebApplicationContext getWebApplicationContext( Context context )
+ {
+ if( isLegalContext( context ) )
+ {
+ WebApplicationContext webApplicationContext =
+ (WebApplicationContext)m_contextMap.get( context );
+ return webApplicationContext;
+ }
+ return null;
+ }
+
+ /**
+ * Destroy this ContextHandler. Before destruction all
+ * deployed Contexts are undeployed.
+ */
+ protected void destroy()
+ {
+ synchronized( this )
+ {
+ List contexts = getContexts();
+ for( int i = 0; i < contexts.size(); i++ )
+ {
+ removeContext( (Context)contexts.get( i ) );
+ }
+ m_server = null;
+ m_contextMonitor = null;
+ m_contextMap = null;
+ }
+ }
+
+ /**
+ * Verify a context
+ * <br/><br/>
+ * If the context's instantiator, path or resource is
+ * <code>null</code>, an <code>IllegalArgumentException</code>
+ * is thrown with proper message.
+ *
+ * @param context The context to verify
+ * @throws IllegalArgumentException if something is wrong with the context.
+ */
+ private void verifyContext( Context context )
+ {
+ if( null == context.getInstantiator() )
+ {
+ final String message = "The context's Instantiator was null.";
+ throw new IllegalArgumentException( message );
+ }
+ if( null == context.getPath() )
+ {
+ final String message = "The context's Path was null.";
+ throw new IllegalArgumentException( message );
+ }
+ if( null == context.getResource() )
+ {
+ final String message = "The context's Resource was null.";
+ throw new IllegalArgumentException( message );
+ }
+ }
+}
</pre></div>
<hr /><a name="file12" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader" id="added"><big><b>JettyFilterHolder.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N JettyFilterHolder.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ JettyFilterHolder.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,105 @@
</small></pre><pre class="diff" id="added">+/*
+
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, 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 "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
+ must not be used to endorse or promote products derived from this software
+ without prior written permission. For written permission, please contact
+ [email protected]
+
+ 5. Products derived from this software may not be called "Apache", 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 (INCLU-
+ DING, 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.codehaus.spice.jervlet.containers.jetty;
+
+import org.mortbay.jetty.servlet.FilterHolder;
+import org.mortbay.jetty.servlet.WebApplicationHandler;
+
+import org.codehaus.spice.jervlet.Instantiator;
+
+/**
+ * Override for Jetty's FilterHolder allow custom
+ * filter handling.
+ *
+ * @author Paul Hammant
+ * @author Peter Royal
+ * @author Johan Sjoberg
+ */
+public class JettyFilterHolder extends FilterHolder
+{
+ private Instantiator m_instantiator;
+
+ /**
+ * Construct a Filter Holder
+ *
+ * @param instantiator Instantiator for Servlet classes
+ * @param handler the handler
+ * @param name the name
+ * @param className the class name
+ */
+ public JettyFilterHolder( Instantiator instantiator,
+ WebApplicationHandler handler,
+ String name,
+ String className )
+ {
+ super( handler, name, className );
+ m_instantiator = instantiator;
+ }
+
+ /**
+ * Create a new instance of a Filter class.
+ *
+ * @return The new instance
+ * @throws InstantiationException If the class was null
+ * @throws IllegalAccessException If the class couldn't be accessed
+ */
+ public synchronized Object newInstance()
+ throws InstantiationException, IllegalAccessException
+ {
+ if( null == _class )
+ {
+ throw new InstantiationException( "No class for " + this );
+ }
+ else
+ {
+ return m_instantiator.instantiate( _class );
+ }
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file13" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader" id="added"><big><b>JettyServer.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N JettyServer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ JettyServer.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,465 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.containers.jetty;
+
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Collections;
+
+import org.codehaus.spice.jervlet.Container;
+import org.codehaus.spice.jervlet.ContextHandler;
+import org.codehaus.spice.jervlet.ContextMonitor;
+import org.codehaus.spice.jervlet.Listener;
+import org.codehaus.spice.jervlet.ListenerException;
+import org.codehaus.spice.jervlet.ListenerHandler;
+import org.codehaus.spice.jervlet.ListenerMonitor;
+import org.codehaus.spice.jervlet.impl.NoopListenerMonitor;
+import org.codehaus.spice.jervlet.impl.NoopContextMonitor;
+import org.codehaus.spice.jervlet.impl.DefaultListener;
+import org.mortbay.http.HttpListener;
+import org.mortbay.http.SocketListener;
+import org.mortbay.http.SunJsseListener;
+import org.mortbay.http.ajp.AJP13Listener;
+import org.mortbay.jetty.Server;
+
+/**
+ * Starting point for a Jetty server.
+ * <br/><br/>
+ * The <code>ListenerHandler</code> contract can be very limited in
+ * many situations. Some functions of the Jetty server can be
+ * parametrized through System parameters, but for most cases where
+ * more advanced setups are needed it is best to feed the Constructor
+ * an already configurated Jetty Server and use this class for
+ * deploying web applications. Note, this class is not intended
+ * to be used as a component, but rather be used as a tool by
+ * compnents.
+ */
+public class JettyServer implements Container, ListenerHandler
+{
+ /** The Jetty Server */
+ private Server m_server;
+
+ /** List of ContextHandlers given out */
+ private final ArrayList m_contextHandlers;
+
+ /** Listener monitor */
+ private ListenerMonitor m_listenerMonitor;
+
+ /** Context monitor */
+ private ContextMonitor m_contextMonitor;
+
+ /** Warning message, about null Listeners */
+ private final static String NULL_LISTENER = "Given Listener was null.";
+
+ /**
+ * Create a new JettyServer instance
+ * <br/><br/>
+ * Note that calls to setServer, setListenerMonitor and
+ * setContextMonitor are needed if this constructor is used. The
+ * newly created instance will NOT work if all listed methods
+ * aren't correctly called.
+ */
+ public JettyServer()
+ {
+ m_contextHandlers = new ArrayList();
+ }
+
+ /**
+ * Set up a JettyServer instance.
+ *
+ * @param jettyServer a jetty Server instance, or null. If
+ * <code>null</code> is given a new unconfigured intance
+ * will be created.
+ * @param listenerMonitor A listener monitor instance
+ * @param contextMonitor A context monitor instance
+ */
+ public JettyServer( final Server jettyServer,
+ final ListenerMonitor listenerMonitor,
+ final ContextMonitor contextMonitor )
+ {
+ this();
+ setListenerMonitor( listenerMonitor );
+ setContextMonitor( contextMonitor );
+ setServer( jettyServer );
+ }
+
+ /**
+ * Set the Jetty server. It can only be set once. Still a server
+ * must be set before the class will work, either in the
+ * constructor or here. <code>null</code> is an accepted value,
+ * and if given a new empty Server an unconfigured instance will
+ * be created.
+ *
+ * @param jettyServer a jetty Server instance, or null. If
+ * <code>null</code> is given a new unconfigured intance
+ * will be created.
+ */
+ public void setServer( final Server jettyServer )
+ {
+ if( null == m_server )
+ {
+ if( null == jettyServer )
+ {
+ m_server = new Server();
+ }
+ else
+ {
+ m_server = jettyServer;
+ }
+ }
+ }
+
+ /**
+ * Set the context monitor. A context monitor must be set before
+ * the class will work, and can be set anytime again while the
+ * system is running.
+ *
+ * @param contextMonitor the context monitor, or null for NoOp
+ */
+ public void setContextMonitor( final ContextMonitor contextMonitor )
+ {
+ if( null == m_contextMonitor )
+ {
+ m_contextMonitor = new NoopContextMonitor();
+ }
+ else
+ {
+ m_contextMonitor = contextMonitor;
+ }
+ }
+
+ /**
+ * Set the listener monitor. A listener monitor must be set
+ * before the class will work, and can be set anytime again while
+ * the system is running.
+ *
+ * @param listenerMonitor the listener monitor, or null for NoOp
+ */
+ public void setListenerMonitor( final ListenerMonitor listenerMonitor )
+ {
+ if( null == m_listenerMonitor )
+ {
+ m_listenerMonitor = new NoopListenerMonitor();
+ }
+ else
+ {
+ m_listenerMonitor = listenerMonitor;
+ }
+ }
+
+ /**
+ * Start the server
+ *
+ * @throws Exception if Jetty's <code>Server</code> threw one
+ */
+ public void startServer() throws Exception
+ {
+ m_server.start();
+ }
+
+ /**
+ * Stop the server
+ *
+ * @throws InterruptedException if Jetty's server threw one
+ */
+ public void stopServer() throws InterruptedException
+ {
+ m_server.stop();
+ }
+
+ /**
+ * Check if the server is started
+ *
+ * @return true if the server is started, else false
+ */
+ public boolean isServerStarted()
+ {
+ if( null == m_server )
+ {
+ return false;
+ }
+ else
+ {
+ return m_server.isStarted();
+ }
+ }
+
+ /**
+ * Create a new context handler.
+ *
+ * @return A new ContextHandler.
+ */
+ public ContextHandler createContextHandler()
+ {
+ final JettyContextHandler contextHandler =
+ new JettyContextHandler( m_server, m_contextMonitor );
+ m_contextHandlers.add( contextHandler );
+ return contextHandler;
+ }
+
+ /**
+ * Destroy a context handler. If the given context handler still
+ * has contexts, they will be stopped and removed before
+ * destruction.
+ *
+ * @param contextHandler the ContextHandler to destroy
+ */
+ public void destroyContextHandler( final ContextHandler contextHandler )
+ {
+ if( null == contextHandler ||
+ !m_contextHandlers.contains( contextHandler ) )
+ {
+ return;
+ }
+ ( (JettyContextHandler)contextHandler ).destroy();
+ m_contextHandlers.remove( contextHandler );
+ }
+
+ /**
+ * Add a <code>Listener</code> the container.
+ *
+ * @param listener the Listener to add
+ * @throws ListenerException if the listener couldn't be added
+ * (the host was unknown)
+ */
+ public void addListener( final Listener listener ) throws ListenerException
+ {
+ final HttpListener httpListener = createHttpListener( listener );
+ try
+ {
+ httpListener.setHost( listener.getHost() );
+ }
+ catch( UnknownHostException ue )
+ {
+ m_listenerMonitor.addListenerException( getClass(), listener, ue );
+ }
+ httpListener.setHttpServer( m_server );
+ httpListener.setPort( listener.getPort() );
+ m_server.addListener( httpListener );
+ m_listenerMonitor.addListenerNotification( getClass(), listener );
+ }
+
+ /**
+ * Create a new Jetty <code>HttpListener</code>
+ *
+ * @param listener the listener to get information from
+ * @return a new Jetty HTTP listener
+ * @throws IllegalArgumentException if the listner type was
+ * unknown (not AJP13, HTTP or TSL)
+ */
+ private static HttpListener createHttpListener( final Listener listener )
+ {
+ switch( listener.getType() )
+ {
+ case Listener.AJP13: return new AJP13Listener();
+ case Listener.HTTP: return new SocketListener();
+ case Listener.TSL: return new SunJsseListener();
+ default:
+ throw new IllegalArgumentException( "Unknown listener type: "
+ + listener.getType() );
+ }
+ }
+
+ /**
+ * Remove a <code>Listener</code> from the container.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeListener( final Listener listener )
+ {
+ if( null == listener )
+ {
+ m_listenerMonitor.removeListenerWarning( getClass(),
+ listener,
+ NULL_LISTENER );
+ }
+ else
+ {
+ final HttpListener[] listeners = m_server.getListeners();
+ if( null != listeners && listeners.length > 0 )
+ {
+ for( int i = 0; i < listeners.length; i++ )
+ {
+ if( listener.getPort() == listeners[i].getPort() &&
+ listener.getHost().equals( listeners[i].getHost() ) )
+ {
+ m_server.removeListener( listeners[i] );
+ }
+ }
+ m_listenerMonitor.removeListenerNotification( getClass(), listener );
+ }
+ }
+ }
+
+ /**
+ * Start a <code>Listener</code>
+ *
+ * @param listener the listener to start
+ */
+ public void startListener( final Listener listener ) throws ListenerException
+ {
+ final HttpListener httpListener = getHttpListener( listener );
+ if( null == httpListener )
+ {
+ m_listenerMonitor.startListenerWarning( getClass(),
+ listener,
+ NULL_LISTENER );
+ }
+ else if( !httpListener.isStarted() )
+ {
+ try
+ {
+ httpListener.start();
+ m_listenerMonitor.startListenerNotification( getClass(), listener );
+ }
+ catch( Exception e )
+ {
+ m_listenerMonitor.startListenerException( getClass(), listener, e );
+ }
+ }
+ else
+ {
+ m_listenerMonitor.startListenerWarning( getClass(), listener,
+ "Given Listener was already started." );
+ }
+ }
+
+ /**
+ * Stop a <code>Listener</code>.
+ *
+ * @param listener the listener to stop
+ * @throws ListenerException if the listener couldn't be stopped
+ */
+ public void stopListener( final Listener listener ) throws ListenerException
+ {
+ final HttpListener httpListener = getHttpListener( listener );
+ if( null == httpListener )
+ {
+ m_listenerMonitor.stopListenerWarning( getClass(),
+ listener,
+ NULL_LISTENER );
+ }
+ else if( httpListener.isStarted() )
+ {
+ try
+ {
+ httpListener.stop();
+ m_listenerMonitor.stopListenerNotification( getClass(), listener );
+ }
+ catch( Exception e )
+ {
+ m_listenerMonitor.stopListenerException( getClass(), listener, e );
+ }
+ }
+ else
+ {
+ m_listenerMonitor.stopListenerWarning( getClass(), listener,
+ "Given Listener was not started." );
+ }
+ }
+
+ /**
+ * Fetch a list of all current <code>Listener</code>s. If there
+ * are no listener the returned list can be empty.
+ *
+ * @return All new list all current listeners.
+ */
+ public List getListeners()
+ {
+ final HttpListener[] listeners = m_server.getListeners();
+ if( null == listeners || 0 == listeners.length )
+ {
+ return Collections.EMPTY_LIST;
+ }
+ else
+ {
+ final ArrayList listenerList = new ArrayList();
+ for( int i = 0; i < listeners.length; i++ )
+ {
+ listenerList.add( createListener( listeners[i] ) );
+ }
+ return listenerList;
+ }
+ }
+
+ /**
+ * Check if a listener is started or not.
+ *
+ * @param listener The Listener to check
+ *
+ * @return true if the listener was handles by this container
+ * and started, else false.
+ */
+ public boolean isStarted( final Listener listener )
+ {
+ final HttpListener httpListener = getHttpListener( listener );
+ if( null == httpListener )
+ {
+ return false;
+ }
+ return httpListener.isStarted();
+ }
+
+ /**
+ * Fetch a Jetty <code>HttpListener</code> represented by a
+ * Jervlet <code>Listener</code>.
+ *
+ * @param listener A listener
+ *
+ * @return The corresponding Jervlet HttpListener, or null
+ */
+ private HttpListener getHttpListener( final Listener listener )
+ {
+ if( null != listener )
+ {
+ final HttpListener[] listeners = m_server.getListeners();
+
+ if( null != listeners && listeners.length != 0 )
+ {
+ for( int i = 0; i < listeners.length; i++ )
+ {
+ if( listener.getPort() == listeners[i].getPort() &&
+ listener.getHost().equals( listeners[i].getHost() ) )
+ {
+ return listeners[i];
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Create a new Listener representing the given HttpListener. A
+ * new instance of a DefaultListener will be created.
+ *
+ * @param httpListener The Jetty HttpListener
+ *
+ * @return a new DefaultListener instance.
+ */
+ private Listener createListener( final HttpListener httpListener )
+ {
+ int type = -1;
+ if( httpListener instanceof AJP13Listener )
+ {
+ type = Listener.AJP13;
+ }
+ else if( httpListener instanceof SunJsseListener )
+ {
+ type = Listener.TSL;
+ }
+ else if( httpListener instanceof SocketListener )
+ {
+ type = Listener.HTTP;
+ }
+ return new DefaultListener( httpListener.getHost(),
+ httpListener.getPort(),
+ type );
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file14" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader" id="added"><big><b>JettyServletHolder.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N JettyServletHolder.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ JettyServletHolder.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,106 @@
</small></pre><pre class="diff" id="added">+/*
+
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, 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 "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
+ must not be used to endorse or promote products derived from this software
+ without prior written permission. For written permission, please contact
+ [email protected]
+
+ 5. Products derived from this software may not be called "Apache", 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 (INCLU-
+ DING, 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.codehaus.spice.jervlet.containers.jetty;
+
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.servlet.WebApplicationHandler;
+
+import org.codehaus.spice.jervlet.Instantiator;
+
+/**
+ * Override for Jetty's ServletHolder to allow custom servlet
+ * handling.
+ *
+ * @author Paul Hammant
+ * @author Johan Sjoberg
+ */
+public class JettyServletHolder extends ServletHolder
+{
+ private Instantiator m_instantiator;
+
+ /**
+ * Construct a Servlet Holder
+ *
+ * @param instantiator Instantiator for Servlet classes
+ * @param handler the handler
+ * @param name the name
+ * @param className the class name
+ * @param forcedPath the forced path
+ */
+ public JettyServletHolder( Instantiator instantiator,
+ WebApplicationHandler handler,
+ String name,
+ String className,
+ String forcedPath )
+ {
+ super( handler, name, className, forcedPath );
+ m_instantiator = instantiator;
+ }
+
+ /**
+ * Create a new instance of a Servlet class.
+ *
+ * @return The new instance
+ * @throws InstantiationException If the class was null
+ * @throws IllegalAccessException If the class couldn't be accessed
+ */
+ public synchronized Object newInstance()
+ throws InstantiationException, IllegalAccessException
+ {
+ if( null == _class )
+ {
+ throw new InstantiationException( "No class for " + this );
+ }
+ else
+ {
+ return m_instantiator.instantiate( _class );
+ }
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file15" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader" id="added"><big><b>JettyWebApplicationHandler.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N JettyWebApplicationHandler.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ JettyWebApplicationHandler.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,147 @@
</small></pre><pre class="diff" id="added">+/*
+
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, 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 "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
+ must not be used to endorse or promote products derived from this software
+ without prior written permission. For written permission, please contact
+ [email protected]
+
+ 5. Products derived from this software may not be called "Apache", 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 (INCLU-
+ DING, 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/>.
+
+*/
+
+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.containers.jetty;
+
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.servlet.WebApplicationHandler;
+import org.mortbay.jetty.servlet.FilterHolder;
+
+import org.codehaus.spice.jervlet.Instantiator;
+
+/**
+ * Override for Jetty's WebApplicationHandler to allow custom Servlet
+ * and Filter handling
+ *
+ * @author Paul Hammant
+ * @author Johan Sjoberg
+ * @author Peter Royal
+ */
+public class JettyWebApplicationHandler extends WebApplicationHandler
+{
+ /** Instantiator used to instantiate Servlets and Filters */
+ private Instantiator m_instantiator;
+
+ /**
+ * Create a new WebApplicationHandler for Jetty
+ *
+ * @param instantiator The instiator to create new classes with
+ */
+ public JettyWebApplicationHandler( Instantiator instantiator )
+ {
+ m_instantiator = instantiator;
+ }
+
+ /**
+ * Override Jettys <code>newServletHolder</code> method with our
+ * own. A new <code>JervletServletHodler</code> will be created
+ * and returned. The <code>JervletServletHodler</code> is created
+ * with the <code>Instantiator</code> given to this class in its
+ * constructor.
+ *
+ * @param name Name of the servlet
+ * @param servletClassName Class name, e.g.
+ * com.biz.project.impl.MyServlet
+ * @param forcedPath Web path for the servlet
+ * @return A new ServletHolder creating the Servlet with a given
+ * Instantiator
+ */
+ public ServletHolder newServletHolder( String name,
+ String servletClassName,
+ String forcedPath )
+ {
+ if( _nameMap.containsKey( name ) )
+ {
+ throw new IllegalArgumentException( "Name already exists: " + name );
+ }
+ else
+ {
+ ServletHolder holder = new JettyServletHolder(
+ m_instantiator, this, name, servletClassName, forcedPath );
+ _nameMap.put( holder.getName(), holder );
+ return holder;
+ }
+ }
+
+ /**
+ * Override Jettys <code>newFilterHolder</code> method with our
+ * own. A new <code>JervletFilterHodler</code> will be created
+ * and returned. The <code>JervletFilterHodler</code> is created
+ * with the <code>Instantiator</code> given to this class in its
+ * constructor.
+ *
+ * @param name Name of the servlet
+ * @param filterClassName Class name, e.g.
+ * com.biz.project.impl.MyServlet
+ * @return A new FilterHolder creating the Filter with a given
+ * Instantiator
+ */
+ public FilterHolder newFilterHolder( String name, String filterClassName )
+ {
+ if( _nameMap.containsKey( name ) )
+ {
+ throw new IllegalArgumentException( "Name already exists: " + name );
+ }
+ else
+ {
+ FilterHolder holder = new JettyFilterHolder(
+ m_instantiator, this, name, filterClassName );
+ _nameMap.put( holder.getName(), holder );
+ return holder;
+ }
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file16" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader" id="added"><big><b>ShieldingJettyContainer.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ShieldingJettyContainer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ShieldingJettyContainer.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,525 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.containers.jetty;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.codehaus.spice.jervlet.Context;
+import org.codehaus.spice.jervlet.ContextException;
+import org.codehaus.spice.jervlet.ContextHandler;
+import org.codehaus.spice.jervlet.Listener;
+import org.codehaus.spice.jervlet.ListenerException;
+import org.codehaus.spice.jervlet.tools.isolate.SysPropertiesRedirector;
+
+/**
+ * Component representing a Jetty server.
+ * <br/><br/>
+ * Use this component to run, or as base for a Jetty server. You can
+ * configure the server with a Jetty configuration, path to a Jetty
+ * configuration or with an URL. This component can also let you set
+ * system properties affecting <b>only this</b> instance of Jetty.
+ * This means no real system properties are used, but Jetty will
+ * believe so. Some of Jettys low level behavior can only be changed
+ * like this. If you need to configure the Jetty Server with the
+ * default configuration, you will probably want to at least set
+ * <code>jetty.home</code> and such parameters. It is highly
+ * recommended to use this as the starting point for a Jetty server.
+ * Shielding the implementation is important in a component based
+ * environment.
+ * <br/><br/>
+ * Following is a list of possible parameters Jetty can use. These
+ * were copied from Jetty's website and might be outdated or not
+ * affect the version of Jetty you run.
+ * <br/><br/>
+ * <font size="-1">
+ * <table border="1" cellspacing="0" cellpadding="0">
+ * <tr><th>Property Name</th><th>Default Value</th><th>Description</th></tr>
+ * <tr><td colspan=3><b>JRE Properties</b></td></tr>
+ * <tr><td>java.version</td><td>No default</td><td>JRE version</td></tr>
+ * <tr><td>java.io.tmpdir</td><td>Platform dependent</td><td>Default temporary file path</td></tr>
+ * <tr><td>line.separator</td><td>Platform dependent</td><td>Line separator ("/n" on *nix)</td></tr>
+ * <tr><td>os.arch</td><td>Platform dependent</td><td>Operating system architecture</td></tr>
+ * <tr><td>os.name</td><td>Platform dependent</td><td>Name of the operating system</td></tr>
+ * <tr><td>os.version</td><td>Platform dependent</td><td>Version of the operating system</td></tr>
+ * <tr><td>user.home</td><td>Platform dependent</td><td>User's home directory</td></tr>
+ * <tr><td colspan=3><b>Jetty Properties</b></td></tr>
+ * <tr><td>jetty.class.path</td><td>Not set</td><td>Adds extra class directories or jars onto the system classpath at startup</td></tr>
+ * <tr><td>jetty.home</td><td>Determined at runtime</td><td>Path of the Jetty installation. The start.jar startup method uses an algorithm to search for this location unless this property has been set on the command line</td></tr>
+ * <tr><td>jetty.ssl.keystore</td><td></td><td>See Jetty's FAQ entry on SSL for more info.</td></tr>
+ * <tr><td>jetty.ssl.keystore.provider.class</td><td></td><td>See Jetty's FAQ entry on SSL for more info.</td></tr>
+ * <tr><td>jetty.ssl.keystore.provider.name</td><td></td><td>See Jetty's FAQ entry on SSL for more info.</td></tr>
+ * <tr><td>jetty.ssl.keystore.type</td><td></td><td>See Jetty's FAQ entry on SSL for more info.</td></tr>
+ * <tr><td>jetty.ssl.keypassword</td><td></td><td>See Jetty's FAQ entry on SSL for more info.</td></tr>
+ * <tr><td>jetty.ssl.password</td><td></td><td>See Jetty's FAQ entry on SSL for more info.</td></tr>
+ * <tr><td>org.mortbay.http.HttpRequest.maxFormContentSize</td><td>200000</td><td>Limits the size of the data a client can push at the server</td></tr>
+ * <tr><td>org.mortbay.http.PathMap.separators</td><td>:,</td><td>Separators used to specify multiple paths as a single string.<td></tr>
+ * <tr><td>org.mortbay.http.Version.paranoid</td><td>false</td><td>If <code>true</code>, suppresses the Jetty version information in the response's HTTP headers</td></tr>
+ * <tr><td>org.mortbay.jetty.servlet.SessionCookie</td><td>JSESSIONID</td><td>Name of cookie used for sessions</td></tr>
+ * <tr><td>org.mortbay.jetty.servlet.SessionURL</td><td>jsessionid</td><td>Name of parameter when using URL rewriting for sessions</td></tr>
+ * <tr><td>org.mortbay.util.ByteArrayPool.pool_size</td><td>8</td><td>Size of pool for recycling byte arrays.</td></tr>
+ * <tr><td>org.mortbay.util.FileResource.checkAliases</td><td>true</td><td>If set to <code>false</code>, Jetty will allow requests for files that involve symbolic links or aliases</td></tr>
+ * <tr><td>org.mortbay.util.TypeUtil.IntegerCacheSize</td><td>600</td><td>Size of cache for converting int and String to Integer</td></tr>
+ * <tr><td>org.mortbay.util.URI.charset</td><td>UTF-8</td><td>Character encoding of URLs</td></tr>
+ * <tr><td>org.mortbay.xml.XmlParser.NotValidating</td><td>false</td><td>If true, validation is <strong>not</strong> performed on the web.xml file</td></tr>
+ * <tr><td>start.class</td><td></td><td>Specifies the name of the class of the Jetty server to invoke by the start.jar mechanism, overriding the default. For standard Jetty the default is org.mortbay.jetty.Server, for JettyPlus it is org.mortbay.jetty.plus.Server. Defaults are specified in a start.config file.</td></tr>
+ * <tr><td>JETTY_NO_SHUTDOWN_HOOK</td><td>false</td><td>If false, a shutdown hook thread is registered with the runtime to stop the server when the runtime is shutdown</td></tr>
+ * <tr><td>POOL_MAX</td><td>256</td><td>Used by the utility class org.mortbay.util.Pool to determine the default max number of items in the pool. Can be overridden by calling setMaxSize(int i). The org.mortbay.util.ThreadPool class uses Pool internally, thus this property can be used to effect the default size of the ThreadPool for servicing requests.</td></tr>
+ * <tr><td>POOL_MIN</td><td>2</td><td>Used by the utility class org.mortbay.util.Pool to determine the minimum number of items in the pool. Can be overriden by calling setMinSize (int i). The org.mortbay.util.ThreadPool class uses Pool internally, thus this property can be used to effect the default minimum size of the ThreadPool for servicing requests.</td></tr>
+ * <tr><td>ROLLOVERFILE_BACKUP_FORMAT</td><td>HHmmssSSS</td><td>Format for the date string that is appended to files during rollover.</td></tr>
+ * <tr><td>ROLLOVERFILE_RETAIN_DAYS</td><td>31</td><td>Number of days before old request log files will be removed.</td></tr>
+ * <tr><td>START</td><td>org/mortbay/start/start.config</td><td>Path to customized startup file. Used for example, by JettyPlus.</td></tr>
+ * <tr><td>STOP.KEY</td><td>No default</td><td>If specified with the start.jar command, a random key is printed on stdout and must be used with the stop.jar command. Security measure to guard against unauthorized stop/starts.</td></tr>
+ * <tr><td>STOP.PORT</td><td>8079</td><td>The local port used to signal to stop the server used with stop.jar. A value of 0 disables the mechanism. See also STOP.KEY</td></tr>
+ * <tr><td>DEBUG</td><td>Not set</td><td>If true, enables debug messages when used with the Jetty logging plugin for Commons logging. See Jetty's FAQ for more info about logging.</td></tr>
+ * <tr><td>DEBUG_PATTERNS</td><td>No default</td><td>Only for use with the Jetty log plugin for Commons logging. Specifies a list of patterns for classnames for which to generate debug messages. See Jetty's FAQ and tutorial for more info about logging.</td></tr>
+ * <tr><td>DEBUG_VERBOSE</td><td>0</td><td>Set to a positive integer value, enables both trace and debug level messages. Set to 0, only debug messages are enabled. Only for use with the Jetty logging plugin for Commons logging. See Jetty's FAQ and tutorial for more info about logging.</td></tr>
+ * <tr><td colspan=3><b>Other</b></td></tr>
+ * <tr><td>org.apache.commons.logging.LogFactory</td><td>org.mortbay.log.Factory</td><td>Property used by the <a href="http://jakarta.apache.org/commons/logging">Apache Commons Logging API</a> to specify the classname of the LogFactory implementation. This property is set in the start.config file. For standard Jetty, it is the Jetty log implemenation org.mortbay.log.Factory. For JettyPlus, it is the Log4J implementation.</td></tr>
+ * </table>
+ * </font>
+ *
+ * @author Johan Sjoberg
+ * @author Peter Royal
+ */
+public class ShieldingJettyContainer extends DefaultJettyContainer
+{
+ /** Jetty's system properties */
+ private final Properties m_jettyProperties;
+
+ /** Stored throwable form Jetty's inialization */
+ private Throwable m_jettyThrowable;
+
+ /**
+ * Create a new ShieldingJettyContainer instance and set some default values.
+ */
+ public ShieldingJettyContainer()
+ {
+ m_jettyProperties = new Properties();
+ m_jettyProperties.putAll( System.getProperties() );
+ }
+
+ /**
+ * Set "system properties" for Jetty. Actually these properties
+ * are set and unset on the current thread for each call to the
+ * underlaying Jetty <code>Server</code>. Note that Jetty or
+ * some of its dependencies might need some properties from
+ * <code>System</code>, like <code>java.home</code>. If you
+ * replace or clear out the properties here Jetty might not work.
+ * Use <code>addJettyProperties</code> to add more properties to
+ * the current set, or add all needed values to the new
+ * <code>Properties</code> object.
+ *
+ * @param properties The new properties. If null or an empty
+ * <code>Properties</code> object is given, the current
+ * properties will be cleared out.
+ */
+ public void setJettyProperties( final Properties properties )
+ {
+ m_jettyProperties.clear();
+ if( null != properties )
+ {
+ m_jettyProperties.putAll( properties );
+ }
+ }
+
+ /**
+ * Add more "system properties" for Jetty. Actually these
+ * properties are set and unset on the current thread for
+ * each call to the underlaying Jetty <code>Server</code>. The
+ * initial value of the underlaying <code>Properties</code> are
+ * copied from <code>System.getProperties()</code>.
+ *
+ * @param properties The new properties. If null or an empty
+ * <code>Properties</code> object is given, the current
+ * properties will be cleared out.
+ */
+ public void addJettyProperties( final Properties properties )
+ {
+ if( null != properties )
+ {
+ m_jettyProperties.putAll( properties );
+ }
+ }
+
+ /**
+ * Fetch the current set of Jetty properties.
+ *
+ * @return current jetty "system properties"
+ */
+ public Properties getJettyProperties()
+ {
+ return m_jettyProperties;
+ }
+
+ /**
+ * Initialize and create a new instance of a Jetty
+ * <code>Server</code>.
+ * <br/><br/>
+ * The server instance can only be created once, so all possible
+ * system properties and configurations that should go to the
+ * constructor must be set before calling this method.
+ * <br/><br/>
+ * A new thread will be spawned, shield itself, call
+ * <code>initialize()</code>, unshield itself and join. If an
+ * <code>Exception</code> was thrown from the Jetty server,
+ * it is stored in <code>m_jettyThrowable</code> and rethrown
+ * after joining again.
+ *
+ * @throws Exception on all errors
+ */
+ public void initialize() throws Exception
+ {
+ final Runnable runnable = new Runnable()
+ {
+ public void run()
+ {
+ SysPropertiesRedirector.install();
+ SysPropertiesRedirector.bindProperties( m_jettyProperties );
+ try
+ {
+ ShieldingJettyContainer.super.initialize();
+ }
+ catch( Exception e )
+ {
+ m_jettyThrowable = e;
+ }
+ }
+ };
+
+ final Thread shieldThread = new Thread( Thread.currentThread().getThreadGroup(),
+ runnable,
+ getClass().getName() + " initialization" );
+ shieldThread.start();
+ shieldThread.join();
+
+ if( null != m_jettyThrowable )
+ {
+ throw (Exception)m_jettyThrowable;
+ }
+ }
+
+ /**
+ * Start the Jetty container
+ *
+ * @throws Exception on all errors
+ */
+ public void start() throws Exception
+ {
+ try
+ {
+ setupShield();
+ super.start();
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Stop the Jetty container
+ *
+ * @throws Exception on all errors
+ */
+ public void stop() throws Exception
+ {
+ try
+ {
+ setupShield();
+ super.stop();
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Create a new context handler.
+ *
+ * @return A new <code>ContextHandler</code> instance
+ */
+ public ContextHandler createContextHandler()
+ {
+ try
+ {
+ setupShield();
+ return super.createContextHandler();
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Destroy a context handler. If the given context handler still
+ * has contexts, they will be stopped and removed before
+ * destryction.
+ *
+ * @param contextHandler The <code>ContextHandler</code> to destroy
+ */
+ public void destroyContextHandler( final ContextHandler contextHandler )
+ {
+ try
+ {
+ setupShield();
+ super.destroyContextHandler( contextHandler );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Add a <code>Listener</code> the container.
+ *
+ * @param listener the listener to add
+ */
+ public void addListener( final Listener listener ) throws ListenerException
+ {
+ try
+ {
+ setupShield();
+ super.addListener( listener );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Remove a <code>Listener</code> from the container.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeListener( final Listener listener )
+ {
+ try
+ {
+ setupShield();
+ super.removeListener( listener );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Start a <code>Listener</code>.
+ *
+ * @param listener the listener to start
+ * @throws ListenerException if the listener couldn't be started
+ */
+ public void startListener( final Listener listener ) throws ListenerException
+ {
+ setupShield();
+ try
+ {
+ super.startListener( listener );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Stop a <code>Listener</code>.
+ *
+ * @param listener the listener to stop
+ * @throws ListenerException if the listener couldn't be stopped
+ */
+ public void stopListener( final Listener listener ) throws ListenerException
+ {
+ setupShield();
+ try
+ {
+ super.stopListener( listener );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Fetch a list of all current <code>Listener</code>s. If there
+ * are no listener the returned list can be empty.
+ *
+ * @return All new list all current listeners.
+ */
+ public List getListeners()
+ {
+ try
+ {
+ setupShield();
+
+ return super.getListeners();
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Check if a <code>Listener</code> is started or not.
+ *
+ * @param listener The listener
+ *
+ * @return True if the listener is started, else false.
+ */
+ public boolean isStarted( final Listener listener )
+ {
+ try
+ {
+ setupShield();
+ return super.isStarted( listener );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Add a context to the container.
+ *
+ * @param context The context to add
+ */
+ public void addContext( final Context context )
+ {
+ try
+ {
+ setupShield();
+ super.addContext( context );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Remove a context from the container.
+ *
+ * @param context The context to remove
+ */
+ public void removeContext( final Context context )
+ {
+ try
+ {
+ setupShield();
+ super.removeContext( context );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Start a context.
+ *
+ * @param context The context to start
+ * @throws ContextException if the context couldn't be started
+ */
+ public void startContext( final Context context ) throws ContextException
+ {
+ try
+ {
+ setupShield();
+ super.startContext( context );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Stop a context.
+ *
+ * @param context The context to stop
+ * @throws ContextException if the context couldn't be stopped
+ */
+ public void stopContext( final Context context ) throws ContextException
+ {
+ try
+ {
+ setupShield();
+ super.startContext( context );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * List the <code>Context</code>s that this
+ * <code>ContextHandler</code> can manage.
+ *
+ * @return A new list of contexts holding all JervletContexts
+ */
+ public List getContexts()
+ {
+ try
+ {
+ setupShield();
+ return super.getContexts();
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Check if <code>Context</context> owned by this handler is
+ * started on not.
+ *
+ * @param context The context to check
+ * @return true if the given context is started, else false
+ */
+ public boolean isStarted( final Context context )
+ {
+ try
+ {
+ setupShield();
+ return super.isStarted( context );
+ }
+ finally
+ {
+ teardownShield();
+ }
+ }
+
+ /**
+ * Set up a system property shield for the current thread.
+ */
+ private void setupShield()
+ {
+ SysPropertiesRedirector.install();
+ SysPropertiesRedirector.bindProperties( m_jettyProperties );
+ }
+
+ /**
+ * Tear down the system property shield for the current thread.
+ */
+ private void teardownShield()
+ {
+ SysPropertiesRedirector.uninstall();
+ }
+}
+
</pre></div>
<hr /><a name="file17" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl/avalon<br /></span>
<div class="fileheader" id="added"><big><b>AvalonContextMonitor.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N AvalonContextMonitor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AvalonContextMonitor.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,256 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.avalon;
+
+import org.codehaus.spice.jervlet.Context;
+import org.codehaus.spice.jervlet.ContextException;
+import org.codehaus.spice.jervlet.ContextMonitor;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+/**
+ * Avalon style, logging context monitor
+ * <br/><br/>
+ * The format of the log file is: "Operation message" "Reporting class"
+ * "Context" "Message". Message is empty for notifications.
+ *
+ * @author Johan Sjoberg
+ */
+public class AvalonContextMonitor implements ContextMonitor, LogEnabled
+{
+ /** Avalon logger recieving all log events */
+ private Logger m_logger;
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ * @param e
+ * @throws ContextException
+ */
+ public void addContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException
+ {
+ final String message = "\"Got exception when adding context\" "
+ + getExceptionMessage( reportingClass, context, e );
+ m_logger.error( message, e );
+ throwContextException( e );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ * @param e
+ * @throws ContextException
+ */
+ public void removeContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException
+ {
+ final String message = "\"Got exception when removing context\" "
+ + getExceptionMessage( reportingClass, context, e );
+ m_logger.error( message, e );
+ throwContextException( e );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ * @param e
+ * @throws ContextException
+ */
+ public void startContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException
+ {
+ final String message = "\"Got exception when starting context\" "
+ + getExceptionMessage( reportingClass, context, e );
+ m_logger.error( message, e );
+ throwContextException( e );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ * @param e
+ * @throws ContextException
+ */
+ public void stopContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException
+ {
+ final String message = "\"Got exception when stopping context\" "
+ + getExceptionMessage( reportingClass, context, e );
+ m_logger.error( message, e );
+ throwContextException( e );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ * @param message
+ */
+ public void addContextWarning( Class reportingClass, Context context, String message )
+ {
+ final String logMessage = "\"Context addition warning\" "
+ + getWarning( reportingClass, context, message );
+ m_logger.warn( logMessage );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ * @param message
+ */
+ public void removeContextWarning( Class reportingClass, Context context, String message )
+ {
+ final String logMessage = "\"Context removal warning\" "
+ + getWarning( reportingClass, context, message );
+ m_logger.warn( logMessage );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ * @param message
+ */
+ public void startContextWarning( Class reportingClass, Context context, String message )
+ {
+ final String logMessage = "\"Context start warning\" "
+ + getWarning( reportingClass, context, message );
+ m_logger.warn( logMessage );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ * @param message
+ */
+ public void stopContextWarning( Class reportingClass, Context context, String message )
+ {
+ final String logMessage = "\"Context stop warning\" "
+ + getWarning( reportingClass, context, message );
+ m_logger.warn( logMessage );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ */
+ public void addContextNotification( Class reportingClass, Context context )
+ {
+ final String message = "\"Adding context\" "
+ + getNotification( reportingClass, context );
+ m_logger.info( message );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ */
+ public void removeContextNotification( Class reportingClass, Context context )
+ {
+ final String message = "\"Removing context\" "
+ + getNotification( reportingClass, context );
+ m_logger.info( message );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ */
+ public void startContextNotification( Class reportingClass, Context context )
+ {
+ final String message = "\"Starting context\" "
+ + getNotification( reportingClass, context );
+ m_logger.info( message );
+ }
+
+ /**
+ * @see org.codehaus.spice.jervlet.ContextMonitor
+ * @param reportingClass
+ * @param context
+ */
+ public void stopContextNotification( Class reportingClass, Context context )
+ {
+ final String message = "\"Stopping context\" "
+ + getNotification( reportingClass, context );
+ m_logger.info( message );
+ }
+
+ /**
+ * Get the logger. All monitor events vill be logger to this logger.
+ *
+ * @param logger The logger to use for monitor events
+ * @dna.logger
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ /**
+ * Throw a <code>ContextException</code>
+ *
+ * @param e Original Exception
+ * @throws ContextException A new ListenerException instance
+ */
+ private void throwContextException( Exception e )
+ throws ContextException
+ {
+ ContextException contextException =
+ new ContextException( e.getMessage(), e.getCause() );
+ throw contextException;
+ }
+
+ /**
+ * Form an exception message
+ *
+ * @return a new Exception message
+ */
+ private String getExceptionMessage( Class reportingClass, Context context, Exception e )
+ {
+ return new StringBuffer().append( "\"" )
+ .append( reportingClass.getName() ).append( "\" \"" )
+ .append( context ).append( "\" \"" ).append( e.getMessage() )
+ .append( "\"" ).toString();
+ }
+
+ /**
+ * Form a message
+ *
+ * @return a new warning message
+ */
+ private String getWarning( Class reportingClass, Context context, String message )
+ {
+ return new StringBuffer().append( "\"" )
+ .append( reportingClass.getName() ).append( "\" \"" )
+ .append( context ).append( "\" \"" ).append( message )
+ .append( "\"" ).toString();
+ }
+
+ /**
+ * Form a notification
+ *
+ * @return a new notification message
+ */
+ private String getNotification( Class reportingClass, Context context )
+ {
+ return new StringBuffer().append( "\"" )
+ .append( reportingClass.getName() )
+ .append( "\" \"" ).append( context )
+ .append( "\" \"\"" ).toString();
+ }
+}
</pre></div>
<hr /><a name="file18" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl/avalon<br /></span>
<div class="fileheader" id="added"><big><b>AvalonInstantiator.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N AvalonInstantiator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AvalonInstantiator.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,144 @@
</small></pre><pre class="diff" id="added">+/*
+
+============================================================================
+ The Apache Software License, Version 1.1
+============================================================================
+
+Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modifica-
+tion, 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 "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
+ must not be used to endorse or promote products derived from this software
+ without prior written permission. For written permission, please contact
+ [email protected]
+
+5. Products derived from this software may not be called "Apache", 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 (INCLU-
+DING, 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/>.
+
+*/
+
+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.avalon;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.container.ContainerUtil;
+
+import org.codehaus.spice.jervlet.Instantiator;
+
<a name="task4" />+//<span class="task">TODO</span>: Should this instantiator extend AbstractInstantiator? Would it be nice to use setter injection too? Perhaps create different Instantiators for all possibilities? At least an AvalonSetterInstantiator should be created.
<a name="task5" />+//<span class="task">TODO</span>: Should we remove the context? It could be easier for back compatibility in the future. Not sure a Servlet really needs the Avalon context.
+
+/**
+ * Instantiator for Apache Avalon style Servlet and Filter components
+ * <br/><br/>
+ * If a component is <code>LogEnabled</code> then a
+ * <code>Logger</code> is set on it, if it is <code>Servicable</code>
+ * then a <code>ServiceManager</code> is set on it and if it is
+ * <code>Contextualizable</code> then a <code>Context</code> is set
+ * on it. Even though the <code>Intializable</code> life cycle
+ * interface overlaps a servlet's <code>init()</code> method it is
+ * called here. Note that no other lifecycle interfaces are
+ * supported.
+ *
+ * @author Johan Sjoberg
+ * @author Ben Hogan
+ */
+public class AvalonInstantiator implements Instantiator
+{
+ /** The service manager */
+ private ServiceManager m_serviceManager;
+
+ /** The logger */
+ private Logger m_logger;
+
+ /** The context */
+ private Context m_context;
+
+ /**
+ * Create a new Avalon style Servlet and Filter instantiator
+ *
+ * @param context The Avalon context to give to new servlets
+ * @param serviceManager The service manager to give to new servlets
+ * @param logger The logger to give to new servlets.
+ * @throws IllegalArgumentException if an argument was null.
+ */
+ public AvalonInstantiator( final Context context,
+ final ServiceManager serviceManager,
+ final Logger logger )
+ {
+ if( null == context || null == serviceManager || null == logger )
+ {
+ throw new IllegalArgumentException( "An argument was null." );
+ }
+ m_context = context;
+ m_serviceManager = serviceManager;
+ m_logger = logger;
+ }
+
+ /**
+ * Instantiate an Avalon style servlet or filter class.
+ *
+ * @param clazz The Avalon style class to instantiate
+ * @return The instatiated avalon servlet component.
+ * @throws InstantiationException If the class couldn't be instantiated
+ * @throws IllegalAccessException if access to the class was restricted
+ */
+ public Object instantiate( Class clazz )
+ throws InstantiationException, IllegalAccessException
+ {
+ Object instance = clazz.newInstance();
+ try
+ {
+ ContainerUtil.enableLogging( instance, m_logger );
+ ContainerUtil.contextualize( instance, m_context );
+ ContainerUtil.service( instance, m_serviceManager );
+ ContainerUtil.initialize( instance );
+ }
+ catch( Exception e )
+ {
+ final String msg = "Exception during lifecycle processing for class ["
+ + clazz.getName() + "]. Exception message: " + e.getMessage();
+ throw new InstantiationException( msg );
+ }
+ return instance;
+ }
+}
</pre></div>
<hr /><a name="file19" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl/avalon<br /></span>
<div class="fileheader" id="added"><big><b>AvalonInstantiatorComponent.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N AvalonInstantiatorComponent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AvalonInstantiatorComponent.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,98 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+
+package org.codehaus.spice.jervlet.impl.avalon;
+
+import org.codehaus.spice.jervlet.Instantiator;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceManager;
+
+/**
+ * Avalon component wrapping an <code>AvalonInstantiator</code>.
+ *
+ * @author Johan Sjoberg
+ * @author Ben Hogan
+ *
+ * @dna.component
+ * @dna.service type="Instantiator"
+ */
+public class AvalonInstantiatorComponent
+ implements Instantiator, LogEnabled, Serviceable, Contextualizable, Initializable
+{
+ /** Internal AvalonInstantiator */
+ AvalonInstantiator m_avalonInstantiator;
+
+ /** Avalon logger */
+ Logger m_logger;
+
+ /** Avalon service manager */
+ ServiceManager m_serviceManager;
+
+ /** Avalon context */
+ Context m_context;
+
+ /**
+ * Instantiate a servlet class. The calls are rerouted
+ * to an internal <code>AvalonInstantiator</code>.
+ *
+ * @param clazz The class to instantiate
+ * @return The instatiated class
+ * @throws InstantiationException Rethrown from internal AvalonInstantiator
+ * @throws IllegalAccessException Rethrown from internal AvalonInstantiator
+ */
+ public Object instantiate( Class clazz )
+ throws InstantiationException, IllegalAccessException
+ {
+ return m_avalonInstantiator.instantiate( clazz );
+ }
+
+ /**
+ * Get the <code>Logger</code>.
+ *
+ * @param logger The logger
+ * @dna.logger
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ /**
+ * Get the <code>ServiceManager</code>.
+ *
+ * @param serviceManager The service manager
+ */
+ public void service( ServiceManager serviceManager )
+ {
+ m_serviceManager = serviceManager;
+ }
+
+ /**
+ * Get the <code>Context</code>
+ *
+ * @param context The context
+ */
+ public void contextualize( Context context )
+ {
+ m_context = context;
+ }
+
+ /**
+ * Initialize: create a new <code>AvalonInstantiator</code>.
+ */
+ public void initialize()
+ {
+ m_avalonInstantiator = new AvalonInstantiator(
+ m_context, m_serviceManager, m_logger );
+ }
+}
</pre></div>
<hr /><a name="file20" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl/avalon<br /></span>
<div class="fileheader" id="added"><big><b>AvalonListenerMonitor.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N AvalonListenerMonitor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AvalonListenerMonitor.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,313 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.avalon;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.codehaus.spice.jervlet.ListenerMonitor;
+import org.codehaus.spice.jervlet.Listener;
+import org.codehaus.spice.jervlet.ListenerException;
+
+/**
+ * Avalon logging listener monitor
+ * <br/><br/>
+ * The format of the log file is: "Operation message" "Reporting class"
+ * "Context" "Message". Message is empty for notifications.
+ *
+ * @author Johan Sjoberg
+ */
+public class AvalonListenerMonitor implements ListenerMonitor, LogEnabled
+{
+ /** Avalon logger recieving all log events */
+ Logger m_logger;
+
+ /**
+ * Create an AvalonListenerMonitor
+ */
+ public AvalonListenerMonitor()
+ {
+ }
+
+ /**
+ * Create an AvalonListenerMonitor
+ *
+ * @param logger The Avalon logger to send monitor events to.
+ */
+ public AvalonListenerMonitor( final Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ /**
+ * Get an AvalonLogger. If the logger was given in the
+ * constructor, this method has no meaning. It won't
+ * be set twice.
+ *
+ * @param logger The logger to send monitor events to.
+ */
+ public void enableLogging( final Logger logger )
+ {
+ if( null == m_logger )
+ {
+ m_logger = logger;
+ }
+ }
+
+ /**
+ * Notify that an Exception was thrown when adding a Listener.
+ * <br/><br/>
+ * Log level: ERROR
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be started
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException representing the reported error
+ */
+ public void addListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException
+ {
+ final String message = "\"Add listener exception\" "
+ + getExceptionMessage( reportingClass, listener, e );
+ m_logger.error( message, e );
+ throwListenerException( e );
+ }
+
+ /**
+ * Notify that an Exception was thrown when removing a Listener.
+ * <br/><br/>
+ * Log level: ERROR
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be started
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException representing the reported error
+ */
+ public void removeListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException
+ {
+ final String message = "\"Remove listener exception\" "
+ + getExceptionMessage( reportingClass, listener, e );
+ m_logger.error( message, e );
+ throwListenerException( e );
+ }
+
+ /**
+ * Report a warning about adding a listener
+ * <br/><br/>
+ * Log level: WARNING
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ public void addListenerWarning( Class reportingClass, Listener listener, String message )
+ {
+ final String logMessage = "\"Add listener warning\" "
+ + getWarning( reportingClass, listener, message );
+ m_logger.warn( logMessage );
+ }
+
+ /**
+ * Report a warning about removing a listener
+ * <br/><br/>
+ * Log level: WARNING
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ public void removeListenerWarning( Class reportingClass, Listener listener, String message )
+ {
+ final String logMessage = "\"Remove listener warning\" "
+ + getWarning( reportingClass, listener, message );
+ m_logger.warn( logMessage );
+ }
+
+ /**
+ * Report that a listener has been added
+ * <br/><br/>
+ * Log level: INFO
+ *
+ * @param reportingClass The class reporting the listener start event
+ * @param listener The listener that was started
+ */
+ public void addListenerNotification( Class reportingClass, Listener listener )
+ {
+ final String message = "\"Added listener\" "
+ + getNotification( reportingClass, listener );
+ m_logger.info( message );
+ }
+
+ /**
+ * Report that a listner has been removed
+ * <br/><br/>
+ * Log level: INFO
+ *
+ * @param reportingClass The class reporting the listener stop event
+ * @param listener The listener that was stopped
+ */
+ public void removeListenerNotification( Class reportingClass, Listener listener )
+ {
+ final String message = "\"Removed listener\" "
+ + getNotification( reportingClass, listener );
+ m_logger.info( message );
+ }
+
+
+
+ /**
+ * Notify that an Exception was thrown when starting a Listener.
+ * <br/><br/>
+ * Log level: ERROR
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be started
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException
+ * representing the reported error
+ */
+ public void startListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException
+ {
+ final String message = "\"Start listener exception\" "
+ + getExceptionMessage( reportingClass, listener, e );;
+ m_logger.error( message, e );
+ throwListenerException( e );
+ }
+
+ /**
+ * Notify that an Exception was thrown when stopping a Listener.
+ * <br/><br/>
+ * Log level: ERROR
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be stopped
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException
+ * representing the reported error
+ */
+ public void stopListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException
+ {
+ final String message = "\"Stop listener exception\" "
+ + getExceptionMessage( reportingClass, listener, e );
+ m_logger.error( message, e );
+ throwListenerException( e );
+ }
+
+ /**
+ * Report a warning about starting a listener
+ * <br/><br/>
+ * Log level: WARNING
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ public void startListenerWarning( Class reportingClass, Listener listener, String message )
+ {
+ final String logMessage = "\"Start listener warning\" "
+ + getWarning( reportingClass, listener, message );
+ m_logger.warn( logMessage );
+ }
+
+ /**
+ * Report a warning about stopping a listener
+ * <br/><br/>
+ * Log level: WARNING
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ public void stopListenerWarning( Class reportingClass, Listener listener, String message )
+ {
+ final String logMessage = "\"Stop listener warning\" "
+ + getWarning( reportingClass, listener, message );
+ m_logger.warn( logMessage );
+ }
+
+ /**
+ * Report that a listener has been started
+ * <br/><br/>
+ * Log level: INFO
+ *
+ * @param reportingClass The class reporting the listener start event
+ * @param listener The listener that was started
+ */
+ public void startListenerNotification( Class reportingClass, Listener listener )
+ {
+ final String message = "\"Started listener\" "
+ + getNotification( reportingClass, listener );
+ m_logger.info( message );
+ }
+
+ /**
+ * Report that a listner has been stopped
+ * <br/><br/>
+ * Log level: INFO
+ *
+ * @param reportingClass The class reporting the listener stop event
+ * @param listener The listener that was stopped
+ */
+ public void stopListenerNotification( Class reportingClass, Listener listener )
+ {
+ final String message = "\"Stopped listener\" "
+ + getNotification( reportingClass, listener );
+ m_logger.info( message );
+ }
+
+ /**
+ * Throw a <code>ListenerException</code>
+ *
+ * @param e Original Exception
+ * @throws ListenerException A new ListenerException instance
+ */
+ private void throwListenerException( Exception e )
+ throws ListenerException
+ {
+ ListenerException listenerException =
+ new ListenerException( e.getMessage(), e.getCause() );
+ throw listenerException;
+ }
+
+ /**
+ * Form an Exception message
+ *
+ * @return a new Exception message
+ */
+ private String getExceptionMessage( Class reportingClass, Listener listener, Exception e )
+ {
+ return new StringBuffer().append( "\"" ).append( reportingClass.getName() )
+ .append( "\" \"" ).append( listener ).append( "\" \"" ).append( e.getMessage() )
+ .append( "\"" ).toString();
+ }
+
+ /**
+ * Form an message
+ *
+ * @return a new warning message
+ */
+ private String getWarning( Class reportingClass, Listener listener, String message )
+ {
+ return new StringBuffer().append( "\"" ).append( reportingClass.getName() )
+ .append( "\" \"" ).append( listener ).append( "\" \"" ).append( message )
+ .append( "\"" ).toString();
+ }
+
+ /**
+ * Form a notification
+ *
+ * @return a new notification message
+ */
+ private String getNotification( Class reportingClass, Listener listener )
+ {
+ return new StringBuffer().append( "\"" ).append( reportingClass.getName() )
+ .append( "\" \"" ).append( listener ).append( "\" \"\"" ).toString();
+ }
+}
</pre></div>
<hr /><a name="file21" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl/avalon<br /></span>
<div class="fileheader" id="added"><big><b>SimpleAvalonDeployer.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N SimpleAvalonDeployer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SimpleAvalonDeployer.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,192 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.avalon;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.activity.Initializable;
+
+import org.codehaus.spice.jervlet.Container;
+import org.codehaus.spice.jervlet.ContextException;
+import org.codehaus.spice.jervlet.Instantiator;
+import org.codehaus.spice.jervlet.impl.AbstractDeploymentHelper;
+
+/**
+ * Avalon component deploying Avalon style Servlet and Filter
+ * components. The logger, context and service manager given to this
+ * component are directly used for the <code>Instantiator</code>.
+ * This means all dependencies of this component are seen by the
+ * deployed classes. <code>SimpleAvalonDeployer</code> can also be
+ * configured to deploy contexts upon initialization. The only mandatory
+ * dependency for this component is a <code>Container</code>. The
+ * container is used for creating one <code>ContextHandler</code> and
+ * all contexts are deployed to it. If no <code>Instantiator</code>
+ * is available from the <code>ServiceManager</code> a new
+ * <code>AvalonInstantiator</code> is created and used.
+ *
+ * @dna.component
+ * @author Johan Sjoberg
+ */
+public class SimpleAvalonDeployer extends AbstractDeploymentHelper
+ implements LogEnabled, Contextualizable, Configurable, Serviceable, Initializable
+{
+ /** The service manager */
+ private ServiceManager m_serviceManager;
+
+ /** The logger */
+ private Logger m_logger;
+
+ /** The context */
+ private Context m_context;
+
+ /** The configuration */
+ private Configuration m_configuration;
+
+ /**
+ * Set the logger
+ *
+ * @dna.logger
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ /**
+ * Set the context
+ */
+ public void contextualize( Context context )
+ {
+ m_context = context;
+ }
+
+ /**
+ * Set the service manager
+ * <br/><br/>
+ * Note, the Instantiator is an optional dependency. If given, it
+ * will be used, otherwise a new <code>AvalonInstantiator</code>
+ * is created.
+ *
+ * @dna.dependency type="org.codehaus.spice.jervlet.Container"
+ * @dna.dependency type="org.codehaus.spice.jervlet.Instantiator" optional="true"
+ */
+ public void service( ServiceManager serviceManager )
+ {
+ m_serviceManager = serviceManager;
+ }
+
+ /**
+ * Set the configuration
+ * <br/><br/>
+ * The configuration can be empty. In this case no contexts will be
+ * automatically deployed. The format is:
+ * <br/>
+ * <pre>
+ * &lt;contexts&gt;
+ * &lt;!-- Enumeration of "context" elements --&gt;
+ * &lt;context&gt;
+ * &lt;!-- The path, e.g. "mywebapp" --&gt;
+ * &lt;path&gt;&lt;/path&gt;
+ * &lt;-- Resource URL, e.g. "file:///usr/local/java/webapps/mywebapp.war" --&gt;
+ * &lt;resource&gt;&lt;/resource&gt;
+ * &lt;!-- Virtual hosts (Optional) --&gt;
+ * &lt;virtual-hosts&gt;
+ * &lt;!-- Enumeration ov "virtual-host" elements, e.g. "www.biz.com" --&gt;
+ * &lt;virtual-host&gt;&lt;/virtual-host&gt;
+ * &lt;/virtual-hosts&gt;
+ * &lt;/context&gt;
+ * &lt;/contexts&gt;
+ *</pre>
+ *
+ * @param configuration The Avalon configuration
+ */
+ public void configure( Configuration configuration )
+ {
+ m_configuration = configuration;
+ }
+
+ /**
+ * Initialize the component
+ * <br/><br/>
+ * If no Instantiator was given, an AvalonInstantiator is created
+ * here with this component's logger, context and service
+ * manager. If this compoent was configured with contexts in its
+ * configuration they are also deployed here.
+ *
+ * @throws Exception on all errors
+ */
+ public void initialize() throws Exception
+ {
+ Instantiator instantiator = null;
+ if( m_serviceManager.hasService( Instantiator.ROLE ) )
+ {
+ instantiator = (Instantiator)m_serviceManager.lookup(
+ Instantiator.ROLE );
+ }
+ else
+ {
+ m_logger.info( "Creating a new AvalonInstantiator." );
+ instantiator = new AvalonInstantiator(
+ m_context, m_serviceManager, m_logger );
+ }
+ setInstantiator( instantiator );
+
+ final Container container =
+ (Container)m_serviceManager.lookup( Container.ROLE );
+ setContextHandler( container.createContextHandler() );
+ deployFromConfiguration( m_configuration );
+ }
+
+ /**
+ * Deploy contexts from a configuration.
+ *
+ * @see #configure( Configuration configuration ) for the
+ * configuration format.
+ * @param configuration The configuration
+ */
+ private void deployFromConfiguration( Configuration configuration )
+ throws ConfigurationException, MalformedURLException, ContextException
+ {
+ Configuration[] contextConfigurations = configuration
+ .getChild( "contexts", true ).getChildren( "context" );
+ if( null != contextConfigurations )
+ {
+ for( int i = 0; i < contextConfigurations.length; i++ )
+ {
+ String path =
+ contextConfigurations[i].getChild( "path" ).getValue();
+ String resourceString =
+ contextConfigurations[i].getChild( "resource" ).getValue();
+ URL resource = new URL( resourceString );
+ Configuration[] virtualHostConfigurations =
+ contextConfigurations[i].getChild( "virtual-hosts", true )
+ .getChildren( "virtual-host" );
+ String[] virtualHosts = null;
+ if( null != virtualHostConfigurations )
+ {
+ virtualHosts = new String[virtualHostConfigurations.length];
+ for( int j = 0; j < virtualHosts.length; j++ )
+ {
+ virtualHosts[j] = virtualHostConfigurations[j].getValue();
+ }
+ }
+ deployContext( path, virtualHosts, resource );
+ }
+ }
+ }
+}
</pre></div>
<hr /><a name="file22" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl/dna<br /></span>
<div class="fileheader" id="added"><big><b>DNAInstantiator.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DNAInstantiator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DNAInstantiator.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,80 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.dna;
+
+import org.codehaus.dna.ResourceLocator;
+import org.codehaus.dna.Logger;
+import org.codehaus.dna.impl.ContainerUtil;
+
+import org.codehaus.spice.jervlet.Instantiator;
+
+/**
+ * Instantiator for DNA style servlet and filter components.
+ * <br/><br/>
+ * If a class is <code>LogEnabled</code> then a <code>Logger</code>
+ * is set on the class, if it is <code>Composable</code> then a
+ * <code>ResourceLocator</code> is set on it. Even though the
+ * <code>Active</code> life cycle interface overlaps a servlet's
+ * init() method, <code>initialize</code> is called. Note that no
+ * other lifecycle interfaces are supported, including destruction.
+ *
+ * @author Johan Sjoberg
+ */
+public class DNAInstantiator implements Instantiator
+{
+ /** The service manager */
+ private ResourceLocator m_resourceLocator;
+
+ /** The logger */
+ private Logger m_logger;
+
+ /**
+ * Create a new DNA style instantiator.
+ *
+ * @param resourceLocator The resource locator to give to new servlets
+ * @param logger The logger to give to new servlets.
+ * @throws IllegalArgumentException if some argument is null.
+ */
+ public DNAInstantiator( final ResourceLocator resourceLocator,
+ final Logger logger )
+ {
+ if( null == resourceLocator || null == logger )
+ {
+ throw new IllegalArgumentException( "An argument was null." );
+ }
+ m_resourceLocator = resourceLocator;
+ m_logger = logger;
+ }
+
+ /**
+ * Instantiate a DNA style Servlet or Filter class.
+ *
+ * @param clazz the DNA style servlet or filter class to instantiate
+ * @return the instatiated class
+ * @throws InstantiationException if the class couldn't be instantiated
+ * @throws IllegalAccessException if access to the class was restricted
+ */
+ public Object instantiate( Class clazz )
+ throws InstantiationException, IllegalAccessException
+ {
+ Object instance = clazz.newInstance();
+ try
+ {
+ ContainerUtil.enableLogging( instance, m_logger );
+ ContainerUtil.compose( instance, m_resourceLocator );
+ ContainerUtil.initialize( instance );
+ }
+ catch( Exception e )
+ {
+ final String msg = "Exception during lifecycle processing for servlet ["
+ + clazz.getName() + "]. Exception message: " + e.getMessage();
+ throw new InstantiationException( msg );
+ }
+ return instance;
+ }
+}
</pre></div>
<hr /><a name="file23" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl/pico<br /></span>
<div class="fileheader" id="added"><big><b>PicoInstantiator.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N PicoInstantiator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PicoInstantiator.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,104 @@
</small></pre><pre class="diff" id="added">+/*
+
+============================================================================
+ The Apache Software License, Version 1.1
+============================================================================
+
+Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modifica-
+tion, 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 "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
+ must not be used to endorse or promote products derived from this software
+ without prior written permission. For written permission, please contact
+ [email protected]
+
+5. Products derived from this software may not be called "Apache", 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 (INCLU-
+DING, 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/>.
+
+*/
+
+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.pico;
+
+import org.picocontainer.MutablePicoContainer;
+import org.picocontainer.defaults.DefaultPicoContainer;
+
+import org.codehaus.spice.jervlet.Instantiator;
+
+/**
+ * Instantiator for Pico style servlet/filter components. Note, these
+ * slightly break the servlet specification by unsing a non empty
+ * constructor.
+ *
+ * @author Paul Hammant
+ * @author Johan Sjoberg
+ */
+public class PicoInstantiator implements Instantiator
+{
+ /** The parent container */
+ private final MutablePicoContainer m_parentContainer;
+
+ /**
+ * Create a new instance.
+ *
+ * @param mutablePicoContainer The parent container
+ */
+ public PicoInstantiator( MutablePicoContainer mutablePicoContainer )
+ {
+ m_parentContainer = mutablePicoContainer;
+ }
+
+ /**
+ * Instantiate a Pico servlet or filter class.
+ *
+ * @param clazz The servlet or filter class to instantiate
+ * @return the instatiated class
+ * @throws InstantiationException If the class couldn't be instantiated
+ * @throws IllegalAccessException If access to the class was restricted
+ */
+ public Object instantiate( Class clazz )
+ throws InstantiationException, IllegalAccessException
+ {
+ MutablePicoContainer picoContainer =
+ new DefaultPicoContainer( m_parentContainer );
+ picoContainer.registerComponentImplementation( clazz );
+ return picoContainer.getComponentInstance( clazz );
+ }
+}
</pre></div>
<hr /><a name="file24" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl<br /></span>
<div class="fileheader" id="added"><big><b>AbstractDeploymentHelper.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N AbstractDeploymentHelper.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AbstractDeploymentHelper.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,161 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl;
+
+import java.net.URL;
+import java.util.List;
+
+import org.codehaus.spice.jervlet.Context;
+import org.codehaus.spice.jervlet.ContextException;
+import org.codehaus.spice.jervlet.ContextHandler;
+import org.codehaus.spice.jervlet.Instantiator;
+
+/**
+ * Basic helper class bo be extended by "deployment" compoents.
+ * It includes common functionality to set and get resources
+ * plus methods to help deploy and undeploy applications.
+ *
+ * @author Johan Sjoberg
+ */
+public abstract class AbstractDeploymentHelper
+{
+ /** Selvlet class instantiator */
+ private Instantiator m_instantiator;
+
+ /** Context handler */
+ private ContextHandler m_contextHandler;
+
+ /**
+ * Set the <code>Instantiator</code> to be used when creating Servlet
+ * instances. Note that the instantiator can only be set once.
+ *
+ * @param instantiator The local servlet class instantiator
+ */
+ public void setInstantiator( Instantiator instantiator )
+ {
+ if( null == m_instantiator )
+ {
+ m_instantiator = instantiator;
+ }
+ }
+
+ /**
+ * Set the <code>ContextHandler</code> for this component. Note that
+ * the context handler can only be set once.
+ *
+ * @param contextHandler The local context handler
+ */
+ public void setContextHandler( ContextHandler contextHandler )
+ {
+ if( null == m_contextHandler )
+ {
+ m_contextHandler = contextHandler;
+ }
+ }
+
+ /**
+ * Fetch the <code>ContextHandler</code> used here for handling
+ * contexts.
+ *
+ * @return The local context handler.
+ */
+ public ContextHandler getContextHandler()
+ {
+ return m_contextHandler;
+ }
+
+ /**
+ * Deploy a context.
+ *
+ * @param path The web path of the context.
+ * @param resource A pointer to the resource for this web application.
+ */
+ public void deployContext( final String path, final URL resource )
+ throws ContextException
+ {
+ deployContext( path, null, resource );
+ }
+
+ /**
+ * Deploy a context.
+ *
+ * @param path The web path of the context.
+ * @param virtualHosts A list of virtual hosts to deploy this context
+ * to or null if virtual hosts are not used.
+ * @param resource A pointer to the resource for this web application.
+ */
+ public void deployContext( final String path,
+ final String[] virtualHosts,
+ final URL resource ) throws ContextException
+ {
+ DefaultContext context = new DefaultContext(
+ path, virtualHosts, resource, true, m_instantiator );
+ m_contextHandler.addContext( context );
+ m_contextHandler.startContext( context );
+ }
+
+ /**
+ * Deploy a context.
+ *
+ * @param path The web path of the context
+ * @param virtualHosts A list of virtual hosts to deploy this context
+ * to or null if virtual hosts are not used
+ * @param resource A pointer to the resource for this web application
+ * @param extractWebArchive Should WARs be extracted by the container?
+ */
+ public void deployContext( final String path,
+ final String[] virtualHosts,
+ final URL resource,
+ final boolean extractWebArchive )
+ throws ContextException
+ {
+ DefaultContext context = new DefaultContext(
+ path, virtualHosts, resource, extractWebArchive, m_instantiator );
+ m_contextHandler.addContext( context );
+ m_contextHandler.startContext( context );
+ }
+
+ /**
+ * Undeploy a context.
+ *
+ * @param path The path of the context to undeploy
+ */
+ public void undeployContext( final String path ) throws ContextException
+ {
+ Context context = getContext( path );
+ if( null != context )
+ {
+ m_contextHandler.stopContext( context );
+ m_contextHandler.removeContext( context );
+ }
+ }
+
+ /**
+ * Fetch the <code>Context</code> for a web path.
+ *
+ * @param path The path of the context to look for.
+ * @return The context for the given path or null if none was found.
+ */
+ private Context getContext( final String path )
+ {
+ if( null == path )
+ {
+ return null;
+ }
+ List contexts = m_contextHandler.getContexts();
+ for( int i = 0; i < contexts.size(); i++ )
+ {
+ Context context = (Context)contexts.get( i );
+ if( path.equals( context.getPath() ) )
+ {
+ return context;
+ }
+ }
+ return null;
+ }
+}
</pre></div>
<hr /><a name="file25" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl<br /></span>
<div class="fileheader" id="added"><big><b>AbstractInstantiator.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N AbstractInstantiator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AbstractInstantiator.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,85 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl;
+
+import org.codehaus.spice.jervlet.Instantiator;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Abstract instantiator, using method insertion to instantiate
+ * new Servet and Filter classes.
+ * <br/><br/>
+ * This is the suggested way to instantiate Servlet classes in
+ * Jervlet. Components extending this class must provide a way
+ * to resolve dependencies. All frameworks should have this
+ * functionality, though.
+ *
+ * @author Johan Sjoberg
+ */
+public abstract class AbstractInstantiator implements Instantiator
+{
+
+ /**
+ * Instantiate a servlet or filter class using method
+ * insertion.
+ *
+ * @param clazz The class to instantiate
+ * @return The instantiated class
+ */
+ public Object instantiate( Class clazz )
+ throws InstantiationException, IllegalAccessException
+ {
+ if( clazz.isInterface() )
+ {
<a name="task6" />+ //<span class="task">TODO</span>: Throw exception?
+ return null;
+ }
+ Method[] methods = clazz.getMethods();
+ Object component = clazz.newInstance();
+ if( null != methods && 0 >= methods.length )
+ {
+ for( int i = 0; i < methods.length; i++ )
+ {
+ Method currentMethod = methods[i];
+ String name = currentMethod.getName();
+ if( name.length() >= 4 &&
+ name.startsWith( "set" ) &&
+ Character.isUpperCase( name.charAt( 3 ) ) &&
+ 1 == currentMethod.getParameterTypes().length )
+ {
+ String dependencyKey = name.substring( 3 );
+ Object dependency = getDependency( clazz, dependencyKey );
+ if( null != dependency )
+ {
+ Object[] arguments = { dependency };
+ try
+ {
+ currentMethod.invoke( component, arguments );
+ }
+ catch( InvocationTargetException ite )
+ {
<a name="task7" />+ //<span class="task">TODO</span>: Do something useful...
+ }
+ }
+ }
+ }
+ }
+ return component;
+ }
+
+ /**
+ * Fetch a dependency.
+ *
+ * @param clazz The class that needs the dependency
+ * @param key The lookup key.
+ * @return A reference to the wanted dependency
+ */
+ public abstract Object getDependency( final Class clazz, final String key );
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file26" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl<br /></span>
<div class="fileheader" id="added"><big><b>DefaultContext.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DefaultContext.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DefaultContext.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,111 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl;
+
+import org.codehaus.spice.jervlet.Context;
+import org.codehaus.spice.jervlet.Instantiator;
+
+import java.net.URL;
+
+/**
+ * Default implementation of a Context. A context represents a web
+ * application. It has a path, e.g. '/myapp', an optional list of
+ * virtual hosts, e.g. '[www.mydomain.com][www.myotherdomain.net]'
+ * and a pointer to the resource. A resource is the physical URL to
+ * a WAR file, or directory containing an exploaded war. In the case
+ * of Jervlet (here) we also have an instantiator used to instantiate
+ * the servlet and filter classes.
+ *
+ * @author Johan Sjoberg
+ */
+public class DefaultContext implements Context
+{
+ /** The path of the context */
+ private String m_path;
+
+ /** Optional virtual hosts */
+ private String[] m_virtualHosts;
+
+ /** Web application resource pointer */
+ private URL m_resource;
+
+ /** Extract WARs or not */
+ private boolean m_extractWebArchive;
+
+ /** Servlet instantiator */
+ private Instantiator m_instantiator;
+
+ /**
+ * Create a new Context
+ *
+ * @param path The path of the context
+ * @param virtualHosts Optional virtual hosts, set to null for no virtual hosts.
+ * @param resource The web application resource pointer
+ * @param instantiator A servlet instantiator
+ * @throws IllegalArgumentException if some of the arguments,
+ * except virtualHosts, are null.
+ */
+ public DefaultContext( final String path,
+ final String[] virtualHosts,
+ final URL resource,
+ final boolean extractWebArchive,
+ final Instantiator instantiator )
+ {
+ if( null == path || null == resource || null == instantiator )
+ {
+ throw new IllegalArgumentException( "A required argument was null." );
+ }
+ m_path = path;
+ m_resource = resource;
+ m_instantiator = instantiator;
+ m_virtualHosts = virtualHosts;
+ m_extractWebArchive = extractWebArchive;
+ }
+
+ /**
+ * Fetch the web path
+ */
+ public String getPath()
+ {
+ return m_path;
+ }
+
+ /**
+ * Fetch possible virtual hosts.
+ */
+ public String[] getVirtualHosts()
+ {
+ return m_virtualHosts;
+ }
+
+ /**
+ * Fetch the web app resource pointer.
+ */
+ public URL getResource()
+ {
+ return m_resource;
+ }
+
+ /**
+ * If the resource is a Web Archive, should it be extracted?
+ *
+ * @return true if the Container should extract the resource, else false
+ */
+ public boolean extractWebArchive()
+ {
+ return m_extractWebArchive;
+ }
+
+ /**
+ * Fetch the class instantiator.
+ */
+ public Instantiator getInstantiator()
+ {
+ return m_instantiator;
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file27" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl<br /></span>
<div class="fileheader" id="added"><big><b>DefaultListener.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DefaultListener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DefaultListener.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,66 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl;
+
+import org.codehaus.spice.jervlet.Listener;
+
+/**
+ * Default implementation of a Listener. A listener represents
+ * an object listening for new connections on a port, an address
+ * using some type of protocol.
+ *
+ * @author Johan Sjoberg
+ */
+public class DefaultListener implements Listener
+{
+ /** Host */
+ final String m_host;
+
+ /** Port */
+ final int m_port;
+
+ /** Listener type */
+ final int m_type;
+
+ public DefaultListener( String host, int port, int type )
+ {
+ m_host = host;
+ m_port = port;
+ m_type = type;
+ }
+ /**
+ * Fetch the port for this listener.
+ *
+ * @return The port number
+ */
+ public int getPort()
+ {
+ return m_port;
+ }
+
+ /**
+ * Fetch the host for this listener. The host value is optional.
+ * No host value means all hosts.
+ *
+ * @return The host address to listen to or null for all hosts
+ */
+ public String getHost()
+ {
+ return m_host;
+ }
+
+ /**
+ * Fetch the connection type.
+ *
+ * @return The type id if this connection.
+ */
+ public int getType()
+ {
+ return m_type;
+ }
+}
</pre></div>
<hr /><a name="file28" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl<br /></span>
<div class="fileheader" id="added"><big><b>NoopContextMonitor.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N NoopContextMonitor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ NoopContextMonitor.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,172 @@
</small></pre><pre class="diff" id="added">+package org.codehaus.spice.jervlet.impl;
+
+import org.codehaus.spice.jervlet.ContextException;
+import org.codehaus.spice.jervlet.ContextMonitor;
+import org.codehaus.spice.jervlet.Context;
+
+/**
+ * Context monitor doing absolutely nothing,
+ * but throwing exceptions.
+ *
+ * @author Johan Sjoberg
+ */
+public class NoopContextMonitor implements ContextMonitor
+{
+ /**
+ * Report that an Exception was thrown when adding a Context
+ *
+ * @param reportingClass Class reporting the error
+ * @param context Context that couldn't be added
+ * @param e Exception that was thrown
+ * @throws org.codehaus.spice.jervlet.ContextException
+ * A new exception describing the reported error
+ */
+ public void addContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException
+ {
+ throwContextException( e );
+ }
+
+ /**
+ * Report that an Exception was thrown when removing a Context
+ *
+ * @param reportingClass Class reporting the error
+ * @param context Context that couldn't be removed
+ * @param e Exception that was thrown
+ * @throws org.codehaus.spice.jervlet.ContextException
+ * A new exception describing the reported error
+ */
+ public void removeContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException
+ {
+ throwContextException( e );
+ }
+
+ /**
+ * Report that an Exception was thrown when starting a Context
+ *
+ * @param reportingClass Class reporting the error
+ * @param context Context that couldn't be started
+ * @param e Exception that was thrown
+ * @throws org.codehaus.spice.jervlet.ContextException
+ * A new exception describing the error
+ */
+ public void startContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException
+ {
+ throwContextException( e );
+ }
+
+ /**
+ * Report that an Exception was thrown when stopping a Context
+ *
+ * @param reportingClass Class reporting the error
+ * @param context Context that couldn't be stopped
+ * @param e Exception that was thrown
+ * @throws org.codehaus.spice.jervlet.ContextException
+ * A new exception decribing the error
+ */
+ public void stopContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException
+ {
+ throwContextException( e );
+ }
+
+ /**
+ * Report a warning about the addition of a Context
+ *
+ * @param reportingClass Class reporting the warning
+ * @param context Context the warning conserns
+ * @param message A message describing the warning
+ */
+ public void addContextWarning( Class reportingClass, Context context, String message )
+ {
+ }
+
+ /**
+ * Report a warning about the removal of a Context
+ *
+ * @param reportingClass Class reporting the warning
+ * @param context Context the warning conserns
+ * @param message A message describing the warning
+ */
+ public void removeContextWarning( Class reportingClass, Context context, String message )
+ {
+ }
+
+ /**
+ * Report a warning about starting a Context
+ *
+ * @param reportingClass Class reporting the warning
+ * @param context Context the warning conserns
+ * @param message A message describing the warning
+ */
+ public void startContextWarning( Class reportingClass, Context context, String message )
+ {
+ }
+
+ /**
+ * Report a warning about stopping a Context
+ *
+ * @param reportingClass Class reporting the warning
+ * @param context Context the warning conserns
+ * @param message A message describing the warning
+ */
+ public void stopContextWarning( Class reportingClass, Context context, String message )
+ {
+ }
+
+ /**
+ * Report that a Context was added
+ *
+ * @param reportingClass Class reporting the additon
+ * @param context Context that was added
+ */
+ public void addContextNotification( Class reportingClass, Context context )
+ {
+ }
+
+ /**
+ * Report that a Context was removed
+ *
+ * @param reportingClass Class reporting the removal
+ * @param context Context that was removed
+ */
+ public void removeContextNotification( Class reportingClass, Context context )
+ {
+ }
+
+ /**
+ * Report that a Context was started
+ *
+ * @param reportingClass Reporting class
+ * @param context Context that was started
+ */
+ public void startContextNotification( Class reportingClass, Context context )
+ {
+ }
+
+ /**
+ * Report that a Context was stopped
+ *
+ * @param reportingClass Reporting class
+ * @param context Context that was stopped
+ */
+ public void stopContextNotification( Class reportingClass, Context context )
+ {
+ }
+
+ /**
+ * Throw a <code>ContextException</code>
+ *
+ * @param e Original Exception
+ * @throws ContextException A new ListenerException instance
+ */
+ private void throwContextException( Exception e )
+ throws ContextException
+ {
+ ContextException contextException =
+ new ContextException( e.getMessage(), e.getCause() );
+ throw contextException;
+ }
+}
</pre></div>
<hr /><a name="file29" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl<br /></span>
<div class="fileheader" id="added"><big><b>NoopListenerMonitor.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N NoopListenerMonitor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ NoopListenerMonitor.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,168 @@
</small></pre><pre class="diff" id="added">+package org.codehaus.spice.jervlet.impl;
+
+import org.codehaus.spice.jervlet.ListenerMonitor;
+import org.codehaus.spice.jervlet.Listener;
+import org.codehaus.spice.jervlet.ListenerException;
+
+/**
+ * Listener monitor doing absolutely nothing,
+ * but throwing exceptions.
+ *
+ * @author Johan Sjoberg
+ */
+public class NoopListenerMonitor implements ListenerMonitor
+{
+ /**
+ * Notify that an Exception was thrown when adding a Listener.
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be started
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException representing the reported error
+ */
+ public void addListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException
+ {
+ throwListenerException( e );
+ }
+
+ /**
+ * Notify that an Exception was thrown when removing a Listener.
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be started
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException representing the reported error
+ */
+ public void removeListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException
+ {
+ throwListenerException( e );
+ }
+
+ /**
+ * Report a warning about adding a listener
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ public void addListenerWarning( Class reportingClass, Listener listener, String message )
+ {
+ }
+
+ /**
+ * Report a warning about removing a listener
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ public void removeListenerWarning( Class reportingClass, Listener listener, String message )
+ {
+ }
+
+ /**
+ * Report that a listener has been added
+ *
+ * @param reportingClass The class reporting the listener start event
+ * @param listener The listener that was started
+ */
+ public void addListenerNotification( Class reportingClass, Listener listener )
+ {
+ }
+
+ /**
+ * Report that a listner has been removed
+ *
+ * @param reportingClass The class reporting the listener stop event
+ * @param listener The listener that was stopped
+ */
+ public void removeListenerNotification( Class reportingClass, Listener listener )
+ {
+ }
+
+ /**
+ * Notify that an Exception was thrown when starting a Listener.
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be started
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException representing the reported error
+ */
+ public void startListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException
+ {
+ throwListenerException( e );
+ }
+
+ /**
+ * Notify that an Exception was thrown when stopping a Listener.
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be stopped
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException representing the reported error
+ */
+ public void stopListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException
+ {
+ throwListenerException( e );
+ }
+
+ /**
+ * Report a warning about starting a listener
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ public void startListenerWarning( Class reportingClass, Listener listener, String message )
+ {
+ }
+
+ /**
+ * Report a warning about stopping a listener
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ public void stopListenerWarning( Class reportingClass, Listener listener, String message )
+ {
+ }
+
+ /**
+ * Report that a listener has been started
+ *
+ * @param reportingClass The class reporting the listener start event
+ * @param listner The listener that was started
+ */
+ public void startListenerNotification( Class reportingClass, Listener listner )
+ {
+ }
+
+ /**
+ * Report that a listner has been stopped
+ *
+ * @param reportingClass The class reporting the listener stop event
+ * @param listener The listener that was stopped
+ */
+ public void stopListenerNotification( Class reportingClass, Listener listener )
+ {
+ }
+
+ /**
+ * Throw a <code>ListenerException</code>
+ *
+ * @param e Original Exception
+ * @throws ListenerException A new ListenerException instance
+ */
+ private void throwListenerException( Exception e )
+ throws ListenerException
+ {
+ ListenerException listenerException =
+ new ListenerException( e.getMessage(), e.getCause() );
+ throw listenerException;
+ }
+}
</pre></div>
<hr /><a name="file30" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl<br /></span>
<div class="fileheader" id="added"><big><b>StandardServletInstantiator.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N StandardServletInstantiator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ StandardServletInstantiator.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,35 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl;
+
+import org.codehaus.spice.jervlet.Instantiator;
+
+/**
+ * Standard class instantiator. This instantiator just creates a
+ * new instance of the Servlet or Filter class. No lifecycle
+ * interfaces will be called, so using this instantiator is the
+ * same as deploying servlets in a standatd servlet container.
+ *
+ * @author Johan Sjoberg
+ */
+public class StandardServletInstantiator implements Instantiator
+{
+ /**
+ * Create a new instance of a Servlet or Filter class.
+ *
+ * @param clazz The calss to instantiate
+ * @return A new instance of the given class
+ * @throws InstantiationException If the class couldn't ne instantiated
+ * @throws IllegalAccessException If an access problem occured
+ */
+ public Object instantiate( Class clazz )
+ throws InstantiationException, IllegalAccessException
+ {
+ return clazz.newInstance();
+ }
+}
</pre></div>
<hr /><a name="file31" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/tools/isolate<br /></span>
<div class="fileheader" id="added"><big><b>DemuxProperties.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DemuxProperties.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DemuxProperties.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,240 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+/*
+ * This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/).
+ */
+package org.codehaus.spice.jervlet.tools.isolate;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.Properties;
+
+/**
+ * Access to this Properties object is forwarded to a properties
+ * object that has been associated with this thread.
+ *
+ * @author Peter Donald
+ * @author Johan Sjoberg
+ */
+public final class DemuxProperties extends Properties
+{
+ /** The properties objects associated with each thread. */
+ private final InheritableThreadLocal m_properties =
+ new InheritableThreadLocal();
+
+ /**
+ * Crate a new DemuxProperties instance
+ *
+ * @param defaults Default properties
+ */
+ public DemuxProperties( final Properties defaults )
+ {
+ super( defaults );
+ }
+
+ /**
+ * Bind the specified Properties object to the current thread.
+ *
+ * @param properties the Properties object to bind
+ */
+ public Properties bindProperties( final Properties properties )
+ {
+ final Properties oldProperties = (Properties)m_properties.get();
+ m_properties.set( properties );
+ return oldProperties;
+ }
+
+ /**
+ * Fetch a property
+ *
+ * @param key The key to search for
+ * @return A value for the given key, or <code>null</null>
+ * if none existed.
+ */
+ public Object get( final Object key )
+ {
+ return getProperties().get( key );
+ }
+
+ /**
+ * Store a property
+ *
+ * @param key The key to be placed into this property list.
+ * @param value The corresponding value to <code>key</code>.
+ * @return The previous value of the specified key in this
+ * property list, or <code>null</code> if it did not
+ * have one.
+ */
+ public Object put( final Object key,
+ final Object value )
+ {
+ return getProperties().put( key, value );
+ }
+
+ /**
+ * Remove a key-value mapping.
+ *
+ * @param key The key of the key-value mapping to remove.
+ * @return The value to which the key had been mapped to,
+ * or null if the key did not have a mapping.
+ */
+ public Object remove( final Object key )
+ {
+ return getProperties().remove( key );
+ }
+
+ /**
+ * Fetch the size, meaning the number of stored mappings.
+ *
+ * @return Number of mappings
+ */
+ public final int size()
+ {
+ return getProperties().size();
+ }
+
+ /**
+ * Check if the properties is empty.
+ *
+ * @return true if no mappings have been stored, else false
+ */
+ public final boolean isEmpty()
+ {
+ return getProperties().isEmpty();
+ }
+
+ /**
+ * Fetch all keys
+ *
+ * @return Enumeration of stored keys
+ */
+ public Enumeration keys()
+ {
+ return getProperties().keys();
+ }
+
+ /**
+ * Fetch all values
+ *
+ * @return Enumeration of values
+ */
+ public Enumeration elements()
+ {
+ return getProperties().keys();
+ }
+
+ /**
+ * Check if a value already exists.
+ *
+ * @param value The value
+ * @return true if <code>value</code> existed, else false
+ */
+ public boolean contains( final Object value )
+ {
+ return getProperties().contains( value );
+ }
+
+ /**
+ * Check if a key exists
+ *
+ * @param key The key
+ * @return true if <code>key</code> existed, else false
+ */
+ public boolean containsKey( final Object key )
+ {
+ return getProperties().containsKey( key );
+ }
+
+ /**
+ * Clear out all key-value mapping in this properties object.
+ */
+ public void clear()
+ {
+ getProperties().clear();
+ }
+
+ /**
+ * Create a copy of this properties object.
+ *
+ * @return A new identical properties object as this
+ */
+ public Object clone()
+ {
+ return getProperties().clone();
+ }
+
+ /**
+ * Create a <code>String</code> representation of this
+ * properties object.
+ *
+ * @return A string
+ */
+ public String toString()
+ {
+ return getProperties().toString();
+ }
+
+ /**
+ * Fetch a property
+ *
+ * @param key The key to search for
+ * @return A property corresponding to <code>key</code>
+ */
+ public final String getProperty( final String key )
+ {
+ return getProperties().getProperty( key );
+ }
+
+ /**
+ * Fetch all property names.
+ *
+ * @return Enumeration of property names
+ */
+ public final Enumeration propertyNames()
+ {
+ return getProperties().propertyNames();
+ }
+
+ /**
+ * Print this property list out to the specified output stream.
+ *
+ * @param out PrintStream to write to.
+ */
+ public final void list( final PrintStream out )
+ {
+ getProperties().list( out );
+ }
+
+ /**
+ * Print this property list out to the specified output stream.
+ *
+ * @param out PrintWriter to write to.
+ */
+ public final void list( final PrintWriter out )
+ {
+ getProperties().list( out );
+ }
+
+ /**
+ * Utility method to retrieve properties bound to current thread (if any).
+ */
+ private Properties getProperties()
+ {
+ final Properties properties = (Properties)m_properties.get();
+ if( null != properties )
+ {
+ return properties;
+ }
+ else
+ {
+ return defaults;
+ }
+ }
+}
</pre></div>
<hr /><a name="file32" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/tools/isolate<br /></span>
<div class="fileheader" id="added"><big><b>SysPropertiesRedirector.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N SysPropertiesRedirector.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SysPropertiesRedirector.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,115 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+/*
+ * This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/).
+ */
+package org.codehaus.spice.jervlet.tools.isolate;
+
+import java.util.Properties;
+
+/**
+ * This is a utility class making it easy to install redirecting
+ * Properties objects for the underlying System.getProeprties()
+ * object. The properties object will redirect to the properties
+ * object that is associated with the current thread. A properties
+ * object becomes associated with the current thread when a user
+ * calls one of the bind*() methods or by inheriting the parent
+ * threads properties object when thread is initially created. The
+ * default streams will redirect to the default System properties.
+ *
+ * @author Peter Donald
+ * @author Johan Sjoberg
+ */
+public final class SysPropertiesRedirector
+{
+ private static final String NOT_INSTALLED_ERROR =
+ "SysPropertiesRedirector not installed";
+
+ /**
+ * Cached version of original System Properties.
+ * (Or at least the properties that were installed in JVM
+ * when this class is loaded and resovled).
+ */
+ private static final Properties c_systemProperties =
+ System.getProperties();
+
+ private static DemuxProperties c_properties;
+
+ /**
+ * Private constructor to block instantiation.
+ */
+ private SysPropertiesRedirector()
+ {
+ }
+
+ /**
+ * Install the redirecting Properties object.
+ *
+ * @return true if installed, false if already installed
+ */
+ public synchronized static boolean install()
+ {
+ if( c_properties == System.getProperties() )
+ {
+ //Already installed so lets ignore
+ return false;
+ }
+ c_properties = new DemuxProperties( c_systemProperties );
+ System.setProperties( c_properties );
+ return true;
+ }
+
+ /**
+ * Uninstall the redirecting streams and replace them with
+ * streams that point to FileDescriptor.in, FileDescriptor.out
+ * and FileDescriptor.err.
+ *
+ * @return true if uninstalled, false if already uninstalled
+ */
+ public synchronized static boolean uninstall()
+ {
+ if( c_properties != System.getProperties() )
+ {
+ //Already uninstalled so lets ignore
+ return false;
+ }
+ c_properties = null;
+ System.setProperties( c_systemProperties );
+ return true;
+ }
+
+ /**
+ * Bind the specified Properties object to this thread.
+ *
+ * @param properties the stream to bind
+ * @throws NullPointerException if the given Properties object was null
+ * @throws SecurityException if don't have permission to bind to input
+ * @throws IllegalStateException if redirector not installed
+ */
+ public static Properties bindProperties( final Properties properties )
+ throws SecurityException, IllegalStateException
+ {
+ if( null == properties )
+ {
+ throw new NullPointerException( "properties" );
+ }
+ if( null == c_properties )
+ {
+ throw new IllegalStateException( NOT_INSTALLED_ERROR );
+ }
+ final SecurityManager manager = System.getSecurityManager();
+ if( null != manager )
+ {
+ final RuntimePermission permission =
+ new RuntimePermission( "SysPropertiesRedirector.setProperties" );
+ manager.checkPermission( permission );
+ }
+ return c_properties.bindProperties( properties );
+ }
+}
</pre></div>
<hr /><a name="file33" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader" id="added"><big><b>Container.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N Container.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Container.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,51 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet;
+
+/**
+ * The <code>Container</code> interface represents a servlet container.
+ * In Jervlet the container has only two functions, to create and
+ * destroy <code>ContextHandler</code>s. The context handlers are used
+ * to manage contexts.
+ * <br/><br/>
+ * The idea behind this interface is to shield web applications from other
+ * components in the system, using the same container (read web server). A
+ * context can only be managed through the <code>ContextManager</code>
+ * that created it.
+ * <br/><br/>
+ * A container implementation representing a HTTP server/servlet container
+ * would normally implement the <code>Container</code> and
+ * <code>ListenerHandler</code> interfaces. In a system where all
+ * components can access all contexts noting says that the container
+ * implementation can't directly implement <code>ContextHandler</code> too,
+ * for an unshielded context manager.
+ *
+ * @author Johan Sjoberg
+ * @author Peter Royal
+ */
+public interface Container
+{
+ String ROLE = Container.class.getName();
+
+ /**
+ * Create a new context handler.
+ *
+ * @return A new ContextHandler.
+ */
+ ContextHandler createContextHandler();
+
+ /**
+ * Destroy a context handler. If the given context
+ * handler still has contexts, they will be stopped
+ * and removed before destruction.
+ *
+ * @param contextHandler The ContextHandler to destroy
+ */
+ void destroyContextHandler( ContextHandler contextHandler );
<a name="task8" />+ //<span class="task">TODO</span>: Verify that this method is really needed, perhaps just as a convenience...
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file34" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader" id="added"><big><b>Context.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N Context.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Context.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,64 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet;
+
+import java.net.URL;
+
+/**
+ * The <code>Context</code> interface represents a web context. A web
+ * context holds information about a web application. This includes
+ * e.g. the path, possible virtual hosts and a pointer to the resource.
+ *
+ * @author Johan Sjoberg
+ * @author Peter Royal
+ */
+public interface Context
+{
+ /** Role, used by some component frameworks */
+ String ROLE = Context.class.getName();
+
+ /**
+ * Fetch the path of the web application, e.g. "/myapp".
+ *
+ * @return The path of the web appliaction
+ */
+ String getPath();
+
+ /**
+ * Fetch possible virtual hosts defined for this context. As
+ * virtual hosts are optional for web contexts the returned list
+ * can be empty.
+ *
+ * @return A new list of the virtual hosts for this context.
+ */
+ String[] getVirtualHosts();
+
+ /**
+ * Fetch the resource for this context. A resource is a pointer
+ * to the web archive. A web archive is usually a .war file or a
+ * directory including the exploded WAR.
+ *
+ * @return The resource URL to the web application
+ */
+ URL getResource();
+
+ /**
+ * If the resource is a Web Archive, should it be extracted?
+ *
+ * @return true if the Container should extract the resource, else false
+ */
+ boolean extractWebArchive();
+
+ /**
+ * Fetch the <code>Instantiator</code> that should be used to instantiate
+ * the servlet classes in this context.
+ *
+ * @return A reference to this context's instantiator implementation.
+ */
+ Instantiator getInstantiator();
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file35" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader" id="added"><big><b>ContextException.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ContextException.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ContextException.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,53 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet;
+
+/**
+ * Exception class to be used when handling contexts
+ *
+ * @author Johan Sjoberg
+ */
+public class ContextException extends Exception
+{
+ /** The original <code>Throwable</code> */
+ private final Throwable m_throwable;
+
+ /**
+ * Create a new <code>ContextException</code>.
+ *
+ * @param message Explanation for this exception.
+ */
+ public ContextException( final String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Create a new <code>ContextException</code>.
+ *
+ * @param message Explanation for this exception.
+ * @param throwable The original throwable that caused
+ * this exception. Give null if none exist.
+ */
+ public ContextException( final String message, final Throwable throwable )
+ {
+ super( message );
+ m_throwable = throwable;
+ }
+
+ /**
+ * Retrieve the original throwable that caused this
+ * deployment exception.
+ *
+ * @return The original throwable or null if none exist.
+ */
+ public final Throwable getCause()
+ {
+ return m_throwable;
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file36" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader" id="added"><big><b>ContextHandler.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ContextHandler.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ContextHandler.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,71 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet;
+
+import java.util.List;
+
+/**
+ * A <code>ContexHandler</code> manages contexts in the system.
+ * Supported functions are addition, removal, listing, starting
+ * and stopping of <code>Contexts</code>.
+ *
+ * @author Johan Sjoberg
+ * @author Peter Royal
+ */
+public interface ContextHandler
+{
+ /** Role, used by some component frameworks */
+ String ROLE = ContextHandler.class.getName();
+
+ /**
+ * Add a context to the container.
+ *
+ * @param context The context to add
+ */
+ void addContext( Context context );
+
+ /**
+ * Remove a context from the container.
+ *
+ * @param context The context to remove
+ */
+ void removeContext( Context context );
+
+ /**
+ * Start a context.
+ *
+ * @param context The context to start
+ * @throws ContextException if the contex couldn't be started
+ */
+ void startContext( Context context ) throws ContextException;
+
+ /**
+ * Stop a context.
+ *
+ * @param context The context to stop
+ * @throws ContextException if the contex couldn't be stopped
+ */
+ void stopContext( Context context ) throws ContextException;
+
+ /**
+ * List the <code>Context</code>s that this <code>ContextHandler</code>
+ * can manage.
+ *
+ * @return A new list of contexts holding all JervletContexts
+ */
+ List getContexts();
+
+ /**
+ * Check if <code>Context</context> owned by this handler
+ * is started on not.
+ *
+ * @param context The context to check
+ * @return true if the given context is started, else false
+ */
+ boolean isStarted( Context context );
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file37" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader" id="added"><big><b>ContextMonitor.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ContextMonitor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ContextMonitor.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,130 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet;
+
+/**
+ * Context monitor
+ * <br/><br/>
+ * This interface defines possible monitor events from Contexts.
+ *
+ * @author Johan Sjoberg
+ */
+public interface ContextMonitor
+{
+ /**
+ * Report that an Exception was thrown when adding a Context
+ *
+ * @param reportingClass Class reporting the error
+ * @param context Context that couldn't be added
+ * @param e Exception that was thrown
+ * @throws ContextException A new exception describing the reported error
+ */
+ void addContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException;
+
+ /**
+ * Report that an Exception was thrown when removing a Context
+ *
+ * @param reportingClass Class reporting the error
+ * @param context Context that couldn't be removed
+ * @param e Exception that was thrown
+ * @throws ContextException A new exception describing the reported error
+ */
+ void removeContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException;
+
+ /**
+ * Report that an Exception was thrown when starting a Context
+ *
+ * @param reportingClass Class reporting the error
+ * @param context Context that couldn't be started
+ * @param e Exception that was thrown
+ * @throws ContextException A new exception describing the error
+ */
+ void startContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException;
+
+ /**
+ * Report that an Exception was thrown when stopping a Context
+ *
+ * @param reportingClass Class reporting the error
+ * @param context Context that couldn't be stopped
+ * @param e Exception that was thrown
+ * @throws ContextException A new exception decribing the error
+ */
+ void stopContextException( Class reportingClass, Context context, Exception e )
+ throws ContextException;
+
+ /**
+ * Report a warning about the addition of a Context
+ *
+ * @param reportingClass Class reporting the warning
+ * @param context Context the warning conserns
+ * @param message A message describing the warning
+ */
+ void addContextWarning( Class reportingClass, Context context, String message );
+
+ /**
+ * Report a warning about the removal of a Context
+ *
+ * @param reportingClass Class reporting the warning
+ * @param context Context the warning conserns
+ * @param message A message describing the warning
+ */
+ void removeContextWarning( Class reportingClass, Context context, String message );
+
+ /**
+ * Report a warning about starting a Context
+ *
+ * @param reportingClass Class reporting the warning
+ * @param context Context the warning conserns
+ * @param message A message describing the warning
+ */
+ void startContextWarning( Class reportingClass, Context context, String message );
+
+ /**
+ * Report a warning about stopping a Context
+ *
+ * @param reportingClass Class reporting the warning
+ * @param context Context the warning conserns
+ * @param message A message describing the warning
+ */
+ void stopContextWarning( Class reportingClass, Context context, String message );
+
+ /**
+ * Report that a Context was added
+ *
+ * @param reportingClass Class reporting the additon
+ * @param context Context that was added
+ */
+ void addContextNotification( Class reportingClass, Context context );
+
+ /**
+ * Report that a Context was removed
+ *
+ * @param reportingClass Class reporting the removal
+ * @param context Context that was removed
+ */
+ void removeContextNotification( Class reportingClass, Context context );
+
+ /**
+ * Report that a Context was started
+ *
+ * @param reportingClass Reporting class
+ * @param context Context that was started
+ */
+ void startContextNotification( Class reportingClass, Context context );
+
+ /**
+ * Report that a Context was stopped
+ *
+ * @param reportingClass Reporting class
+ * @param context Context that was stopped
+ */
+ void stopContextNotification( Class reportingClass, Context context );
+}
</pre></div>
<hr /><a name="file38" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader" id="added"><big><b>Instantiator.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N Instantiator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Instantiator.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,35 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet;
+
+/**
+ * An <code>Instantiator</code> is responsible for instantiating
+ * <a href="http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/Servlet.html">Servlet</a>
+ * and
+ * <a href="http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/Filter.html">Filter</a>
+ * clsses on behalf of a servlet container.
+ *
+ * @author Paul Hammant
+ * @author Johan Sjoberg
+ * @author Peter Royal
+ */
+public interface Instantiator
+{
+ /** Role, used by some component frameworks */
+ String ROLE = Instantiator.class.getName();
+
+ /**
+ * Instantiate a servlet or filter class.
+ *
+ * @param clazz The servlet of filter class to instantiate
+ * @return The instatiated class
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ Object instantiate( Class clazz ) throws InstantiationException, IllegalAccessException;
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file39" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader" id="added"><big><b>Listener.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N Listener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Listener.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,53 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet;
+
+/**
+ * The Listener interface repesents some type of litener that passes
+ * requests to a servlet container. Listeners are managed by a
+ * <code>ListenerHandler</code>.
+ *
+ * @author Johan Sjoberg
+ * @author Peter Royal
+ */
+public interface Listener
+{
+ /** Role, used by some component frameworks */
+ String ROLE = Listener.class.getName();
+
+ /** HTTP listener */
+ static final int HTTP = 1;
+
+ /** SSL and TSL listener */
+ static final int TSL = 2;
+
+ /** AJP 1.3 listener */
+ static final int AJP13 = 3;
+
+ /**
+ * Fetch the port for this listener.
+ *
+ * @return The port number
+ */
+ int getPort();
+
+ /**
+ * Fetch the host for this listener. The host value is optional.
+ * No host value means all hosts.
+ *
+ * @return The host address to listen to or null for all hosts
+ */
+ String getHost();
+
+ /**
+ * Fetch the connection type.
+ *
+ * @return The type id if this connection.
+ */
+ int getType();
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file40" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader" id="added"><big><b>ListenerException.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ListenerException.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ListenerException.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,53 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet;
+
+/**
+ * Exception class to be used when handling listeners
+ *
+ * @author Johan Sjoberg
+ */
+public class ListenerException extends Exception
+{
+ /** The original <code>Throwable</code> */
+ private final Throwable m_throwable;
+
+ /**
+ * Create a new <code>ContextException</code>.
+ *
+ * @param message Explanation for this exception.
+ */
+ public ListenerException( final String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Create a new <code>ContextException</code>.
+ *
+ * @param message Explanation for this exception.
+ * @param throwable The original throwable that caused
+ * this exception. Give null if none exist.
+ */
+ public ListenerException( final String message, final Throwable throwable )
+ {
+ super( message );
+ m_throwable = throwable;
+ }
+
+ /**
+ * Retrieve the original throwable that caused this
+ * deployment exception.
+ *
+ * @return The original throwable or null if none exist.
+ */
+ public final Throwable getCause()
+ {
+ return m_throwable;
+ }
+}
</pre></div>
<hr /><a name="file41" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader" id="added"><big><b>ListenerHandler.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ListenerHandler.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ListenerHandler.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,58 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet;
+
+import java.util.List;
+
+/**
+ * A <code>ListenerHandler</code> handles <code>Listener</code>s.
+ *
+ * @author Johan Sjoberg
+ * @author Peter Royal
+ */
+public interface ListenerHandler
+{
+ /** Role, used in some component frameworks */
+ String ROLE = ListenerHandler.class.getName();
+
+ /**
+ * Add a <code>Listener</code> the container.
+ */
+ void addListener( Listener listener ) throws ListenerException;
+
+ /**
+ * Remove a <code>Listener</code> from the container.
+ */
+ void removeListener( Listener listener ) throws ListenerException;
+
+ /**
+ * Start a <code>Listener</code>.
+ */
+ void startListener( Listener listener ) throws ListenerException;
+
+ /**
+ * Stop a <code>Listener</code>.
+ */
+ void stopListener( Listener listener ) throws ListenerException;
+
+ /**
+ * Fetch a list of all current <code>Listener</code>s. If there are
+ * no listener the returned list can be empty.
+ *
+ * @return All new list all current listeners.
+ */
+ List getListeners();
+
+ /**
+ * Check if a <code>Listener</code> is started or not.
+ *
+ * @param listener The listener
+ * @return True if the listener is started, else false.
+ */
+ boolean isStarted( Listener listener );
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file42" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader" id="added"><big><b>ListenerMonitor.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ListenerMonitor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ListenerMonitor.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,134 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet;
+
+/**
+ * Listener monitor
+ * <br/><br/>
+ * This interface defines possible monitor events form a Listener.
+ *
+ * @author Johan Sjoberg
+ */
+public interface ListenerMonitor
+{
+ /**
+ * Notify that an Exception was thrown when adding a Listener.
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be started
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException
+ * representing the reported error
+ */
+ void addListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException;
+
+ /**
+ * Notify that an Exception was thrown when removing a Listener.
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be started
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException
+ * representing the reported error
+ */
+ void removeListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException;
+
+ /**
+ * Report a warning about adding a listener
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ void addListenerWarning( Class reportingClass, Listener listener, String message );
+
+ /**
+ * Report a warning about removing a listener
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ void removeListenerWarning( Class reportingClass, Listener listener, String message );
+
+ /**
+ * Report that a listener has been added
+ *
+ * @param reportingClass The class reporting the listener start event
+ * @param listener The listener that was started
+ */
+ void addListenerNotification( Class reportingClass, Listener listener );
+
+ /**
+ * Report that a listner has been removed
+ *
+ * @param reportingClass The class reporting the listener stop event
+ * @param listener The listener that was stopped
+ */
+ void removeListenerNotification( Class reportingClass, Listener listener );
+
+ /**
+ * Notify that an Exception was thrown when starting a Listener.
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be started
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException
+ * representing the reported error
+ */
+ void startListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException;
+
+ /**
+ * Notify that an Exception was thrown when stopping a Listener.
+ *
+ * @param reportingClass The class reporting the exception
+ * @param listener The listener that qouldn't be stopped
+ * @param e The exception that was thrown
+ * @throws ListenerException A newly created ListenerException
+ * representing the reported error
+ */
+ void stopListenerException( Class reportingClass, Listener listener, Exception e )
+ throws ListenerException;
+
+ /**
+ * Report a warning about starting a listener
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ void startListenerWarning( Class reportingClass, Listener listener, String message );
+
+ /**
+ * Report a warning about stopping a listener
+ *
+ * @param reportingClass The calass reporting the warning
+ * @param listener Listener the warning concerns
+ * @param message A message describing the warning
+ */
+ void stopListenerWarning( Class reportingClass, Listener listener, String message );
+
+ /**
+ * Report that a listener has been started
+ *
+ * @param reportingClass The class reporting the listener start event
+ * @param listener The listener that was started
+ */
+ void startListenerNotification( Class reportingClass, Listener listener );
+
+ /**
+ * Report that a listner has been stopped
+ *
+ * @param reportingClass The class reporting the listener stop event
+ * @param listener The listener that was stopped
+ */
+ void stopListenerNotification( Class reportingClass, Listener listener );
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file43" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/containers/jetty/avalon<br /></span>
<div class="fileheader" id="added"><big><b>AvalonJettyContainerTestCase.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N AvalonJettyContainerTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AvalonJettyContainerTestCase.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,134 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.containers.jetty.avalon;
+
+import junit.framework.TestCase;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.avalon.framework.logger.ConsoleLogger;
+
+import java.util.Properties;
+import java.util.Enumeration;
+
+/**
+ * TestCase for JettyContainerComponent
+ *
+ * @author Johan Sjoberg
+ */
+public class AvalonJettyContainerTestCase extends TestCase
+{
+ private static final String m_defaultConfiguration =
+ "./testdata/jetty/jetty.xml";
+
+ /**
+ * Create an empty container and start/stop it.
+ *
+ * @throws Exception
+ */
+ public void testEmpty() throws Exception
+ {
+ AvalonJettyContainer container =
+ getContainer( new DefaultConfiguration( "", "" ) );
+ container.start();
+ container.stop();
+ }
+
+ /**
+ * Create a container with the default configuration and
+ * start/stop it.
+ *
+ * @throws Exception
+ */
+ public void testDefaultConfigurationFile() throws Exception
+ {
+ AvalonJettyContainer container =
+ getContainer( getStringConfiguration( m_defaultConfiguration ) );
+ container.start();
+ container.stop();
+ }
+
+ /**
+ * Create a container with one property (jetty.port) and
+ * start/stop it.
+ *
+ * @throws Exception
+ */
+ public void testProperties() throws Exception
+ {
+ Properties properties = new Properties();
+ properties.setProperty( "jetty.port", "8421" );
+ AvalonJettyContainer container =
+ getContainer( getPropertiesConfiguration( m_defaultConfiguration, properties ) );
+ container.start();
+ container.stop();
+ }
+
+ /**
+ * Fetch a container by giving a configuration.
+ *
+ * @param configuration configuration for the continer
+ * @return an initialized AvalonJettyContainer
+ * @throws Exception on all errors
+ */
+ private AvalonJettyContainer getContainer( Configuration configuration )
+ throws Exception
+ {
+ AvalonJettyContainer avalonJettyContainer = new AvalonJettyContainer();
+ avalonJettyContainer.enableLogging( new ConsoleLogger() );
+ avalonJettyContainer.configure( configuration );
+ avalonJettyContainer.initialize();
+ return avalonJettyContainer;
+ }
+
+
+ /**
+ * Create a configuraion including Jetty system properties
+ *
+ * @param jettyConfigurationFile path to Jetty's configuration file
+ * @param properties the properties to add to the configuration
+ * @return a new configuration object
+ */
+ private Configuration getPropertiesConfiguration( String jettyConfigurationFile,
+ Properties properties )
+ {
+ DefaultConfiguration configuration = (DefaultConfiguration)
+ getStringConfiguration( jettyConfigurationFile );
+ DefaultConfiguration propertiesConfiguration =
+ new DefaultConfiguration( "jetty-system-properties", "" );
+ for( Enumeration propertyNames = properties.propertyNames();
+ propertyNames.hasMoreElements(); )
+ {
+ String key = (String)propertyNames.nextElement();
+ String value = properties.getProperty( key );
+ System.out.println( "Setting property [" + key + "=" + value + "].");
+ DefaultConfiguration propertyConfiguration =
+ new DefaultConfiguration( "property", "" );
+ propertyConfiguration.setAttribute( "key", key );
+ propertyConfiguration.setAttribute( "value", value );
+ propertiesConfiguration.addChild( propertyConfiguration );
+ }
+ configuration.addChild( propertiesConfiguration );
+ return configuration;
+ }
+
+ /**
+ * Create a configuration using a Jetty configuration file
+ *
+ * @param jettyConfigurationFile path to Jetty's configuration file
+ * @return a new configuration object
+ */
+ private Configuration getStringConfiguration( String jettyConfigurationFile )
+ {
+ DefaultConfiguration configuration = new DefaultConfiguration( "", "" );
+ DefaultConfiguration configurationFile =
+ new DefaultConfiguration( "jetty-configuration-file", "" );
+ configurationFile.setValue( jettyConfigurationFile );
+ configuration.addChild( configurationFile );
+ return configuration;
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file44" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader" id="added"><big><b>ShieldingJettyContainerTestCase.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ShieldingJettyContainerTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ShieldingJettyContainerTestCase.java 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,69 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.containers.jetty;
+
+import junit.framework.TestCase;
+
+import java.util.Properties;
+
+/**
+ * TestCase for ShieldingJettyContainer
+ *
+ * @author Johan Sjoberg
+ */
+public class ShieldingJettyContainerTestCase extends TestCase
+{
+ private static final String DEFAULT_CONFIGURATION = "./testdata/jetty/jetty.xml";
+
+ /**
+ * Test a dafault plain Jetty, no conf but with the
+ * shielding turned on.
+ *
+ * @throws Exception on all errors
+ */
+ public void testCreationNoConf() throws Exception
+ {
+ ShieldingJettyContainer container = new ShieldingJettyContainer();
+ container.initialize();
+ container.start();
+ container.stop();
+ }
+
+ /**
+ * Test jetty with default configuration, shielded,
+ * but no parameters.
+ *
+ * @throws Exception on all errors
+ */
+ public void testCreationDefaultConfiguration() throws Exception
+ {
+ ShieldingJettyContainer container = new ShieldingJettyContainer();
+ container.setJettyConfiguration( DEFAULT_CONFIGURATION );
+ container.initialize();
+ container.start();
+ container.stop();
+ }
+
+ /**
+ * Test jetty with default configuration, shielded and
+ * with one (overriding) parameter.
+ *
+ * @throws Exception on all errors
+ */
+ public void testCreationDefaultConfigurationOneParameter() throws Exception
+ {
+ ShieldingJettyContainer container = new ShieldingJettyContainer();
+ container.setJettyConfiguration( DEFAULT_CONFIGURATION );
+ Properties properties = new Properties();
+ properties.setProperty( "jetty.port", "10081" );
+ container.addJettyProperties( properties );
+ container.initialize();
+ container.start();
+ container.stop();
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file49" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/testdata/jetty<br /></span>
<div class="fileheader" id="added"><big><b>jetty.xml</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N jetty.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ jetty.xml 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,216 @@
</small></pre><pre class="diff" id="added">+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
+
+
+
+<!-- =============================================================== -->
+<!-- Configure the Jetty Server -->
+<!-- =============================================================== -->
+<Configure class="org.mortbay.jetty.Server">
+
+ <!-- =============================================================== -->
+ <!-- Configure Logging -->
+ <!-- =============================================================== -->
+
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Configure Jetty Logging. -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Uncomment if using jetty logging.
+ <Call class="org.apache.commons.logging.LogFactory" name="getFactory">
+ <Call name="getInstance">
+ <Arg/>
+ <Call name="reset"/>
+ <Call name="add">
+ <Arg>
+ <New class="org.mortbay.log.OutputStreamLogSink">
+ <Set name="filename"><SystemProperty name="jetty.home" default="."/>/logs/yyyy_mm_dd.jetty.log</Set>
+ <Set name="retainDays">90</Set>
+ <Set name="append">true</Set>
+ <Set name="logLabels">true</Set>
+ <Set name="logStackSize">true</Set>
+ <Set name="logStackTrace">false</Set>
+ <Set name="logOneLine">false</Set>
+ <Set name="suppressStack">false</Set>
+ <Set name="logTimeZone">GMT</Set>
+ </New>
+ </Arg>
+ </Call>
+ </Call>
+ </Call>
+ -->
+
+ <!-- =============================================================== -->
+ <!-- Configure the Request Listeners -->
+ <!-- =============================================================== -->
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Add and configure a HTTP listener to port 10080 -->
+ <!-- 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="10080"/></Set>
+ <Set name="PoolName">P1</Set>
+ <Set name="MinThreads">10</Set>
+ <Set name="MaxThreads">200</Set>
+ <Set name="MaxIdleTimeMs">30000</Set>
+ <Set name="lowResources">50</Set>
+ <Set name="LowResourcePersistTimeMs">2000</Set>
+ <Set name="acceptQueueSize">0</Set>
+ <Set name="ConfidentialPort">8443</Set>
+ <Set name="IntegralPort">8443</Set>
+ </New>
+ </Arg>
+ </Call>
+
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Add a HTTPS SSL listener on port 8443 -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- UNCOMMENT TO ACTIVATE
+ <Call name="addListener">
+ <Arg>
+ <New class="org.mortbay.http.SunJsseListener">
+ <Set name="Port">8443</Set>
+ <Set name="PoolName">P1</Set>
+ <Set name="MaxIdleTimeMs">30000</Set>
+ <Set name="lowResources">30</Set>
+ <Set name="LowResourcePersistTimeMs">2000</Set>
+ <Set name="Keystore"><SystemProperty name="jetty.home" default="."/>/etc/demokeystore</Set>
+ <Set name="Password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
+ <Set name="KeyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
+
+ <Set name="HttpHandler">
+ <New class="org.mortbay.http.handler.MsieSslHandler">
+ <Set name="UserAgentSubString">MSIE 5</Set>
+ </New>
+ </Set>
+ </New>
+ </Arg>
+ </Call>
+ -->
+
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Add a AJP13 listener on port 18009 -->
+ <!-- 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">18009</Set>
+ <Set name="MinThreads">5</Set>
+ <Set name="MaxThreads">20</Set>
+ <Set name="MaxIdleTimeMs">0</Set>
+ <Set name="confidentialPort">443</Set>
+ </New>
+ </Arg>
+ </Call>
+
+
+ <!-- =============================================================== -->
+ <!-- Set the default web application configuration mechanisms: -->
+ <!-- XMLConfiguration - handles WEB-INF/web.xml -->
+ <!-- JettyWebConfiguration - handles WEB-INF/jetty-web.xml -->
+ <!-- jsr77.Configuration - Adds jsr77 statistics to servlets -->
+ <!-- -->
+ <!-- Order of these classes is significant. The defaults set here -->
+ <!-- can be overridden by calling setConfigurationClassNames() on -->
+ <!-- the webapp context. -->
+ <!-- The jsr77 configuration requires additional jars on the -->
+ <!-- on the classpath and it needs jmx enabled. To do this start -->
+ <!-- with a command like: -->
+ <!-- java -DSTART=extra/etc/start-jsr77.config -jar start.jar etc/demo.mlet
+ -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <Set name="WebApplicationConfigurationClassNames">
+ <Array type="java.lang.String">
+ <Item>org.mortbay.jetty.servlet.XMLConfiguration</Item>
+ <Item>org.mortbay.jetty.servlet.JettyWebConfiguration</Item>
+ <!--
+ <Item>org.mortbay.jetty.servlet.jsr77.Configuration</Item>
+ -->
+ </Array>
+ </Set>
+
+
+ <!-- =============================================================== -->
+ <!-- Configure the Contexts -->
+ <!-- =============================================================== -->
+
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Add a all web application within the webapps directory. -->
+ <!-- + No virtual host specified -->
+ <!-- + Look in the webapps directory relative to jetty.home or . -->
+ <!-- + Use the webdefault.xml resource for the defaults descriptor -->
+ <!-- + Upack the war file -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <Set name="rootWebApp">root</Set>
+
+ <Call name="addWebApplications">
+ <Arg></Arg>
+ <Arg><SystemProperty name="jetty.home" default="."/>/testdata/webapps/</Arg>
+ <Arg><SystemProperty name="jetty.home" default="."/>/testdata/jetty/webdefault.xml</Arg>
+ <Arg type="boolean">true</Arg><!--extract WARs-->
+ </Call>
+
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Add and configure a specific web application -->
+ <!-- + Set Unpack WAR files -->
+ <!-- + Set Default Descriptor. Resource, file or URL -->
+ <!-- + Set java 2 complaint classloading -->
+ <!-- + Set Virtual Hosts. A Null host or empty array means all hosts -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- UNCOMMENT TO ACTIVATE
+ <Call name="addWebApplication">
+ <Arg>/context</Arg>
+ <Arg>./webapps/root</Arg>
+
+ <Set name="extractWAR">false</Set>
+ <Set name="defaultsDescriptor">org/mortbay/jetty/servlet/webdefault.xml</Set>
+ <Set name="classLoaderJava2Compliant">true</Set>
+
+ <Set name="virtualHosts">
+ <Array type="java.lang.String">
+ <Item></Item>
+ <Item>127.0.0.1</Item>
+ <Item>localhost</Item>
+ <Item>www.acme.com</Item>
+ </Array>
+ </Set>
+ </Call>
+ -->
+
+ <!-- =============================================================== -->
+ <!-- Configure the Request Log -->
+ <!-- =============================================================== -->
+ <Set name="RequestLog">
+ <New class="org.mortbay.http.NCSARequestLog">
+ <Arg><SystemProperty name="jetty.home" default="."/>/testdata/jetty/logs/yyyy_mm_dd.request.log</Arg>
+ <Set name="retainDays">90</Set>
+ <Set name="append">true</Set>
+ <Set name="extended">false</Set>
+ <Set name="LogTimeZone">GMT</Set>
+ </New>
+ </Set>
+
+ <!-- =============================================================== -->
+ <!-- Configure the Other Server Options -->
+ <!-- =============================================================== -->
+ <Set name="requestsPerGC">2000</Set>
+ <Set name="statsOn">false</Set>
+ <Set class="org.mortbay.util.FileResource" name="checkAliases" type="boolean">true</Set>
+</Configure>
+
+
+
+
+
+
+
+
+
</pre></div>
<hr /><a name="file50" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/testdata/jetty<br /></span>
<div class="fileheader" id="added"><big><b>webdefault.xml</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N webdefault.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ webdefault.xml 5 Jul 2005 13:32:12 -0000 1.1
@@ -0,0 +1,367 @@
</small></pre><pre class="diff" id="added">+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- ===================================================================== -->
+<!-- This file contains the default descriptor for web applications. -->
+<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+<!-- The intent of this descriptor is to include jetty specific or common -->
+<!-- configuration for all webapps. If a context has a webdefault.xml -->
+<!-- descriptor, it is applied before the contexts own web.xml file -->
+<!-- -->
+<!-- A context may be assigned a default descriptor by: -->
+<!-- + Allowing the default defaultweb.xml to be applied -->
+<!-- + Calling WebApplicationContext.setDefaultsDescriptor -->
+<!-- + Passed an arg to addWebApplications -->
+<!-- -->
+<!-- If a defaults descriptor is set, it is first looked for as a system -->
+<!-- resource. The jetty jar contains a webdefault.xml file as a resource -->
+<!-- at "org/mortbay/jetty/servlet/webdefault.xml". If a system resource -->
+<!-- is not found, then a normal resource is tried, thus a filename or URL -->
+<!-- may be used to specify an arbitrary file. -->
+<!-- -->
+<!-- ===================================================================== -->
+<web-app
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <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, OPTIONS 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>
+
+ <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
+
+
+ <!-- ==================================================================== -->
+ <!-- JSP Servlet -->
+ <!-- This is the jasper JSP servlet from the jakarta project -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- The JSP page compiler and execution servlet, which is the mechanism -->
+ <!-- used by Tomcat to support JSP pages. Traditionally, this servlet -->
+ <!-- is mapped to URL patterh "*.jsp". This servlet supports the -->
+ <!-- following initialization parameters (default values are in square -->
+ <!-- brackets): -->
+ <!-- -->
+ <!-- checkInterval If development is false and reloading is true, -->
+ <!-- background compiles are enabled. checkInterval -->
+ <!-- is the time in seconds between checks to see -->
+ <!-- if a JSP page needs to be recompiled. [300] -->
+ <!-- -->
+ <!-- compiler Which compiler Ant should use to compile JSP -->
+ <!-- pages. See the Ant documenation for more -->
+ <!-- information. [javac] -->
+ <!-- -->
+ <!-- classdebuginfo Should the class file be compiled with -->
+ <!-- debugging information? [true] -->
+ <!-- -->
+ <!-- classpath What class path should I use while compiling -->
+ <!-- generated servlets? [Created dynamically -->
+ <!-- based on the current web application] -->
+ <!-- -->
+ <!-- development Is Jasper used in development mode (will check -->
+ <!-- for JSP modification on every access)? [true] -->
+ <!-- -->
+ <!-- enablePooling Determines whether tag handler pooling is -->
+ <!-- enabled [true] -->
+ <!-- -->
+ <!-- fork Tell Ant to fork compiles of JSP pages so that -->
+ <!-- a separate JVM is used for JSP page compiles -->
+ <!-- from the one Tomcat is running in. [true] -->
+ <!-- -->
+ <!-- ieClassId The class-id value to be sent to Internet -->
+ <!-- Explorer when using <jsp:plugin> tags. -->
+ <!-- [clsid:8AD9C840-044E-11D1-B3E9-00805F499D93] -->
+ <!-- -->
+ <!-- javaEncoding Java file encoding to use for generating java -->
+ <!-- source files. [UTF8] -->
+ <!-- -->
+ <!-- keepgenerated Should we keep the generated Java source code -->
+ <!-- for each page instead of deleting it? [true] -->
+ <!-- -->
+ <!-- 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] -->
+ <!-- -->
+ <!-- -->
+ <!-- reloading Should Jasper check for modified JSPs? [true] -->
+ <!-- -->
+ <!-- suppressSmap Should the generation of SMAP info for JSR45 -->
+ <!-- debugging be suppressed? [false] -->
+ <!-- -->
+ <!-- dumpSmap Should the SMAP info for JSR45 debugging be -->
+ <!-- dumped to a file? [false] -->
+ <!-- False if suppressSmap is true -->
+ <!-- -->
+ <!-- scratchdir What scratch directory should we use when -->
+ <!-- compiling JSP pages? [default work directory -->
+ <!-- for the current web application] -->
+ <!-- -->
+ <!-- tagpoolMaxSize The maximum tag handler pool size [5] -->
+ <!-- -->
+ <!-- xpoweredBy Determines whether X-Powered-By response -->
+ <!-- header is added by generated servlet [false] -->
+ <!-- -->
+ <!-- If you wish to use Jikes to compile JSP pages: -->
+ <!-- Set the init parameter "compiler" to "jikes". Define -->
+ <!-- the property "-Dbuild.compiler.emacs=true" when starting Jetty -->
+ <!-- to cause Jikes to emit error messages in a format compatible with -->
+ <!-- Jasper. -->
+ <!-- If you get an error reporting that jikes can't use UTF8 encoding, -->
+ <!-- try setting the init parameter "javaEncoding" to "ISO-8859-1". -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <servlet>
+ <servlet-name>jsp</servlet-name>
+ <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
+ <init-param>
+ <param-name>logVerbosityLevel</param-name>
+ <param-value>DEBUG</param-value>
+ </init-param>
+ <init-param>
+ <param-name>fork</param-name>
+ <param-value>false</param-value>
+ </init-param>
+ <init-param>
+ <param-name>xpoweredBy</param-name>
+ <param-value>false</param-value>
+ </init-param>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+
+ <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>jsp</servlet-name> <url-pattern>*.jspx</url-pattern> </servlet-mapping>
+ <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.xsp</url-pattern> </servlet-mapping>
+
+
+ <!-- ==================================================================== -->
+ <!-- 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 -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Uncomment for dynamic invocation
+ <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>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>
+
+ <!-- ==================================================================== -->
+ <locale-encoding-mapping-list>
+ <locale-encoding-mapping><locale>ar</locale><encoding>ISO-8859-6</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>be</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>bg</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>ca</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>cs</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>da</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>de</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>el</locale><encoding>ISO-8859-7</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>en</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>es</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>et</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>fi</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>fr</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>hr</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>hu</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>is</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>it</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>iw</locale><encoding>ISO-8859-8</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>ja</locale><encoding>Shift_JIS</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>ko</locale><encoding>EUC-KR</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>lt</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>lv</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>mk</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>nl</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>no</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>pl</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>pt</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>ro</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>ru</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>sh</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>sk</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>sl</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>sq</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>sr</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>sv</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>tr</locale><encoding>ISO-8859-9</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>uk</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>zh</locale><encoding>GB2312</encoding></locale-encoding-mapping>
+ <locale-encoding-mapping><locale>zh_TW</locale><encoding>Big5</encoding></locale-encoding-mapping>
+ </locale-encoding-mapping-list>
+
+
+ <!-- ==================================================================== -->
+ <!-- JSR154 Stupidness -->
+ <!-- This filter implements some of the JSR154 (servlet 2.4) "features", -->
+ <!-- which are rather stupid and expensive to implement. Thus they are -->
+ <!-- not included in the core Jetty architecture. It is HIGHLY -->
+ <!-- RECOMMENDED that this filter NOT be used, unless you need: -->
+ <!-- RequestAttributeListeners - If you actually have a real use for -->
+ <!-- these, please tell the jetty lists what they are and why you -->
+ <!-- can't use a normal filter/wrapper for this? -->
+ <!-- SRV.6.2.2 Dispatachers - where the container cannot wrap the -->
+ <!-- request or response. See -->
+ <!-- http://jetty.mortbay.org/jetty/doc/servlet24.html#d0e711 -->
+ <!-- to find out why this is stupid. -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- UNCOMMENT For compliant behaviour
+ <filter>
+ <filter-name>jsr154</filter-name>
+ <filter-class>org.mortbay.jetty.servlet.JSR154Filter</filter-class>
+ <init-param><param-name>unwrappedDispatch</param-name><param-value>true</param-value></init-param>
+ </filter>
+ <filter-mapping>
+ <filter-name>jsr154</filter-name>
+ <url-pattern>/*</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+ -->
+
+</web-app>
+
</pre></div>
<hr /><a name="file51" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/testdata/webapps/template/WEB-INF<br /></span>
<div class="fileheader" id="added"><big><b>web.xml</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N web.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ web.xml 5 Jul 2005 13:32:14 -0000 1.1
@@ -0,0 +1,45 @@
</small></pre><pre class="diff" id="added">+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <display-name>Template WebApp</display-name>
+
+<!--
+ <filter>
+ <filter-name>Filter</filter-name>
+ <filter-class>com.acme.DemoFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>Filter</filter-name>
+ <url-pattern>/</url-pattern>
+ </filter-mapping>
+
+ <servlet>
+ <servlet-name>Dump</servlet-name>
+ <servlet-class>com.acme.DumpServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Dump</servlet-name>
+ <url-pattern>/dump/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>Dump</servlet-name>
+ <url-pattern>*.dump</url-pattern>
+ </servlet-mapping>
+
+ <error-page>
+ <error-code>404</error-code>
+ <location>/dump/ERROR</location>
+ </error-page>
+-->
+
+</web-app>
+
+
</pre></div>
<hr /><a name="file52" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/testdata/webapps/template/src/com/acme<br /></span>
<div class="fileheader" id="added"><big><b>DemoFilter.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DemoFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DemoFilter.java 5 Jul 2005 13:32:14 -0000 1.1
@@ -0,0 +1,44 @@
</small></pre><pre class="diff" id="added">+// ===========================================================================
+// Copyright (c) 1996-2003 Mort Bay Consulting Pty. Ltd. All rights reserved.
+// $Id: DemoFilter.java,v 1.1 2005/07/05 13:32:14 proyal Exp $
+// ---------------------------------------------------------------------------
+
+package com.acme;
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+
+/* ------------------------------------------------------------ */
+public class DemoFilter implements Filter
+{
+ private FilterConfig config;
+
+ /* ------------------------------------------------------------ */
+ public void init(FilterConfig filterConfig)
+ throws ServletException
+ {
+ config=filterConfig;
+ }
+
+ /* ------------------------------------------------------------ */
+ public void doFilter(ServletRequest request,
+ ServletResponse response,
+ FilterChain chain)
+ throws IOException, ServletException
+ {
+ // Do your funky filter thang here ...
+ chain.doFilter(request, response);
+ }
+
+ /* ------------------------------------------------------------ */
+ public void destroy()
+ {
+ }
+}
+
</pre></div>
<hr /><a name="file53" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/testdata/webapps/template/src/com/acme<br /></span>
<div class="fileheader" id="added"><big><b>DumpServlet.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DumpServlet.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DumpServlet.java 5 Jul 2005 13:32:14 -0000 1.1
@@ -0,0 +1,100 @@
</small></pre><pre class="diff" id="added">+package com.acme;
+
+import java.io.*;
+import java.util.Enumeration;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestWrapper;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class DumpServlet extends HttpServlet
+{
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ String furi = (String) request.getAttribute("javax.servlet.forward.request_uri");
+ if (furi == null) furi = request.getRequestURI();
+ String url = request.getScheme() + "://" + request.getServerName() + ":"
+ + request.getServerPort() + furi;
+
+ String uri = (String) request.getAttribute("javax.servlet.forward.request_uri");
+ if (uri == null) uri = request.getRequestURI();
+
+ String servlet = (String) request.getAttribute("javax.servlet.include.servlet_path");
+ if (servlet == null) servlet = request.getServletPath();
+
+ String info = (String) request.getAttribute("javax.servlet.include.path_info");
+ if (info == null) info = request.getPathInfo();
+
+ PrintWriter out = null;
+ try
+ {
+ out = new PrintWriter(new OutputStreamWriter(response.getOutputStream()));
+ }
+ catch (IllegalStateException e)
+ {
+ out = response.getWriter();
+ }
+
+ String referer = request.getHeader("referer");
+ response.setContentType("text/html");
+
+ out.write("<html><body>");
+ out.write("<h1>Dump from " + getServletContext().getServerInfo() + "</h1>");
+ out.write("<h3>Logical Values</h3>");
+ out.write("<table border=\"1\"><tr><th>Name</th><th>Value</th><th>Expected Value</th></tr>");
+ out.write("<tr><td>Client URL</td><td>" + url
+ + "</td><td>Same as browser location bar</td></tr>");
+ out.write("<tr><td>Client URI</td><td>" + uri
+ + "</td><td>Tail of browser location bar</td></tr>");
+ out.write("<tr><td>This Servlet</td><td>" + servlet + "</td><td>/dump</td></tr>");
+ out.write("<tr><td>This Info</td><td>" + info + "</td><td>/info</td></tr>");
+ out.write("</table>");
+
+ // loop over all wrappers
+ ServletRequest sr = request;
+
+ while (sr != null)
+ {
+ out.write("<h3>" + sr.getClass() + ":" + sr.hashCode() + "</h3>");
+
+ out.write("<table border=\"1\"><tr><th>Name</th><th>Value</th></tr>");
+ out.write("<tr><td>getScheme()</td><td>" + sr.getScheme() + "</td></tr>");
+ out.write("<tr><td>getServerName()</td><td>" + sr.getServerName() + "</td></tr>");
+ out.write("<tr><td>getServlerPort()</td><td>" + sr.getServerPort() + "</td></tr>");
+
+ if (sr instanceof HttpServletRequest)
+ {
+ HttpServletRequest hsr = (HttpServletRequest) sr;
+
+ out.write("<tr><td>getRequestURL()</td><td>" + hsr.getRequestURL() + "</td></tr>");
+ out.write("<tr><td>getRequestURI()</td><td>" + hsr.getRequestURI() + "</td></tr>");
+ out.write("<tr><td>getContextPath()</td><td>" + hsr.getContextPath()
+ + "</td></tr>");
+ out.write("<tr><td>getServletPath()</td><td>" + hsr.getServletPath()
+ + "</td></tr>");
+ out.write("<tr><td>getPathInfo()</td><td>" + hsr.getPathInfo() + "</td></tr>");
+ }
+
+ Enumeration e = sr.getAttributeNames();
+ while (e.hasMoreElements())
+ {
+ String name = (String) e.nextElement();
+ out.write("<tr><td>getAttribute(\"" + name + "\")</td><td>" + sr.getAttribute(name)
+ + "</td></tr>");
+ }
+ out.write("</table>");
+
+ if (sr instanceof ServletRequestWrapper)
+ sr = ((ServletRequestWrapper) sr).getRequest();
+ else
+ sr = null;
+ }
+
+ if (referer != null) out.write("<p><a href=\"" + referer + "\">BACK</a></p>");
+ out.write("</body></html>");
+ out.flush();
+ }
+}
</pre></div>
<hr /><a name="file54" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/testdata/webapps/template<br /></span>
<div class="fileheader" id="added"><big><b>build.xml</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N build.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ build.xml 5 Jul 2005 13:32:14 -0000 1.1
@@ -0,0 +1,71 @@
</small></pre><pre class="diff" id="added">+
+<project name="template" default="classes" basedir=".">
+
+ <property name="src" value="${basedir}/src"/>
+ <property name="webinf" value="${basedir}/WEB-INF"/>
+ <property name="webinf.lib" value="${webinf}/lib"/>
+ <property name="webinf.classes" value="${webinf}/classes"/>
+ <property name="lib" value="${basedir}/../../lib" />
+ <property name="ext" value="${basedir}/../../ext" />
+ <property name="war" value="${basedir}/../${ant.project.name}.war" />
+ <property name="javac.debug" value="true" />
+ <property name="javac.optimize" value="true" />
+ <property name="javac.deprecation" value="true" />
+
+
+ <target name="classpath">
+ <mkdir dir="${webinf.lib}"/>
+ <path id="classpath">
+ <fileset dir="${webinf.lib}">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${lib}">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${ext}">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+ <property name="expanded.classpath" refid="classpath"/>
+ <echo message="classpath=${expanded.classpath}" level="info"/>
+ </target>
+
+
+ <target name="classes" depends="classpath" description="Compile classes">
+ <mkdir dir="${webinf.classes}"/>
+ <javac srcdir="${src}"
+ destdir="${webinf.classes}"
+ debug="${javac.debug}"
+ optimize="${javac.optimize}"
+ deprecation="${javac.deprecation}"
+ >
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+
+ <include name="**/*.java"/>
+ </javac>
+ </target>
+
+ <target name="war" depends="classes" description="build WAR">
+ <war destfile="${war}"
+ webxml="${webinf}/web.xml"
+ basedir="${basedir}">
+ <exclude name="build.xml"/>
+ <exclude name="WEB-INF/web.xml"/>
+ <exclude name="**/CVS/**"/>
+ <exclude name="src/**"/>
+ </war>
+ </target>
+
+ <target name="clean" description="Remove generated files">
+ <delete file="${war}" quiet="false"/>
+ <delete dir="${webinf.classes}"/>
+ <delete dir="${webinf.lib}"/>
+ </target>
+
+</project>
+
+
+
</pre></div>
<hr /><a name="file55" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/testdata/webapps/template<br /></span>
<div class="fileheader" id="added"><big><b>index.html</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N index.html
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ index.html 5 Jul 2005 13:32:14 -0000 1.1
@@ -0,0 +1,46 @@
</small></pre><pre class="diff" id="added">+<HTML>
+ <HEAD>
+ <TITLE>Powered By Jetty</TITLE>
+ <META http-equiv="Pragma" content="no-cache">
+ <META http-equiv="Cache-Control" content="no-cache,no-store">
+ </HEAD>
+<BODY>
+<A HREF="http://jetty.mortbay.org"><IMG SRC="jetty_banner.gif"></A>
+<P>
+This is a template web application context, which can be used as the
+basis of your own web application. It contains some static content
+and a <a href="dump">Dump Servlet</a>.
+It's location is $JETTY_HOME/webapps/template.
+<p>
+If you want to see a full demonstration of Jetty, then you will need
+to have either the Jetty-5.0.x-extra or Jetty-5.0.x-all package installed.
+You will then be able to run the demo with:<PRE>
+ java -jar start.jar etc/admin.xml etc/demo.xml
+</PRE>
+<p>
+For a standard installation of Jetty, the <a href="/javadoc">javadoc</a>
+will be available.
+<p>
+If this server was started with the etc/admin.xml configuration, then
+a <A href="http://localhost:8081">simple admin UI</a> may be
+available (default username/password is admin/admin).
+<p>
+If this server was started via JMX, then a
+<A href="http://localhost:8082">JMX console UI</a> should be available.
+To start Jetty with JMX use: <PRE>
+ java -Dstart.class=org.mortbay.util.jmx.Main -jar start.jar etc/jetty.mlet
+</PRE>
+
+To start a server using the jars and resource in the extra packages, use:
+<PRE>
+java -DSTART=extra/etc/start.config -jar start.jar
+</PRE>
+or
+<PRE>
+java -Dmain.class=org.mortbay.jetty.plus.Server -DSTART=extra/etc/start.config -jar start.jar
+</PRE>
+
+
+
+</BODY>
+</HTML>
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.8</small></center>
</body></html>