[CVS spice] Tweak test case to start implementation -- need suggestions from pico-people on how to accomplis the goal :)
proyal-yCVjj/[email protected] 8 Aug 2005 03:01:44 -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>test/org/codehaus/spice/jervlet/impl/pico/<a href="#file1">AnotherTestCase.java</a></tt></td><td align="right" id="added">+10</td><td align="right" id="removed">-10</td><td nowrap="nowrap" align="center">1.2 -> 1.3</td></tr>
<tr class="alt"><td><tt> /<a href="#file2">delegate.groovy</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>java/org/codehaus/spice/jervlet/impl/pico/<a href="#file3"><span id="added">PicoJettyContainer.java</span></a></tt></td><td align="right" id="added">+55</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file4">JervletNanoContainerBuilderDecorationDelegate.java</a></tt></td><td align="right" id="added">+35</td><td></td><td nowrap="nowrap" align="center">1.1 -> 1.2</td></tr>
<tr><td></td><td align="right" id="added">+101</td><td align="right" id="removed">-11</td><td></td></tr>
</table>
<small id="info">1 added + 3 modified, total 4 files</small><br />
<div class="tasklist"><ul>
<li><a href="#task1">TODO check parent is a NanoContainer TDD-style</a></li>
</ul></div>
<pre class="comment">
Tweak test case to start implementation -- need suggestions from pico-people on how to accomplis the goal :)
</pre>
<hr /><a name="file1" /><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.2 -> 1.3</small></div>
<pre class="diff"><small id="info">diff -u -r1.2 -r1.3
--- AnotherTestCase.java 8 Aug 2005 02:33:44 -0000 1.2
+++ AnotherTestCase.java 8 Aug 2005 03:01:44 -0000 1.3
@@ -13,6 +13,7 @@
</small></pre><pre class="diff" id="context"> import junit.framework.TestCase;
import org.codehaus.groovy.control.CompilationFailedException;
import org.codehaus.groovy.runtime.InvokerHelper;
</pre><pre class="diff" id="added">+import org.codehaus.spice.jervlet.ContextHandler;
</pre><pre class="diff" id="context"> import org.nanocontainer.script.groovy.GroovyContainerBuilder;
import org.picocontainer.PicoContainer;
import org.picocontainer.defaults.DefaultPicoContainer;
</pre><pre class="diff"><small id="info">@@ -24,9 +25,8 @@
</small></pre><pre class="diff" id="context"> public void testJervletNanoContainerBuilderDecorationDelegate() throws Exception
{
final InputStream script = getClass().getResourceAsStream( "delegate.groovy" );
</pre><pre class="diff" id="removed">-
- createContainer( new InputStreamReader( script ) );
- assertEquals( "", "" );
</pre><pre class="diff" id="added">+ final PicoContainer pico = createContainer( new InputStreamReader( script ) );
+ assertNotNull("expected ContextHandler in picocontainer", pico.getComponentInstance( ContextHandler.class));
</pre><pre class="diff" id="context"> }
protected PicoContainer createContainer( final Reader reader ) throws CompilationFailedException
</pre><pre class="diff"><small id="info">@@ -71,17 +71,17 @@
</small></pre><pre class="diff" id="context"> assertEquals( "", "" );
}
</pre><pre class="diff" id="removed">- protected void doGroovy( InputStream is ) throws CompilationFailedException
</pre><pre class="diff" id="added">+ protected void doGroovy( <span id="addedchars">final </span>InputStream is ) throws CompilationFailedException
</pre><pre class="diff" id="context"> {
</pre><pre class="diff" id="removed">- Script groovyScript = null;
- GroovyClassLoader loader = new GroovyClassLoader( getClass().getClassLoader() );
- GroovyCodeSource groovyCodeSource = new GroovyCodeSource( is,
</pre><pre class="diff" id="added">+ Script groovyScript;
+ final GroovyClassLoader loader = new GroovyClassLoader( getClass().getClassLoader() );
+ final GroovyCodeSource groovyCodeSource = new GroovyCodeSource( is,
</pre><pre class="diff" id="context"> "nanocontainer.groovy",
"groovyGeneratedForNanoContainer" );
</pre><pre class="diff" id="removed">- Class scriptClass = loader.parseClass( groovyCodeSource );
</pre><pre class="diff" id="added">+ <span id="addedchars">final </span>Class scriptClass = loader.parseClass( groovyCodeSource );
</pre><pre class="diff" id="context"> groovyScript = InvokerHelper.createScript( scriptClass, null );
</pre><pre class="diff" id="removed">- Binding binding = new Binding();
</pre><pre class="diff" id="added">+ <span id="addedchars">final </span>Binding binding = new Binding();
</pre><pre class="diff" id="context"> groovyScript.setBinding( binding );
</pre><pre class="diff" id="removed">- Object result = groovyScript.run();
</pre><pre class="diff" id="added">+ groovyScript.run();
</pre><pre class="diff" id="context"> }
}
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl/pico<br /></span>
<div class="fileheader"><big><b>delegate.groovy</b></big> <small id="info">1.1 -> 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- delegate.groovy 8 Aug 2005 02:33:44 -0000 1.1
+++ delegate.groovy 8 Aug 2005 03:01:44 -0000 1.2
@@ -6,5 +6,5 @@
</small></pre><pre class="diff" id="context"> pico = builder.container {
webserver()
webapp( context : "foo/", warPath : "foo.war" )
</pre><pre class="diff" id="removed">- component( A )
</pre><pre class="diff" id="added">+ component( StringBuffer )
</pre><pre class="diff" id="context"> }
</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>PicoJettyContainer.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N PicoJettyContainer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PicoJettyContainer.java 8 Aug 2005 03:01:44 -0000 1.1
@@ -0,0 +1,55 @@
</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.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="file4" /><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.1 -> 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- JervletNanoContainerBuilderDecorationDelegate.java 8 Aug 2005 02:33:44 -0000 1.1
+++ JervletNanoContainerBuilderDecorationDelegate.java 8 Aug 2005 03:01:44 -0000 1.2
@@ -7,11 +7,46 @@
</small></pre><pre class="diff" id="context"> */
package org.codehaus.spice.jervlet.impl.pico;
</pre><pre class="diff" id="added">+import java.util.Map;
+
+import org.codehaus.spice.jervlet.containers.jetty.DefaultJettyContainer;
+import org.codehaus.spice.jervlet.ContextHandler;
</pre><pre class="diff" id="context"> import org.nanocontainer.script.NullNanoContainerBuilderDecorationDelegate;
</pre><pre class="diff" id="added">+import org.nanocontainer.NanoContainer;
+import org.picocontainer.MutablePicoContainer;
</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="added">+ public Object createNode( Object name, Map attributes, Object parent )
+ {
<a name="task1" />+ //<span class="task">TODO</span> check parent is a NanoContainer TDD-style
+ if( "webserver".equals( name ))
+ {
+ final MutablePicoContainer pico = ( (NanoContainer)parent ).getPico();
+
+ pico.registerComponentImplementation( DefaultJettyContainer.class );
+ pico.registerComponentImplementation( PicoJettyContainer.class );
+
+ final PicoJettyContainer jetty =
+ (PicoJettyContainer)pico.getComponentInstance( PicoJettyContainer.class );
+
+ pico.registerComponentInstance( jetty.createContextHandler() );
+
+ return null;
+ }
+ else if( "webapp".equals( name ))
+ {
+ final MutablePicoContainer pico = ( (NanoContainer)parent ).getPico();
+ final ContextHandler contextHandler = (ContextHandler)pico.getComponentInstance( ContextHandler.class );
+
+ //contextHandler.addContext( new PicoContext() );
+
+ return null;
+ }
+
+ return super.createNode( name, attributes, parent );
+ }
</pre><pre class="diff" id="context"> }
</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>