You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2006/10/14 23:08:50 UTC

svn commit: r464027 - in /incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty: AbstractJettyDecorator.java JettyDecorator.java JettyHelperException.java JettyMonitor.java JettyMonitorException.java package.html

Author: ehillenius
Date: Sat Oct 14 14:08:49 2006
New Revision: 464027

URL: http://svn.apache.org/viewvc?view=rev&rev=464027
Log:
simplified jetty support and upgraded to Jetty 6

Added:
    incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/AbstractJettyDecorator.java
    incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyDecorator.java
    incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyHelperException.java
    incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyMonitor.java
    incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyMonitorException.java
    incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/package.html

Added: incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/AbstractJettyDecorator.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/AbstractJettyDecorator.java?view=auto&rev=464027
==============================================================================
--- incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/AbstractJettyDecorator.java (added)
+++ incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/AbstractJettyDecorator.java Sat Oct 14 14:08:49 2006
@@ -0,0 +1,124 @@
+/*
+ * $Id: AbstractJettyDecorator.java 459490 2006-02-23 23:25:06 +0100 (Thu, 23
+ * Feb 2006) jdonnerstag $ $Revision: 464023 $ $Date: 2006-02-23 23:25:06 +0100
+ * (Thu, 23 Feb 2006) $
+ * 
+ * ====================================================================
+ * Copyright (c) 2003, Open Edge B.V. All rights reserved. Redistribution and
+ * use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met: Redistributions of source
+ * code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer. 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. Neither
+ * the name of OpenEdge B.V. nor the names of its contributors may be used to
+ * endorse or promote products derived from this software without specific prior
+ * written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS 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 COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package nl.openedge.util.jetty;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+/**
+ * Base class for Jetty TestDecorators.
+ * 
+ * @author Eelco Hillenius
+ */
+public abstract class AbstractJettyDecorator extends TestSetup
+{
+	/** context path (webapp name). */
+	private String contextPath = "/wicket-examples";
+
+	/** port for http requests. */
+	private int port = 8098;
+
+	/** root folder of web application. */
+	private String webappContextRoot = "src/webapp";
+
+	/**
+	 * Construct with test to decorate.
+	 * 
+	 * @param test
+	 *            test to decorate
+	 */
+	public AbstractJettyDecorator(Test test)
+	{
+		super(test);
+	}
+
+	/**
+	 * Get context path (webapp name).
+	 * 
+	 * @return String Returns the context path (webapp name).
+	 */
+	public String getContextPath()
+	{
+		return contextPath;
+	}
+
+	/**
+	 * Get port for http requests.
+	 * 
+	 * @return int Returns the port.
+	 */
+	public int getPort()
+	{
+		return port;
+	}
+
+	/**
+	 * Get root folder of web application.
+	 * 
+	 * @return String Returns the webappContextRoot.
+	 */
+	public String getWebappContextRoot()
+	{
+		return webappContextRoot;
+	}
+
+	/**
+	 * Set context path (webapp name).
+	 * 
+	 * @param contextPath
+	 *            context path (webapp name).
+	 */
+	public void setContextPath(String contextPath)
+	{
+		this.contextPath = contextPath;
+	}
+
+	/**
+	 * Set port for http requests.
+	 * 
+	 * @param port
+	 *            port for http requests.
+	 */
+	public void setPort(int port)
+	{
+		this.port = port;
+	}
+
+	/**
+	 * Set root folder of web application.
+	 * 
+	 * @param webappContextRoot
+	 *            webappContextRoot to set.
+	 */
+	public void setWebappContextRoot(String webappContextRoot)
+	{
+		this.webappContextRoot = webappContextRoot;
+	}
+}
\ No newline at end of file

