[CVS spice] Modify existing nanocontainer testcase to build on new PicoJettyContainer. Add empty cxtor to same.
proyal-yCVjj/[email protected] 22 Aug 2005 00:38:55 -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/pico/<a href="#file1">PicoJettyContainer.java</a></tt></td><td align="right" id="added">+17</td><td align="right" id="removed">-13</td><td nowrap="nowrap" align="center">1.5 -> 1.6</td></tr>
<tr class="alt"><td><tt>java/org/codehaus/spice/jervlet/impl/pico/<a href="#file2">JervletNanoContainerBuilderDecorationDelegate.java</a></tt></td><td align="right" id="added">+11</td><td align="right" id="removed">-10</td><td nowrap="nowrap" align="center">1.3 -> 1.4</td></tr>
<tr><td><tt> /<a href="#file3">PicoContext.java</a></tt></td><td align="right" id="added">+8</td><td align="right" id="removed">-8</td><td nowrap="nowrap" align="center">1.1 -> 1.2</td></tr>
<tr class="alt"><td><tt> /<a href="#file4"><span id="removed">PicoJettyServer.java</span></a></tt></td><td></td><td align="right" id="removed">-60</td><td nowrap="nowrap">1.2 removed</td></tr>
<tr><td><tt>test/org/codehaus/spice/jervlet/containers/jetty/pico/<a href="#file5">PicoJettyContainerTestCase.java</a></tt></td><td align="right" id="added">+24</td><td align="right" id="removed">-28</td><td nowrap="nowrap" align="center">1.2 -> 1.3</td></tr>
<tr class="alt"><td><tt>test/org/codehaus/spice/jervlet/impl/pico/<a href="#file6">AnotherTestCase.java</a></tt></td><td align="right" id="added">+16</td><td align="right" id="removed">-20</td><td nowrap="nowrap" align="center">1.4 -> 1.5</td></tr>
<tr><td></td><td align="right" id="added">+76</td><td align="right" id="removed">-139</td><td></td></tr>
</table>
<small id="info">1 removed + 5 modified, total 6 files</small><br />
<pre class="comment">
Modify existing nanocontainer testcase to build on new PicoJettyContainer. Add empty cxtor to same.
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/containers/jetty/pico<br /></span>
<div class="fileheader"><big><b>PicoJettyContainer.java</b></big> <small id="info">1.5 -> 1.6</small></div>
<pre class="diff"><small id="info">diff -u -r1.5 -r1.6
--- PicoJettyContainer.java 21 Aug 2005 21:29:48 -0000 1.5
+++ PicoJettyContainer.java 22 Aug 2005 00:38:55 -0000 1.6
@@ -7,21 +7,14 @@
</small></pre><pre class="diff" id="context"> */
package org.codehaus.spice.jervlet.containers.jetty.pico;
</pre><pre class="diff" id="removed">-import java.io.File;
-import java.util.List;
-
-import org.picocontainer.Startable;
-
-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;
</pre><pre class="diff" id="added">+import org.codehaus.spice.jervlet.*;
</pre><pre class="diff" id="context"> import org.codehaus.spice.jervlet.containers.jetty.DefaultJettyContainer;
import org.codehaus.spice.jervlet.containers.jetty.JettyContainer;
import org.codehaus.spice.jervlet.containers.jetty.ShieldingJettyContainer;
</pre><pre class="diff" id="added">+import org.picocontainer.Startable;
+
+import java.io.File;
+import java.util.List;
</pre><pre class="diff" id="context">
/**
* Pico style component wrapping a Jetty Server
</pre><pre class="diff"><small id="info">@@ -41,6 +34,16 @@
</small></pre><pre class="diff" id="context"> private JettyContainer m_container;
/**
</pre><pre class="diff" id="added">+ * Create a new Pico style JettyContainer will NOOP monitors
+ *
+ * todo can these monitors be hooked into pico's {@link org.picocontainer.ComponentMonitor} support?
+ */
+ public PicoJettyContainer()
+ {
+ this( null, null );
+ }
+
+ /**
</pre><pre class="diff" id="context"> * Create a new Pico style JettyContainer.
*
* @param contextMonitor optional context monitor.
</pre><pre class="diff"><small id="info">@@ -71,7 +74,7 @@
</small></pre><pre class="diff" id="context"> {
if( null != configuration && configuration.shieldJetty() )
{
</pre><pre class="diff" id="removed">- <span id="removedchars">final </span>ShieldingJettyContainer shieldingJettyContainer =
</pre><pre class="diff" id="added">+ ShieldingJettyContainer shieldingJettyContainer =
</pre><pre class="diff" id="context"> new ShieldingJettyContainer();
shieldingJettyContainer.addJettyProperties(
configuration.getProperties() );
</pre><pre class="diff"><small id="info">@@ -95,6 +98,7 @@
</small></pre><pre class="diff" id="context"> m_container.setListenerMonitor( listenerMonitor );
}
}
</pre><pre class="diff" id="added">+
</pre><pre class="diff" id="context">
/**
* Start the Jetty container
</pre></div>
<hr /><a name="file2" /><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.3 -> 1.4</small></div>
<pre class="diff"><small id="info">diff -u -r1.3 -r1.4
--- JervletNanoContainerBuilderDecorationDelegate.java 9 Aug 2005 01:42:12 -0000 1.3
+++ JervletNanoContainerBuilderDecorationDelegate.java 22 Aug 2005 00:38:55 -0000 1.4
@@ -7,10 +7,7 @@
</small></pre><pre class="diff" id="context"> */
package org.codehaus.spice.jervlet.impl.pico;
</pre><pre class="diff" id="removed">-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.Map;
-
</pre><pre class="diff" id="added">+import org.codehaus.spice.jervlet.containers.jetty.pico.PicoJettyContainer;
</pre><pre class="diff" id="context"> import org.nanocontainer.NanoContainer;
import org.nanocontainer.script.NanoContainerMarkupException;
import org.nanocontainer.script.NullNanoContainerBuilderDecorationDelegate;
</pre><pre class="diff"><small id="info">@@ -19,29 +16,33 @@
</small></pre><pre class="diff" id="context"> import org.picocontainer.defaults.ComponentParameter;
import org.picocontainer.defaults.ConstantParameter;
</pre><pre class="diff" id="added">+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.Map;
+
</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( final Object name, final Map attributes, final Object parent )
</pre><pre class="diff" id="added">+ public Object createNode( Object name, Map attributes, Object parent )
</pre><pre class="diff" id="context"> {
//TODO check parent is a NanoContainer TDD-style
if( "webserver".equals( name ) )
{
</pre><pre class="diff" id="removed">- <span id="removedchars">final </span>MutablePicoContainer pico = ( (NanoContainer)parent ).getPico();
</pre><pre class="diff" id="added">+ MutablePicoContainer pico = ( (NanoContainer)parent ).getPico();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- pico.registerComponentImplementation( PicoJetty<span id="removedchars">Serv</span>er.class );
</pre><pre class="diff" id="added">+ pico.registerComponentImplementation( PicoJetty<span id="addedchars">Contain</span>er.class );
</pre><pre class="diff" id="context"> pico.registerComponentImplementation( PicoDefaultContextHandler.class );
return null;
}
else if( "webapp".equals( name ) )
{
</pre><pre class="diff" id="removed">- final MutablePicoContainer pico = ( (NanoContainer)parent ).getPico();
- final String context = (String)attributes.remove( "context" );
</pre><pre class="diff" id="added">+ MutablePicoContainer pico = ( (NanoContainer)parent ).getPico();
+ String context = (String)attributes.remove( "context" );
</pre><pre class="diff" id="context"> //TODO should likely attempt as a URL, then if that fails, treat as a file (relative to working dir)
</pre><pre class="diff" id="removed">- <span id="removedchars">final </span>String warPath = (String)attributes.remove( "warPath" );
</pre><pre class="diff" id="added">+ String warPath = (String)attributes.remove( "warPath" );
</pre><pre class="diff" id="context">
try
{
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">spice/components/jervlet/src/java/org/codehaus/spice/jervlet/impl/pico<br /></span>
<div class="fileheader"><big><b>PicoContext.java</b></big> <small id="info">1.1 -> 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- PicoContext.java 9 Aug 2005 01:42:12 -0000 1.1
+++ PicoContext.java 22 Aug 2005 00:38:55 -0000 1.2
@@ -7,24 +7,24 @@
</small></pre><pre class="diff" id="context"> */
package org.codehaus.spice.jervlet.impl.pico;
</pre><pre class="diff" id="removed">-import java.net.URL;
-
-import org.picocontainer.Startable;
</pre><pre class="diff" id="context"> import org.codehaus.spice.jervlet.ContextHandler;
import org.codehaus.spice.jervlet.Instantiator;
import org.codehaus.spice.jervlet.impl.DefaultContext;
</pre><pre class="diff" id="added">+import org.picocontainer.Startable;
+
+import java.net.URL;
</pre><pre class="diff" id="context">
/**
* @author <a href="mailto:[email protected]">peter royal</a>
*/
public class PicoContext extends DefaultContext implements Startable
{
</pre><pre class="diff" id="removed">- private ContextHandler m_contextHandler;
</pre><pre class="diff" id="added">+ private <span id="addedchars">final </span>ContextHandler m_contextHandler;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- public PicoContext( final ContextHandler contextHandler,
- final String context,
- final URL resource,
- final Instantiator instantiator )
</pre><pre class="diff" id="added">+ public PicoContext( ContextHandler contextHandler,
+ String context,
+ URL resource,
+ Instantiator instantiator )
</pre><pre class="diff" id="context"> {
super(context, null, resource, false, instantiator);
</pre></div>
<hr /><a name="file4" /><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>PicoJettyServer.java</b></big> <small id="info">removed after 1.2</small></div>
<pre class="diff"><small id="info">diff -N PicoJettyServer.java
--- PicoJettyServer.java 9 Aug 2005 01:42:37 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,60 +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.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;
-
-/**
- * TODO 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="file5" /><div class="file">
<span class="pathname">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/containers/jetty/pico<br /></span>
<div class="fileheader"><big><b>PicoJettyContainerTestCase.java</b></big> <small id="info">1.2 -> 1.3</small></div>
<pre class="diff"><small id="info">diff -u -r1.2 -r1.3
--- PicoJettyContainerTestCase.java 12 Aug 2005 11:37:49 -0000 1.2
+++ PicoJettyContainerTestCase.java 22 Aug 2005 00:38:55 -0000 1.3
@@ -8,22 +8,20 @@
</small></pre><pre class="diff" id="context"> package org.codehaus.spice.jervlet.containers.jetty.pico;
import junit.framework.TestCase;
</pre><pre class="diff" id="removed">-
-import java.util.Properties;
-import java.io.File;
-import java.net.URL;
-import java.net.MalformedURLException;
-
-import org.codehaus.spice.jervlet.impl.*;
-import org.codehaus.spice.jervlet.impl.pico.PicoInstantiator;
-import org.codehaus.spice.jervlet.ContextHandler;
</pre><pre class="diff" id="context"> import org.codehaus.spice.jervlet.Context;
</pre><pre class="diff" id="added">+import org.codehaus.spice.jervlet.ContextHandler;
</pre><pre class="diff" id="context"> import org.codehaus.spice.jervlet.Instantiator;
import org.codehaus.spice.jervlet.Listener;
</pre><pre class="diff" id="removed">-
</pre><pre class="diff" id="added">+import org.codehaus.spice.jervlet.impl.*;
+import org.codehaus.spice.jervlet.impl.pico.PicoInstantiator;
</pre><pre class="diff" id="context"> import org.picocontainer.MutablePicoContainer;
import org.picocontainer.defaults.DefaultPicoContainer;
</pre><pre class="diff" id="added">+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
</pre><pre class="diff" id="context"> /**
* TestCase for PicoJettyContainer
*
</pre><pre class="diff"><small id="info">@@ -47,7 +45,7 @@
</small></pre><pre class="diff" id="context"> */
public void testEmpty() throws Exception
{
</pre><pre class="diff" id="removed">- PicoJettyContainer container = new PicoJettyContainer(<span id="removedchars"> null, null, null </span>);
</pre><pre class="diff" id="added">+ PicoJettyContainer container = new PicoJettyContainer();
</pre><pre class="diff" id="context"> container.start();
container.stop();
}
</pre><pre class="diff"><small id="info">@@ -183,7 +181,7 @@
</small></pre><pre class="diff" id="context"> * Create a basic context, using the standard servlet
* instantiator.
*/
</pre><pre class="diff" id="removed">- private Context getStandardContext( <span id="removedchars">final </span>String filePath )
</pre><pre class="diff" id="added">+ private Context getStandardContext( String filePath )
</pre><pre class="diff" id="context"> throws MalformedURLException
{
String path = "context" + m_count++;
</pre><pre class="diff"><small id="info">@@ -192,23 +190,22 @@
</small></pre><pre class="diff" id="context"> boolean extractWAR = false;
Instantiator instantiator = new StandardServletInstantiator();
</pre><pre class="diff" id="removed">- DefaultContext context = new DefaultContext( path,
- virtualHosts,
- resource,
- extractWAR,
- instantiator );
- return context;
</pre><pre class="diff" id="added">+ return new DefaultContext( path,
+ virtualHosts,
+ resource,
+ extractWAR,
+ instantiator );
</pre><pre class="diff" id="context"> }
/**
* Create a Pico context, using <code>PicoInstantiator</code>.
*
</pre><pre class="diff" id="removed">- * @filePath path to the web resource
- * @pico a pico container for this context
</pre><pre class="diff" id="added">+ * @param filePath path to the web resource
+ * @param pico container for this context
</pre><pre class="diff" id="context"> * (used when instantiation servlets)
*/
</pre><pre class="diff" id="removed">- private Context getPicoContext( final String filePath,
- final MutablePicoContainer pico )
</pre><pre class="diff" id="added">+ private Context getPicoContext( String filePath,
+ MutablePicoContainer pico )
</pre><pre class="diff" id="context"> throws MalformedURLException
{
String path = "context" + m_count++;
</pre><pre class="diff"><small id="info">@@ -217,11 +214,10 @@
</small></pre><pre class="diff" id="context"> boolean extractWAR = false;
Instantiator instantiator = new PicoInstantiator( pico );
</pre><pre class="diff" id="removed">- DefaultContext context = new DefaultContext( path,
- virtualHosts,
- resource,
- extractWAR,
- instantiator );
- return context;
</pre><pre class="diff" id="added">+ return new DefaultContext( path,
+ virtualHosts,
+ resource,
+ extractWAR,
+ instantiator );
</pre><pre class="diff" id="context"> }
}
</pre></div>
<hr /><a name="file6" /><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.4 -> 1.5</small></div>
<pre class="diff"><small id="info">diff -u -r1.4 -r1.5
--- AnotherTestCase.java 9 Aug 2005 01:42:12 -0000 1.4
+++ AnotherTestCase.java 22 Aug 2005 00:38:55 -0000 1.5
@@ -1,11 +1,5 @@
</small></pre><pre class="diff" id="context"> package org.codehaus.spice.jervlet.impl.pico;
</pre><pre class="diff" id="removed">-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-
</pre><pre class="diff" id="context"> import groovy.lang.Binding;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyCodeSource;
</pre><pre class="diff"><small id="info">@@ -20,21 +14,23 @@
</small></pre><pre class="diff" id="context"> import org.picocontainer.defaults.ObjectReference;
import org.picocontainer.defaults.SimpleReference;
</pre><pre class="diff" id="added">+import java.io.*;
+
</pre><pre class="diff" id="context"> public class AnotherTestCase extends TestCase
{
public void testJervletNanoContainerBuilderDecorationDelegate() throws Exception
{
</pre><pre class="diff" id="removed">- final InputStream script = getClass().getResourceAsStream( "delegate.groovy" );
- final PicoContainer pico = createContainer( new InputStreamReader( script ) );
</pre><pre class="diff" id="added">+ InputStream script = getClass().getResourceAsStream( "delegate.groovy" );
+ PicoContainer pico = createContainer( new InputStreamReader( script ) );
</pre><pre class="diff" id="context"> assertNotNull("expected ContextHandler in picocontainer", pico.getComponentInstanceOfType( ContextHandler.class));
}
</pre><pre class="diff" id="removed">- protected PicoContainer createContainer( <span id="removedchars">final </span>Reader reader ) throws CompilationFailedException
</pre><pre class="diff" id="added">+ protected PicoContainer createContainer( Reader reader ) throws CompilationFailedException
</pre><pre class="diff" id="context"> {
</pre><pre class="diff" id="removed">- final ObjectReference containerRef = new SimpleReference();
- final ObjectReference parentContainerRef = new SimpleReference();
- final PicoContainer parent = new DefaultPicoContainer();
- final GroovyContainerBuilder builder = new GroovyContainerBuilder( reader, getClass().getClassLoader() );
</pre><pre class="diff" id="added">+ ObjectReference containerRef = new SimpleReference();
+ ObjectReference parentContainerRef = new SimpleReference();
+ PicoContainer parent = new DefaultPicoContainer();
+ GroovyContainerBuilder builder = new GroovyContainerBuilder( reader, getClass().getClassLoader() );
</pre><pre class="diff" id="context">
parentContainerRef.set( parent );
builder.buildContainer( containerRef, parentContainerRef, "SOME_SCOPE", true );
</pre><pre class="diff"><small id="info">@@ -71,16 +67,16 @@
</small></pre><pre class="diff" id="context"> assertEquals( "", "" );
}
</pre><pre class="diff" id="removed">- protected void doGroovy( <span id="removedchars">final </span>InputStream is ) throws CompilationFailedException
</pre><pre class="diff" id="added">+ protected void doGroovy( InputStream is ) throws CompilationFailedException
</pre><pre class="diff" id="context"> {
</pre><pre class="diff" id="removed">- Script groovyScript;
- final GroovyClassLoader loader = new GroovyClassLoader( getClass().getClassLoader() );
- final GroovyCodeSource groovyCodeSource = new GroovyCodeSource( is,
</pre><pre class="diff" id="added">+ GroovyClassLoader loader = new GroovyClassLoader( getClass().getClassLoader() );
+
+ GroovyCodeSource groovyCodeSource = new GroovyCodeSource( is,
</pre><pre class="diff" id="context"> "nanocontainer.groovy",
"groovyGeneratedForNanoContainer" );
</pre><pre class="diff" id="removed">- final Class scriptClass = loader.parseClass( groovyCodeSource );
- groovyScript = InvokerHelper.createScript( scriptClass, null );
- final Binding binding = new Binding();
</pre><pre class="diff" id="added">+ Class scriptClass = loader.parseClass( groovyCodeSource );
+ Script groovyScript = InvokerHelper.createScript( scriptClass, null );
+ Binding binding = new Binding();
</pre><pre class="diff" id="context"> groovyScript.setBinding( binding );
groovyScript.run();
}
</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>