[CVS spice] make my test pass -- whee!
proyal-yCVjj/[email protected] 9 Aug 2005 01:42:12 -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/src</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt>java/org/codehaus/spice/jervlet/containers/jetty/<a href="#file1">DefaultJettyContainer.java</a></tt></td><td align="right" id="added">+2</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">1.1 -> 1.2</td></tr>
<tr class="alt"><td><tt> /<a href="#file2">JettyServer.java</a></tt></td><td align="right" id="added">+2</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">1.1 -> 1.2</td></tr>
<tr><td><tt>java/org/codehaus/spice/jervlet/impl/pico/<a href="#file3"><span id="added">PicoContext.java</span></a></tt></td><td align="right" id="added">+49</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file4"><span id="added">PicoDefaultContextHandler.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> /<a href="#file5"><span id="added">PicoJettyServer.java</span></a></tt></td><td align="right" id="added">+60</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file6">JervletNanoContainerBuilderDecorationDelegate.java</a></tt></td><td align="right" id="added">+30</td><td align="right" id="removed">-16</td><td nowrap="nowrap" align="center">1.2 -> 1.3</td></tr>
<tr><td><tt> /<a href="#file7"><span id="removed">PicoJettyContainer.java</span></a></tt></td><td></td><td align="right" id="removed">-55</td><td nowrap="nowrap">1.1 removed</td></tr>
<tr class="alt"><td><tt>java/org/codehaus/spice/jervlet/<a href="#file8">ContextException.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.1 -> 1.2</td></tr>
<tr><td><tt>test/org/codehaus/spice/jervlet/impl/pico/<a href="#file9">AnotherTestCase.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.3 -> 1.4</td></tr>
<tr><td></td><td align="right" id="added">+214</td><td align="right" id="removed">-77</td><td></td></tr>
</table>
<small id="info">3 added + 1 removed + 5 modified, total 9 files</small><br />
<div class="tasklist"><ul>
<li><a href="#task1">TODO must be a better way to integrate into pico lifecycle just for this one component</a></li>
<li><a href="#task2">TODO should likely attempt as a URL, then if that fails, treat as a file (relative to working dir)</a></li>
</ul></div>
<pre class="comment">
make my test pass -- whee!
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader"><big><b>DefaultJettyContainer.java</b></big> <small id="info">1.1 -> 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- DefaultJettyContainer.java 5 Jul 2005 13:32:12 -0000 1.1
+++ DefaultJettyContainer.java 9 Aug 2005 01:42:12 -0000 1.2
@@ -142,7 +142,7 @@
</small></pre><pre class="diff" id="context"> {
if( !m_jettyServer.isServerStarted() )
{
</pre><pre class="diff" id="removed">- m_jettyServer.start<span id="removedchars">Server</span>();
</pre><pre class="diff" id="added">+ m_jettyServer.start();
</pre><pre class="diff" id="context"> m_defaultContextHandler = m_jettyServer.createContextHandler();
}
}
</pre><pre class="diff"><small id="info">@@ -156,7 +156,7 @@
</small></pre><pre class="diff" id="context"> {
if( m_jettyServer.isServerStarted() )
{
</pre><pre class="diff" id="removed">- m_jettyServer.stop<span id="removedchars">Server</span>();
</pre><pre class="diff" id="added">+ m_jettyServer.stop();
</pre><pre class="diff" id="context"> }
}
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader"><big><b>JettyServer.java</b></big> <small id="info">1.1 -> 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- JettyServer.java 5 Jul 2005 13:32:12 -0000 1.1
+++ JettyServer.java 9 Aug 2005 01:42:12 -0000 1.2
@@ -158,7 +158,7 @@
</small></pre><pre class="diff" id="context"> *
* @throws Exception if Jetty's <code>Server</code> threw one
*/
</pre><pre class="diff" id="removed">- public void start<span id="removedchars">Server</span>() throws Exception
</pre><pre class="diff" id="added">+ public void start() throws Exception
</pre><pre class="diff" id="context"> {
m_server.start();
}
</pre><pre class="diff"><small id="info">@@ -168,7 +168,7 @@
</small></pre><pre class="diff" id="context"> *
* @throws InterruptedException if Jetty's server threw one
*/
</pre><pre class="diff" id="removed">- public void stop<span id="removedchars">Server</span>() throws InterruptedException
</pre><pre class="diff" id="added">+ public void stop() throws InterruptedException
</pre><pre class="diff" id="context"> {
m_server.stop();
}
</pre></div>
<hr /><a name="file3" /><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>PicoContext.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N PicoContext.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PicoContext.java 9 Aug 2005 01:42:12 -0000 1.1
@@ -0,0 +1,49 @@
</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.pico;
+
+import java.net.URL;
+
+import org.picocontainer.Startable;
+import org.codehaus.spice.jervlet.ContextHandler;
+import org.codehaus.spice.jervlet.Instantiator;
+import org.codehaus.spice.jervlet.impl.DefaultContext;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public class PicoContext extends DefaultContext implements Startable
+{
+ private ContextHandler m_contextHandler;
+
+ public PicoContext( final ContextHandler contextHandler,
+ final String context,
+ final URL resource,
+ final Instantiator instantiator )
+ {
+ super(context, null, resource, false, instantiator);
+
+ m_contextHandler = contextHandler;
+
+ System.out.println( "Created Context - " + this );
+ }
+
+ public void start()
+ {
+ System.out.println( "Starting Context - " + this );
+
+ m_contextHandler.addContext( this );
+ m_contextHandler.startContext( this );
+ }
+
+ public void stop()
+ {
+ m_contextHandler.stopContext( this );
+ m_contextHandler.removeContext( this );
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file4" /><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>PicoDefaultContextHandler.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N PicoDefaultContextHandler.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PicoDefaultContextHandler.java 9 Aug 2005 01:42: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.impl.pico;
+
+import java.util.List;
+
+import org.codehaus.spice.jervlet.ContextHandler;
+import org.codehaus.spice.jervlet.Container;
+import org.codehaus.spice.jervlet.Context;
+import org.picocontainer.Startable;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public class PicoDefaultContextHandler implements ContextHandler, Startable
+{
+ private final Container m_container;
+ private ContextHandler m_handler;
+
+ public PicoDefaultContextHandler( final Container container )
+ {
+ m_container = container;
+ }
+
+ public void start()
+ {
+ m_handler = m_container.createContextHandler();
+ }
+
+ public void stop()
+ {
+ m_container.destroyContextHandler( m_handler );
+ }
+
+ public void addContext( Context context )
+ {
+ m_handler.addContext( context );
+ }
+
+ public List getContexts()
+ {
+ return m_handler.getContexts();
+ }
+
+ public boolean isStarted( Context context )
+ {
+ return m_handler.isStarted( context );
+ }
+
+ public void removeContext( Context context )
+ {
+ m_handler.removeContext( context );
+ }
+
+ public void startContext( Context context )
+ {
+ m_handler.startContext( context );
+ }
+
+ public void stopContext( Context context )
+ {
+ m_handler.stopContext( context );
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file5" /><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>PicoJettyServer.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N PicoJettyServer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PicoJettyServer.java 9 Aug 2005 01:42:12 -0000 1.1
@@ -0,0 +1,60 @@
</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.pico;
+
+import org.codehaus.spice.jervlet.ContextMonitor;
+import org.codehaus.spice.jervlet.ListenerMonitor;
+import org.codehaus.spice.jervlet.containers.jetty.JettyServer;
+import org.codehaus.spice.jervlet.impl.NoopContextMonitor;
+import org.codehaus.spice.jervlet.impl.NoopListenerMonitor;
+import org.mortbay.jetty.Server;
+import org.picocontainer.Startable;
+
+/**
<a name="task1" />+ * <span class="task">TODO</span> must be a better way to integrate into pico lifecycle just for this one component
+ *
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public class PicoJettyServer extends JettyServer implements Startable
+{
+ public PicoJettyServer()
+ {
+ super( new Server(), new NoopListenerMonitor(), new NoopContextMonitor() );
+ }
+
+ public PicoJettyServer( final Server jettyServer,
+ final ListenerMonitor listenerMonitor,
+ final ContextMonitor contextMonitor )
+ {
+ super( jettyServer, listenerMonitor, contextMonitor );
+ }
+
+ public void start()
+ {
+ try
+ {
+ super.start();
+ }
+ catch( Exception e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+
+ public void stop()
+ {
+ try
+ {
+ super.stop();
+ }
+ catch( InterruptedException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file6" /><div class="file">
<span class="pathname">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl/pico<br /></span>
<div class="fileheader"><big><b>JervletNanoContainerBuilderDecorationDelegate.java</b></big> <small id="info">1.2 -> 1.3</small></div>
<pre class="diff"><small id="info">diff -u -r1.2 -r1.3
--- JervletNanoContainerBuilderDecorationDelegate.java 8 Aug 2005 03:01:44 -0000 1.2
+++ JervletNanoContainerBuilderDecorationDelegate.java 9 Aug 2005 01:42:12 -0000 1.3
@@ -7,42 +7,56 @@
</small></pre><pre class="diff" id="context"> */
package org.codehaus.spice.jervlet.impl.pico;
</pre><pre class="diff" id="added">+import java.io.File;
+import java.net.MalformedURLException;
</pre><pre class="diff" id="context"> import java.util.Map;
</pre><pre class="diff" id="removed">-import org.codehaus.spice.jervlet.containers.jetty.DefaultJettyContainer;
-import org.codehaus.spice.jervlet.ContextHandler;
-import org.nanocontainer.script.NullNanoContainerBuilderDecorationDelegate;
</pre><pre class="diff" id="context"> import org.nanocontainer.NanoContainer;
</pre><pre class="diff" id="added">+import org.nanocontainer.script.NanoContainerMarkupException;
+import org.nanocontainer.script.NullNanoContainerBuilderDecorationDelegate;
</pre><pre class="diff" id="context"> import org.picocontainer.MutablePicoContainer;
</pre><pre class="diff" id="added">+import org.picocontainer.Parameter;
+import org.picocontainer.defaults.ComponentParameter;
+import org.picocontainer.defaults.ConstantParameter;
</pre><pre class="diff" id="context">
/**
* @author <a href="mailto:[email protected]">peter royal</a>
*/
public class JervletNanoContainerBuilderDecorationDelegate extends NullNanoContainerBuilderDecorationDelegate
{
</pre><pre class="diff" id="removed">- public Object createNode( Object name, Map attributes, Object parent )
</pre><pre class="diff" id="added">+ public Object createNode( final Object name, final Map attributes, final Object parent )
</pre><pre class="diff" id="context"> {
//TODO check parent is a NanoContainer TDD-style
</pre><pre class="diff" id="removed">- if( "webserver".equals( name ))
</pre><pre class="diff" id="added">+ if( "webserver".equals( name )<span id="addedchars"> </span>)
</pre><pre class="diff" id="context"> {
final MutablePicoContainer pico = ( (NanoContainer)parent ).getPico();
</pre><pre class="diff" id="removed">- pico.registerComponentImplementation( DefaultJettyContainer.class );
- pico.registerComponentImplementation( PicoJettyContainer.class );
-
- final PicoJettyContainer jetty =
- (PicoJettyContainer)pico.getComponentInstance( PicoJettyContainer.class );
-
- pico.registerComponentInstance( jetty.createContextHandler() );
</pre><pre class="diff" id="added">+ pico.registerComponentImplementation( PicoJettyServer.class );
+ pico.registerComponentImplementation( PicoDefaultContextHandler.class );
</pre><pre class="diff" id="context">
return null;
}
</pre><pre class="diff" id="removed">- else if( "webapp".equals( name ))
</pre><pre class="diff" id="added">+ else if( "webapp".equals( name )<span id="addedchars"> </span>)
</pre><pre class="diff" id="context"> {
final MutablePicoContainer pico = ( (NanoContainer)parent ).getPico();
</pre><pre class="diff" id="removed">- final ContextHandler contextHandler = (ContextHandler)pico.getComponentInstance( ContextHandler.class );
-
- //contextHandler.addContext( new PicoContext() );
</pre><pre class="diff" id="added">+ final String context = (String)attributes.remove( "context" );
<a name="task2" />+ //<span class="task">TODO</span> should likely attempt as a URL, then if that fails, treat as a file (relative to working dir)
+ final String warPath = (String)attributes.remove( "warPath" );
+
+ try
+ {
+ pico.registerComponentImplementation(
+ PicoContext.class,
+ PicoContext.class,
+ new Parameter[]{new ComponentParameter(),
+ new ConstantParameter( context ),
+ new ConstantParameter( new File( warPath ).toURL() ),
+ new ConstantParameter( new PicoInstantiator( pico ) )} );
+ }
+ catch( MalformedURLException e )
+ {
+ throw new NanoContainerMarkupException("Malformed warPath: " + warPath, e );
+ }
</pre><pre class="diff" id="context">
return null;
}
</pre></div>
<hr /><a name="file7" /><div class="file">
<span class="pathname" id="removed">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl/pico<br /></span>
<div class="fileheader" id="removed"><big><b>PicoJettyContainer.java</b></big> <small id="info">removed after 1.1</small></div>
<pre class="diff"><small id="info">diff -N PicoJettyContainer.java
--- PicoJettyContainer.java 8 Aug 2005 03:01:44 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,55 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * 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.Startable;
-import org.codehaus.spice.jervlet.containers.jetty.JettyContainer;
-import org.codehaus.spice.jervlet.ContextHandler;
-
-/**
- * @author <a href="mailto:proyal-ysQLU0v/mp1Wk0Htik3J/[email protected]">peter royal</a>
- */
-public class PicoJettyContainer implements Startable
-{
- private final JettyContainer m_jettyContainer;
-
- public PicoJettyContainer( final JettyContainer jettyContainer )
- {
- m_jettyContainer = jettyContainer;
- }
-
- public void start()
- {
- try
- {
- m_jettyContainer.initialize();
- m_jettyContainer.start();
- }
- catch( Exception e )
- {
- throw new RuntimeException( e );
- }
- }
-
- public void stop()
- {
- try
- {
- m_jettyContainer.stop();
- }
- catch( Exception e )
- {
- throw new RuntimeException( e );
- }
- }
-
- public ContextHandler createContextHandler()
- {
- return m_jettyContainer.createContextHandler();
- }
-}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file8" /><div class="file">
<span class="pathname">spice/components/jervlet/src/java/org/codehaus/spice/jervlet<br /></span>
<div class="fileheader"><big><b>ContextException.java</b></big> <small id="info">1.1 -> 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- ContextException.java 5 Jul 2005 13:32:12 -0000 1.1
+++ ContextException.java 9 Aug 2005 01:42:12 -0000 1.2
@@ -12,7 +12,7 @@
</small></pre><pre class="diff" id="context"> *
* @author Johan Sjoberg
*/
</pre><pre class="diff" id="removed">-public class ContextException extends Exception
</pre><pre class="diff" id="added">+public class ContextException extends <span id="addedchars">Runtime</span>Exception
</pre><pre class="diff" id="context"> {
/** The original <code>Throwable</code> */
private final Throwable m_throwable;
</pre></div>
<hr /><a name="file9" /><div class="file">
<span class="pathname">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl/pico<br /></span>
<div class="fileheader"><big><b>AnotherTestCase.java</b></big> <small id="info">1.3 -> 1.4</small></div>
<pre class="diff"><small id="info">diff -u -r1.3 -r1.4
--- AnotherTestCase.java 8 Aug 2005 03:01:44 -0000 1.3
+++ AnotherTestCase.java 9 Aug 2005 01:42:12 -0000 1.4
@@ -26,7 +26,7 @@
</small></pre><pre class="diff" id="context"> {
final InputStream script = getClass().getResourceAsStream( "delegate.groovy" );
final PicoContainer pico = createContainer( new InputStreamReader( script ) );
</pre><pre class="diff" id="removed">- assertNotNull("expected ContextHandler in picocontainer", pico.getComponentInstance( ContextHandler.class));
</pre><pre class="diff" id="added">+ assertNotNull("expected ContextHandler in picocontainer", pico.getComponentInstance<span id="addedchars">OfType</span>( ContextHandler.class));
</pre><pre class="diff" id="context"> }
protected PicoContainer createContainer( final Reader reader ) throws CompilationFailedException
</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>