Added: incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyDecorator.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyDecorator.java?view=auto&rev=464027
==============================================================================
--- incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyDecorator.java (added)
+++ incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyDecorator.java Sat Oct 14 14:08:49 2006
@@ -0,0 +1,145 @@
+/*
+ * $Id: JettyDecorator.java 461192 2006-06-28 08:37:16 +0200 (Wed, 28 Jun 2006)
+ * ehillenius $ $Revision: 464023 $ $Date: 2006-06-28 08:37:16 +0200 (Wed, 28 Jun
+ * 2006) $
+ * 
+ * ====================================================================
+ * Copyright (c) 2003, Open Edge B.V. All rights reserved. Redistribution and
+ * use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met: Redistributions of source
+ * code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer. 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. Neither
+ * the name of OpenEdge B.V. nor the names of its contributors may be used to
+ * endorse or promote products derived from this software without specific prior
+ * written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS 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 COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package nl.openedge.util.jetty;
+
+import junit.framework.Test;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+/**
+ * JUnit decorator for starting and stopping a local instance Jetty for usage
+ * with test cases.
+ * <p>
+ * It uses property 'jettyConfig' to load the - mandatory - Jetty configuration
+ * document. Eg '/jetty-test-config.xml' is loaded from the classpath root (so
+ * providing the configuration document in the root of the test classes folder
+ * will suffice) but 'file://c:/mydir/myconfig.xml' should work as well. If
+ * property 'jettyConfig' is not provided (default == null), the properties
+ * 'port', 'webappContextRoot' and 'contextPath' are used to start a Jetty
+ * instance.
+ * </p>
+ * <p>
+ * Property useJettyPlus (default == false) is used to decide whether JettyPlus
+ * should be used, or just the basic version of Jetty. JettyPlus provides
+ * support for JNDI, datasources, transactions etc.
+ * </p>
+ * <p>
+ * Usage:
+ * 
+ * <pre>
+ *           
+ *            ...
+ *              public static Test suite() 
+ *              {
+ *           	    TestSuite suite = new TestSuite();
+ *           	    suite.addTest(new JettyDecoratorWithArgsTest(&quot;testPing&quot;));
+ *           	    JettyDecorator deco = new JettyDecorator(suite);
+ *           	    deco.setPort(8098);
+ *           	    deco.setWebappContextRoot(&quot;src/webapp&quot;);
+ *           	    deco.setContextPath(&quot;/test&quot;);
+ *           	    deco.setUseJettyPlus(false);
+ *           	    return deco;
+ *              }
+ *            ...
+ *            
+ * </pre>
+ * 
+ * Jetty will be started before the tests are actually run, and will be stopped
+ * afterwards.
+ * </p>
+ * 
+ * @author Eelco Hillenius
+ */
+public class JettyDecorator extends AbstractJettyDecorator
+{
+	/** logger. */
+	private static final Log log = LogFactory.getLog(JettyDecorator.class);
+
+	/** instance of jetty server. */
+	private Server server = null;
+
+	/**
+	 * construct with test.
+	 * 
+	 * @param test
+	 *            test case
+	 */
+	public JettyDecorator(final Test test)
+	{
+		super(test);
+	}
+
+	/**
+	 * Start Jetty.
+	 * 
+	 * @throws Exception
+	 * @see junit.extensions.TestSetup#setUp()
+	 */
+	public void setUp() throws Exception
+	{
+		server = new Server();
+		SelectChannelConnector connector = new SelectChannelConnector();
+		connector.setPort(getPort());
+		server.setConnectors(new Connector[] { connector });
+
+		WebAppContext web = new WebAppContext();
+		web.setContextPath(getContextPath());
+		web.setWar(getWebappContextRoot());
+		server.addHandler(web);
+
+		log.info("Starting Jetty");
+		server.start();
+		log.info("Jetty started");
+	}
+
+	/**
+	 * Stop Jetty.
+	 * 
+	 * @see junit.extensions.TestSetup#tearDown()
+	 */
+	public void tearDown()
+	{
+		log.info("Stopping Jetty");
+		try
+		{
+			server.stop();
+			log.info("Jetty stopped");
+		}
+		catch (Exception e)
+		{
+			log.error(e.getMessage(), e);
+		}
+	}
+}
\ No newline at end of file

Added: incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyHelperException.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyHelperException.java?view=auto&rev=464027
==============================================================================
--- incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyHelperException.java (added)
+++ incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyHelperException.java Sat Oct 14 14:08:49 2006
@@ -0,0 +1,59 @@
+/*
+ * $Id: JettyHelperException.java 458776 2006-01-19 21:34:20 +0100 (Thu, 19 Jan 2006) jdonnerstag $
+ * $Revision: 458776 $ $Date: 2006-01-19 21:34:20 +0100 (Thu, 19 Jan 2006) $
+ * 
+ * ================================================================================
+ * Copyright (c) All rechten voorbehouden.
+ */
+package nl.openedge.util.jetty;
+
+/**
+ * Exceptions that can be thrown by the JettyMonitor.
+ */
+public class JettyHelperException extends Exception
+{
+
+	/**
+	 * Construct.
+	 */
+	public JettyHelperException()
+	{
+		super();
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param message
+	 *            exception message
+	 */
+	public JettyHelperException(String message)
+	{
+		super(message);
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param cause
+	 *            exception cause
+	 */
+	public JettyHelperException(Throwable cause)
+	{
+		super(cause);
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param message
+	 *            exception message
+	 * @param cause
+	 *            exception cause
+	 */
+	public JettyHelperException(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+}

Added: incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyMonitor.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyMonitor.java?view=auto&rev=464027
==============================================================================
--- incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyMonitor.java (added)
+++ incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyMonitor.java Sat Oct 14 14:08:49 2006
@@ -0,0 +1,334 @@
+/*
+ * $Id: JettyMonitor.java 461192 2006-06-28 08:37:16 +0200 (Wed, 28 Jun 2006) ehillenius $ $Revision:
+ * 3905 $ $Date: 2006-06-28 08:37:16 +0200 (Wed, 28 Jun 2006) $
+ * 
+ * ====================================================================
+ * Copyright (c) 2003, Open Edge B.V. All rights reserved. Redistribution and
+ * use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met: Redistributions of source
+ * code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer. 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. Neither
+ * the name of OpenEdge B.V. nor the names of its contributors may be used to
+ * endorse or promote products derived from this software without specific prior
+ * written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS 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 COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package nl.openedge.util.jetty;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mortbay.jetty.Server;
+
+/**
+ * Monitor thread. This thread listens on the port specified by the STOP.PORT
+ * system parameter (defaults to 8079) for request authenticated with the key
+ * given by the STOP.KEY system parameter (defaults to "mortbay") for admin
+ * requests. Commands "stop" and "status" are currently supported. Based on
+ * Monitor from JettyServer (start and stop classes).
+ * 
+ * @author Eelco Hillenius
+ */
+public class JettyMonitor extends Thread
+{
+
+	/** Listen port. */
+	private int monitorPort;
+
+	/** Auth key. */
+	private String commKey;
+
+	/** Log. */
+	private static final Log log = LogFactory.getLog(JettyMonitor.class);
+
+	/** socket chanel for commands. */
+	private ServerSocketChannel serverSocketChanel = null;
+
+	/** JettyServer instantie, zodat we (nog) schoner kunnen afsluiten. */
+	private Server server = null;
+
+	/**
+	 * Hidden constructor.
+	 * 
+	 * @param commKey
+	 *            auth key
+	 * @param monitorPort
+	 *            monitor port
+	 */
+	private JettyMonitor(String commKey, int monitorPort)
+	{
+		this.commKey = commKey;
+		this.monitorPort = monitorPort;
+	}
+
+	/**
+	 * @see java.lang.Runnable#run()
+	 */
+	public void run()
+	{
+		log.info("Starting Jetty Monitor on port " + monitorPort);
+		createServerSocket();
+		log.info("Socket created");
+		// listen to incomming connections until stop command is issued (method
+		// blocks)
+		listen();
+		try
+		{
+			// exiting... close server socket
+			serverSocketChanel.close();
+		}
+		catch (IOException e)
+		{
+			log.error(e.getMessage(), e);
+		}
+		log.info("exiting monitor and VM");
+		System.exit(0);
+	}
+
+	/**
+	 * Create the server socket.
+	 */
+	private void createServerSocket()
+	{
+		try
+		{
+			ServerSocket internalSocket = null;
+			InetSocketAddress socketAddress = new InetSocketAddress(InetAddress
+					.getByName("127.0.0.1"), monitorPort);
+			serverSocketChanel = ServerSocketChannel.open();
+			internalSocket = serverSocketChanel.socket();
+			internalSocket.bind(socketAddress);
+			if (monitorPort == 0)
+			{
+				monitorPort = internalSocket.getLocalPort();
+				log.info("using internal port " + monitorPort);
+			}
+			if (!"mortbay".equals(commKey))
+			{
+				commKey = Long.toString((long)(Long.MAX_VALUE * Math.random()), 36);
+				log.debug("Using key " + commKey);
+			}
+		}
+		catch (Exception e)
+		{
+			log.fatal(e.getMessage(), e);
+			log.fatal("************ SHUTTING DOWN VM!");
+			System.exit(1);
+		}
+	}
+
+	/**
+	 * Listen to incomming commands until stop command is issued (method
+	 * blocks).
+	 */
+	private void listen()
+	{
+		boolean goOn = true;
+		while (goOn)
+		{
+			Socket socket = null;
+			try
+			{
+				// wait in blocking mode for an incomming socket connection
+				SocketChannel socketChanel = serverSocketChanel.accept();
+				// we've got a connection here; get concrete socket
+				socket = socketChanel.socket();
+				// attach reader
+				InputStream socketInputStream = socket.getInputStream();
+				InputStreamReader inputStreamReader = new InputStreamReader(socketInputStream);
+				LineNumberReader lnReader = new LineNumberReader(inputStreamReader);
+				String key = lnReader.readLine(); // first line contains auth
+				// key
+				if (!commKey.equals(key))
+				{
+					log.warn("Keys '" + commKey + "' and '" + key + "' do not match!");
+					continue;
+				}
+
+				String cmd = lnReader.readLine(); // second line contains
+				// command
+				OutputStream socketOutputStream = socket.getOutputStream();
+				goOn = handleCommand(cmd, socketOutputStream, goOn);
+
+			}
+			catch (Exception e)
+			{
+				log.error(e.getMessage(), e);
+			}
+			finally
+			{
+				if (socket != null)
+				{
+					try
+					{
+						socket.close();
+					}
+					catch (Exception e)
+					{
+						log.error(e.getMessage());
+					}
+				}
+				socket = null;
+			}
+		}
+	}
+
+	/**
+	 * Handle given command.
+	 * 
+	 * @param cmd
+	 *            the command to handle
+	 * @param socketOutputStream
+	 *            output stream of socket
+	 * @param goOn
+	 *            current value of goOn
+	 * @return value of goOn, possibly changed
+	 * @throws IOException
+	 */
+	private boolean handleCommand(String cmd, OutputStream socketOutputStream, boolean goOn)
+			throws IOException
+	{
+		log.info("handle command '" + cmd + "'");
+		if ("stop".equals(cmd))
+		{
+			handleStopCommand(socketOutputStream);
+			goOn = false;
+		}
+		else if ("status".equals(cmd))
+		{
+			handleStatusCommand(socketOutputStream);
+		}
+		return goOn;
+	}
+
+	/**
+	 * Handle stop command.
+	 * 
+	 * @param socketOutputStream
+	 *            output stream of socket
+	 */
+	private void handleStopCommand(OutputStream socketOutputStream)
+	{
+		// write ack
+		try
+		{
+			log.info("sending reply ACK_STOP");
+			socketOutputStream.write("ACK_STOP\r\n".getBytes());
+			socketOutputStream.flush();
+		}
+		catch (Exception e)
+		{
+			log.error("sending acknowledgement of stop command failed:", e);
+		}
+		try
+		{
+			server.stop();
+			log.info("Jetty server stopped");
+		}
+		catch (Exception e)
+		{
+			log.fatal(e.getMessage(), e);
+			log.fatal("************* Hard shutdown this server (System.exit)!");
+			System.exit(1);
+		}
+		System.out.flush();
+		System.err.flush();
+	}
+
+	/**
+	 * Handle status command.
+	 * 
+	 * @param socketOutputStream
+	 *            output stream of socket
+	 * @throws IOException
+	 */
+	private void handleStatusCommand(OutputStream socketOutputStream) throws IOException
+	{
+		if ((server != null) && server.isStarted())
+		{
+			log.info("sending reply OK");
+			socketOutputStream.write("OK\r\n".getBytes());
+		}
+		else
+		{
+			if (server == null)
+			{
+				log.info("Server (still) is null");
+			}
+			else
+			{
+				log.info("Server not started yet");
+			}
+			log.info("sending reply STARTING");
+			socketOutputStream.write("STARTING\r\n".getBytes());
+		}
+		socketOutputStream.flush();
+	}
+
+	/**
+	 * Starts a new monitor on the given port, holding the given instance of
+	 * Jetty. This static method starts a monitor that listens for admin
+	 * requests.
+	 * 
+	 * @param theServer
+	 *            instance of Jetty Server
+	 * @param commKey
+	 *            auth key
+	 * @param monitorPort
+	 *            port of monitor
+	 * @return instance of monitor
+	 */
+	public static JettyMonitor startMonitor(Server theServer, String commKey, int monitorPort)
+	{
+		JettyMonitor monitor = new JettyMonitor(commKey, monitorPort);
+		monitor.setServer(theServer);
+		monitor.setDaemon(true);
+		monitor.start();
+		return monitor;
+	}
+
+	/**
+	 * Get server.
+	 * 
+	 * @return Server Returns the server.
+	 */
+	public Server getServer()
+	{
+		return server;
+	}
+
+	/**
+	 * Set server.
+	 * 
+	 * @param server
+	 *            server to set.
+	 */
+	public void setServer(Server server)
+	{
+		this.server = server;
+	}
+}
\ No newline at end of file

Added: incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyMonitorException.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyMonitorException.java?view=auto&rev=464027
==============================================================================
--- incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyMonitorException.java (added)
+++ incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/JettyMonitorException.java Sat Oct 14 14:08:49 2006
@@ -0,0 +1,59 @@
+/*
+ * $Id: JettyMonitorException.java 458776 2006-01-19 21:34:20 +0100 (Thu, 19 Jan 2006) jdonnerstag $
+ * $Revision: 458776 $ $Date: 2006-01-19 21:34:20 +0100 (Thu, 19 Jan 2006) $
+ * 
+ * ================================================================================
+ * Copyright (c) All rechten voorbehouden.
+ */
+package nl.openedge.util.jetty;
+
+/**
+ * Exceptions that can be thrown by the JettyMonitor.
+ */
+public class JettyMonitorException extends Exception
+{
+
+	/**
+	 * Construct.
+	 */
+	public JettyMonitorException()
+	{
+		super();
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param message
+	 *            exception message
+	 */
+	public JettyMonitorException(String message)
+	{
+		super(message);
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param cause
+	 *            exception cause
+	 */
+	public JettyMonitorException(Throwable cause)
+	{
+		super(cause);
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param message
+	 *            exception message
+	 * @param cause
+	 *            exception cause
+	 */
+	public JettyMonitorException(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+}

Added: incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/package.html
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/package.html?view=auto&rev=464027
==============================================================================
--- incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/package.html (added)
+++ incubator/wicket/trunk/wicket-examples/src/test/java/nl/openedge/util/jetty/package.html Sat Oct 14 14:08:49 2006
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//NL">
+<html xmlns:wicket="http://wicket.sourceforge.net/">
+<head>
+<title>nl.openedge.util.jetty package</title>
+</head>
+<body>
+Contains Jetty utilities.
+</body>
+</html>
\ No newline at end of file