You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by hl...@apache.org on 2003/06/12 22:57:40 UTC

cvs commit: jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/ant ConstructRegistry.java

hlship      2003/06/12 13:57:40

  Modified:    hivemind/src/test/hivemind/test/ant
                        TestManifestClassPath.java
               hivemind/xdocs configuration.xml navigation.xml services.xml
               hivemind/xdocs/ant index.xml
               hivemind/src/test/hivemind/test HiveMindSuite.java
                        HiveMindTestCase.java
               hivemind maven.xml project.properties
               hivemind/src/java/org/apache/commons/hivemind HiveMind.java
  Added:       hivemind/src/test/hivemind/test/ant
                        TestConstructRegistry.java
               hivemind/xdocs/ant ConstructRegistry.xml
               hivemind/xdocs/images InterceptorStack.png
               hivemind/src/test-data/TestConstructRegistry testBasic.xml
                        testUptoDate.xml
               hivemind/src/images InterceptorStack.psp
               hivemind/src/java/org/apache/commons/hivemind/ant
                        ConstructRegistry.java
  Log:
  Add ConstructRegistry Ant task.
  Use the ManifestClassPath Ant task when building the HiveMind JAR.
  Add an image to illustrate interceptors.
  
  Revision  Changes    Path
  1.3       +27 -50    jakarta-commons-sandbox/hivemind/src/test/hivemind/test/ant/TestManifestClassPath.java
  
  Index: TestManifestClassPath.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/ant/TestManifestClassPath.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestManifestClassPath.java	10 Jun 2003 21:29:25 -0000	1.2
  +++ TestManifestClassPath.java	12 Jun 2003 20:57:39 -0000	1.3
  @@ -67,36 +67,37 @@
   import org.apache.tools.ant.Target;
   import org.apache.tools.ant.types.Path;
   
  +/**
  + * Tests the {@link org.apache.commons.hivemind.ant.ManifestClassPath}
  + * Ant task.
  + *
  + * @author Howard Lewis Ship
  + * @version $Id$
  + */
   public class TestManifestClassPath extends HiveMindTestCase
   {
  -    public class Driver extends ManifestClassPath
  -    {
  -        public Driver()
  -        {
  -            project = new Project();
  -            project.init();
  -
  -            taskType = "manifestClassPath";
  -            taskName = "manfiestClassPath";
  -
  -            target = new Target();
  -        }
  -    }
  +    protected Project _project = new Project();
   
       public TestManifestClassPath(String name)
       {
           super(name);
       }
   
  -    public void testSimple() throws Exception
  +    protected ManifestClassPath create()
       {
  -        Project p = new Project();
           Target t = new Target();
   
  -        ManifestClassPath mcp = new ManifestClassPath();
  -        mcp.setProject(p);
  -        mcp.setOwningTarget(t);
  -        mcp.setTaskName("manifestClassPath");
  +        ManifestClassPath result = new ManifestClassPath();
  +        result.setProject(_project);
  +        result.setOwningTarget(t);
  +        result.setTaskName("manifestClassPath");
  +
  +        return result;
  +    }
  +
  +    public void testSimple() throws Exception
  +    {
  +        ManifestClassPath mcp = create();
   
           mcp.setProperty("output");
   
  @@ -114,18 +115,12 @@
   
           mcp.execute();
   
  -        assertEquals("hivemodule.xml HiveMind.properties", p.getProperty("output"));
  +        assertEquals("hivemodule.xml HiveMind.properties", _project.getProperty("output"));
       }
   
       public void testDirectory() throws Exception
       {
  -        Project p = new Project();
  -        Target t = new Target();
  -
  -        ManifestClassPath mcp = new ManifestClassPath();
  -        mcp.setProject(p);
  -        mcp.setOwningTarget(t);
  -        mcp.setTaskName("manifestClassPath");
  +        ManifestClassPath mcp = create();
   
           mcp.setProperty("output");
   
  @@ -155,18 +150,12 @@
   
           assertEquals(
               "META-INF/hivemodule.xml java/org/apache/commons/hivemind/HiveMind.properties",
  -            p.getProperty("output"));
  +            _project.getProperty("output"));
       }
   
       public void testEmpty() throws Exception
       {
  -        Project p = new Project();
  -        Target t = new Target();
  -
  -        ManifestClassPath mcp = new ManifestClassPath();
  -        mcp.setProject(p);
  -        mcp.setOwningTarget(t);
  -        mcp.setTaskName("manifestClassPath");
  +        ManifestClassPath mcp = create();
   
           mcp.setProperty("zap");
   
  @@ -176,19 +165,13 @@
   
           mcp.execute();
   
  -        assertEquals("", p.getProperty("zap"));
  +        assertEquals("", _project.getProperty("zap"));
   
       }
   
       public void testNoProperty() throws Exception
       {
  -        Project p = new Project();
  -        Target t = new Target();
  -
  -        ManifestClassPath mcp = new ManifestClassPath();
  -        mcp.setProject(p);
  -        mcp.setOwningTarget(t);
  -        mcp.setTaskName("manifestClassPath");
  +        ManifestClassPath mcp = create();
   
           mcp.createClasspath();
   
  @@ -207,13 +190,7 @@
   
       public void testNoClasspath() throws Exception
       {
  -        Project p = new Project();
  -        Target t = new Target();
  -
  -        ManifestClassPath mcp = new ManifestClassPath();
  -        mcp.setProject(p);
  -        mcp.setOwningTarget(t);
  -        mcp.setTaskName("manifestClassPath");
  +        ManifestClassPath mcp = create();
   
           mcp.setProperty("bar");
   
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/test/hivemind/test/ant/TestConstructRegistry.java
  
  Index: TestConstructRegistry.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 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 (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.
   * ====================================================================
   *
   * 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 hivemind.test.ant;
  
  import hivemind.test.HiveMindTestCase;
  
  import java.io.BufferedInputStream;
  import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.LineNumberReader;
  
  import org.apache.commons.hivemind.ant.ConstructRegistry;
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Target;
  import org.apache.tools.ant.types.Path;
  
  public class TestConstructRegistry extends HiveMindTestCase
  {
      protected Project _project = new Project();
  
      public TestConstructRegistry(String name)
      {
          super(name);
      }
  
      protected ConstructRegistry create()
      {
          Target t = new Target();
  
          ConstructRegistry result = new ConstructRegistry();
          result.setProject(_project);
          result.setOwningTarget(t);
          result.setTaskName("constructRegistry");
  
          return result;
      }
  
      public void testNoFile() throws Exception
      {
          ConstructRegistry cr = create();
  
          try
          {
              cr.execute();
              unreachable();
          }
          catch (BuildException ex)
          {
              checkException(ex, "You must specify an output file");
          }
      }
  
      public void testNoDescriptors() throws Exception
      {
          ConstructRegistry cr = create();
  
          File f = File.createTempFile("registry-", ".xml");
  
          cr.setOutput(f);
  
          assertSame(f, cr.getOutput());
  
          try
          {
              cr.execute();
              unreachable();
          }
          catch (BuildException ex)
          {
              checkException(ex, "You must specify a set of module descriptors");
          }
  
      }
  
      public void testBasic() throws Exception
      {
          ConstructRegistry cr = create();
  
          Path p = cr.createDescriptors();
  
          p.createPath().setLocation(new File("src/META-INF/hivemodule.xml"));
          p.createPath().setLocation(new File("src/test/hivemind/test/config/ValueVariables.xml"));
  
          File output = File.createTempFile("registry-", ".xml");
  
          // Delete the file, to force the task to re-create it.
  
          output.delete();
  
          cr.setOutput(output);
  
          cr.execute();
  
          compare(output, "src/test-data/TestConstructRegistry/testBasic.xml");
      }
  
      public void testUptoDate() throws Exception
      {
          ConstructRegistry cr = create();
  
          Path p = cr.createDescriptors();
  
          p.createPath().setLocation(new File("src/META-INF/hivemodule.xml"));
          p.createPath().setLocation(new File("src/test/hivemind/test/config/CheckRequired.xml"));
  
          File output = File.createTempFile("registry-", ".xml");
  
          // Delete the file, to force the task to re-create it.
  
          output.delete();
  
          cr.setOutput(output);
  
          cr.execute();
  
          compare(output, "src/test-data/TestConstructRegistry/testUptoDate.xml");
  
          long stamp = output.lastModified();
  
          cr.execute();
  
          assertEquals(stamp, output.lastModified());
      }
  
      protected void compare(File actual, String expectedPath) throws Exception
      {
          String expectedContent = readFile(new File(expectedPath));
          String actualContent = readFile(actual);
  
          assertEquals(expectedContent, actualContent);
      }
  
      protected String readFile(File f) throws Exception
      {
          InputStream in = new FileInputStream(f);
          BufferedInputStream bin = new BufferedInputStream(in);
          InputStreamReader reader = new InputStreamReader(bin);
          BufferedReader br = new BufferedReader(reader);
          LineNumberReader r = new LineNumberReader(br);
  
          StringBuffer buffer = new StringBuffer();
  
          while (true)
          {
              String line = r.readLine();
  
              if (line == null)
                  break;
  
              buffer.append(line);
              buffer.append("\n");
          }
  
          r.close();
  
          return buffer.toString();
      }
  
  }
  
  
  
  1.2       +5 -5      jakarta-commons-sandbox/hivemind/xdocs/configuration.xml
  
  Index: configuration.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/configuration.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- configuration.xml	11 Jun 2003 18:43:12 -0000	1.1
  +++ configuration.xml	12 Jun 2003 20:57:39 -0000	1.2
  @@ -138,7 +138,7 @@
   HiveMind supports this notion through <em>substitution variables</em>.  These are references to values 
   that are supplied at runtime.  Substitution variables can appear inside literal values and OGNL expressions (in
   a module descriptor).  In addition, when the &xml; element reads an external XML file, substitution variables
  -in attribute and inside element content are expanded.
  +in attributes and inside element content are expanded.
   </p>
   
   <p>
  @@ -196,8 +196,8 @@
   	<li><strong>Why contribute objects?  Why not just strings, or just XML?</strong>
   	
   	<p>
  -	The whole point of HiveMind is to reduce code clutter.  When configuration data is just strings
  -	(in a .properties file) or just XML, that puts a lot of burden on the developer who
  +	A central goal of HiveMind is to reduce code clutter.  When configuration data is just strings
  +	(in a .properties file) or just XML, that puts a lot of burden on the developer whose code
   	<em>reads</em> the configuration to then massage it into useful objects.  That kind of ad-hoc
   	code is notoriously buggy; in HiveMind it is almost entirely absent.  Instead, all the XML parsing
   	occurs inside HiveMind, which typically creates and configures objects based on the XML (with exceptional
  @@ -206,7 +206,7 @@
   	
   	<p>
   	You can still limit yourself to strings, and you can even store configuration data as
  -	XML (that you must interpret yourself), but the path of least resistance it
  +	XML (that you must interpret yourself), but the path of least resistance is
   	to use &create-instance; and nested &set; elements to create the objects to be contributed.
   	</p>
   		
  
  
  
  1.5       +1 -0      jakarta-commons-sandbox/hivemind/xdocs/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/navigation.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- navigation.xml	11 Jun 2003 18:43:12 -0000	1.4
  +++ navigation.xml	12 Jun 2003 20:57:39 -0000	1.5
  @@ -11,6 +11,7 @@
   			<item name="Module Descriptor" href="/descriptor.html"/>
   			<item name="Ant Tasks" href="/ant/index.html" collapse="true">
   				<item name="ManifestClassPath" href="/ant/ManifestClassPath.html"/>
  +				<item name="ConstructRegistry" href="/ant/ConstructRegistry.html"/>	
   			</item>
   		</menu>
   	</body>
  
  
  
  1.6       +15 -7     jakarta-commons-sandbox/hivemind/xdocs/services.xml
  
  Index: services.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/services.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- services.xml	10 Jun 2003 17:58:20 -0000	1.5
  +++ services.xml	12 Jun 2003 20:57:39 -0000	1.6
  @@ -81,12 +81,20 @@
   					contributions. If the order in which interceptors are applied is
   					important, then the optional order attribute can be specified; it is
   					used to sort the interceptors into the order in which they will be
  -					applied. The default order is 0. Low numbers are executed first, and
  -					are therefore "closer" to the core instance. Larger numbers are
  -					executed later, and are "closer" to the client code. So you might use
  -					an order of 200 for a logging interceptor, and an order of 100 for a
  -					performance monitor interceptor. The logging interceptor will execute
  -					before the performance monitor, and so won't affect its timing.</p>
  +					applied.</p>
  +					
  +				<img src="images/InterceptorStack.png"/>
  +				
  +				<p>
  +				The lowest order ("Security", with an order of 100) is applied first, wrapping around
  +				the core implementation.  Then comes "Performance" and last "Logging".  When a client
  +				invokes a method, it is really invoking it on the "Logging" interceptor, which then re-invokes the method
  +				on the "Performance" interceptor, and so in, down to the core implementation.  Each interceptor
  +				can perform work before and/or after re-invoking the method on the next layer.  In this example,
  +				"Logging" was given a high order so that it wouldn't affect the "Performance" interceptor.  Security
  +				was given a lower order than "Performance" so that the time for security checks would be included in the
  +				"Performance" analysis.
  +				</p>
   			</subsection>
   		</section>
   		<section name="A short example">
  
  
  
  1.2       +7 -1      jakarta-commons-sandbox/hivemind/xdocs/ant/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/ant/index.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- index.xml	10 Jun 2003 17:58:19 -0000	1.1
  +++ index.xml	12 Jun 2003 20:57:39 -0000	1.2
  @@ -36,6 +36,12 @@
   						for ensuring that all modules will be in the classpath when
   						executing an application as an Enterprise Application Archive.</td>
   				</tr>
  +				
  +				<tr>
  +				<td><a href="ConstructRegistry.html">ConstructRegistry</a></td>	
  +				<td>org.apache.commons.hivemind.ant.ConstructRegistry</td>
  +				<td>Reads multiple HiveMind module descriptors, creating a single XML file from them.</td>
  +				</tr>
   			</table>
   		</section>
   	</body>
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/xdocs/ant/ConstructRegistry.xml
  
  Index: ConstructRegistry.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- $Id: ConstructRegistry.xml,v 1.1 2003/06/12 20:57:39 hlship Exp $ -->
  <document>
  	<properties>
  		<title>ConstructRegistry Ant Task</title>
  		<author email="hlship@apache.org">Howard M. Lewis Ship</author>
  	</properties>
  	<body>
  		<section name="Description">
  		
  		<p>
  Reads some number of HiveMind module descriptors and assembles a single registry file
  from them.  The output registry consists of a &lt;registry&gt; element which contains one &lt;module&gt;
  element for each module descriptor read.  This registry is useful for generating documentation.
  		</p>	
  			
  		<p>
  The registry XML is only updated if it does not exist, or if any of the module deployment descriptor
  is newer.
  		</p>
  		</section>
  		
  		<section name="Parameters">
  		
  		<table>
  			<tr>
  				<th>Attribute</th>	 <th>Description</th> <th>Required</th>
  			</tr>	
  			
  			<tr>
  				<td>output</td>	
  				<td>The file to write the registry to.</td>
  				<td>Yes</td>
  			</tr>
  
  		</table>
  			
  		</section>
  		
  		<section name="Parameters specified as nested elements">
  		  <subsection name="descriptors">
  		  
  		  <p>A path-like structure, used to identify which identifies
  		  	which HiveMind module descriptors
  		  	(<code>hivemodule.xml</code>) should be included. </p>
  		  	
  		  </subsection>	
  		</section>
  		
  		<section name="Examples">
  			
  <p>
  Generate a list of JARs inside the <code>${target}</code> directory as relative paths
  and use it to set the Class-Path manifest attribute.
  </p>
  
  <source><![CDATA[
  <constructregistry output="target/registry.xml">
    <descriptors>
      <fileset dir="src">
        <include name="**/hivemodule.xml"/>
      </fileset>
    </descriptors>
  </constructregistry>
  
  ]]>	
  </source>	
  		</section>
  	</body>
  </document>
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/xdocs/images/InterceptorStack.png
  
  	<<Binary file>>
  
  
  1.7       +9 -0      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/HiveMindSuite.java
  
  Index: HiveMindSuite.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/HiveMindSuite.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HiveMindSuite.java	10 Jun 2003 17:58:20 -0000	1.6
  +++ HiveMindSuite.java	12 Jun 2003 20:57:39 -0000	1.7
  @@ -57,6 +57,7 @@
   
   package hivemind.test;
   
  +import hivemind.test.ant.TestConstructRegistry;
   import hivemind.test.ant.TestManifestClassPath;
   import hivemind.test.config.TestConfiguration;
   import hivemind.test.external.TestExternalParser;
  @@ -66,6 +67,13 @@
   import junit.framework.Test;
   import junit.framework.TestSuite;
   
  +/**
  + * Composes a test suite for all the HiveMind tests. Not used by
  + * Maven, but handy inside Eclipse.
  + *
  + * @author Howard Lewis Ship
  + * @version $Id$
  + */
   public class HiveMindSuite extends TestSuite
   {
       public static Test suite()
  @@ -79,6 +87,7 @@
           suite.addTestSuite(TestRegistryBuilder.class);
           suite.addTestSuite(TestToString.class);
           suite.addTestSuite(TestManifestClassPath.class);
  +        suite.addTestSuite(TestConstructRegistry.class);
   
           return suite;
       }
  
  
  
  1.6       +2 -3      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/HiveMindTestCase.java
  
  Index: HiveMindTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/HiveMindTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HiveMindTestCase.java	6 Jun 2003 21:56:30 -0000	1.5
  +++ HiveMindTestCase.java	12 Jun 2003 20:57:39 -0000	1.6
  @@ -160,12 +160,11 @@
       }
   
       /**
  -     * Resets the brittle flag to false and flushes the Clover code-coverage cache to disk.
  +     * Resets the brittle flag to false.
        */
       protected void tearDown() throws Exception
       {
           HiveMind.setBrittle(false);
  -        HiveMind.flushCloverCache();
       }
   
       protected void unreachable()
  
  
  
  1.2       +31 -23    jakarta-commons-sandbox/hivemind/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/maven.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- maven.xml	9 Jun 2003 22:23:07 -0000	1.1
  +++ maven.xml	12 Jun 2003 20:57:39 -0000	1.2
  @@ -1,25 +1,33 @@
   <?xml version="1.0"?>
   <!-- $Id$ -->
  -
  -<project
  -  xmlns:m="maven"
  -  xmlns:ant="jelly:ant"  
  -  xmlns:j="jelly:core"
  -  xmlns:u="jelly:util">
  -
  -  <postGoal name="jar:jar">
  -
  -	<ant:echo>Adding META-INF/hivemodule.xml to ${maven.final.name}.jar</ant:echo>
  -  <ant:jar
  -      jarfile="${maven.build.dir}/${maven.final.name}.jar"
  -      basedir="${maven.build.dest}"
  -      update="true"
  -      excludes="${maven.jar.excludes}"> 
  -  
  -    <ant:fileset dir="src">
  -      <ant:include name="META-INF/**"/>
  -    </ant:fileset>
  -  </ant:jar>
  -  </postGoal>
  -
  +<project xmlns:j="jelly:core">
  +	<postGoal name="jar:jar">
  +		<echo>Adding META-INF/hivemodule.xml to ${maven.final.name}.jar</echo>
  +		
  +		<taskdef name="manifestClassPath" classname="org.apache.commons.hivemind.ant.ManifestClassPath">
  +		  <classpath>
  +		  	<pathelement location="${maven.build.dest}"/>	
  +		  </classpath>
  +		</taskdef>
  +		
  +		<manifestClassPath property="hivemind.manifest.class.path">
  +		  <classpath>
  +		    <path refid="maven.dependency.classpath"/>	
  +		  </classpath>	
  +		</manifestClassPath>
  +		
  +		<jar jarfile="${maven.build.dir}/${maven.final.name}.jar"
  +			basedir="${maven.build.dest}" update="true"
  +			excludes="${maven.jar.excludes}">
  +			
  +			<fileset dir="src">
  +				<include name="META-INF/**"/>
  +			</fileset>
  +			
  +			<manifest>
  +        <attribute name="Class-Path" value="${hivemind.manifest.class.path}"/>			
  +			</manifest>
  +			
  +		</jar>
  +	</postGoal>
   </project>
  
  
  
  1.3       +2 -1      jakarta-commons-sandbox/hivemind/project.properties
  
  Index: project.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/project.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- project.properties	9 Jun 2003 22:23:07 -0000	1.2
  +++ project.properties	12 Jun 2003 20:57:39 -0000	1.3
  @@ -2,3 +2,4 @@
   
   maven.username=hlship
   maven.xdoc.date=left
  +maven.junit.fork=yes
  
  
  
  1.4       +1 -11     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMind.java
  
  Index: HiveMind.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMind.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HiveMind.java	4 Jun 2003 23:52:49 -0000	1.3
  +++ HiveMind.java	12 Jun 2003 20:57:40 -0000	1.4
  @@ -192,14 +192,4 @@
       {
           _brittle = brittle;
       }
  -    
  -    /**
  -     * Utility invoked from unit test suite to force
  -     * a flush of cached code coverage data.
  -     * @see <a href="http://www.thecortex.net/clover/userguide/directives.html">Clover User Guide</a>
  -     */
  -    public static void flushCloverCache()
  -    {
  -		///CLOVER:FLUSH
  -    }
   }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/test-data/TestConstructRegistry/testBasic.xml
  
  Index: testBasic.xml
  ===================================================================
  <?xml version="1.0"?>
  <registry>
      <module id="org.apache.commons.hivemind" version="1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd">
          <configuration
              element-type="org.apache.commons.hivemind.VariableSourceContribution" id="VariableSource">
              <description>Provides a list of sources for substitution variables.</description>
          </configuration>
      </module>
      <module id="hivemind.test.config" version="1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd">
          <contribute-configuration configuration-id="org.apache.commons.hivemind.VariableSource">
              <create-instance class="org.apache.commons.hivemind.VariableSourceContribution">
                  <set-create
                      class="hivemind.test.external.PropertiesVariableSource" property="source"/>
              </create-instance>
          </contribute-configuration>
          <configuration element-type="java.lang.String" id="Dogs">
              <value>${dog}</value>
          </configuration>
      </module>
  </registry>
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/test-data/TestConstructRegistry/testUptoDate.xml
  
  Index: testUptoDate.xml
  ===================================================================
  <?xml version="1.0"?>
  <registry>
      <module id="org.apache.commons.hivemind" version="1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd">
          <configuration
              element-type="org.apache.commons.hivemind.VariableSourceContribution" id="VariableSource">
              <description>Provides a list of sources for substitution variables.</description>
          </configuration>
      </module>
      <module id="hivemind.test.config" version="1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd">
          <configuration count="1" element-type="java.lang.String" id="Required"/>
      </module>
  </registry>
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/images/InterceptorStack.psp
  
  	<<Binary file>>
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/ant/ConstructRegistry.java
  
  Index: ConstructRegistry.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 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 (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.
   * ====================================================================
   *
   * 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.apache.commons.hivemind.ant;
  
  import java.io.BufferedOutputStream;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.OutputStream;
  
  import javax.xml.parsers.DocumentBuilder;
  import javax.xml.parsers.DocumentBuilderFactory;
  import javax.xml.parsers.ParserConfigurationException;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  import org.apache.tools.ant.types.Path;
  import org.apache.xml.serialize.OutputFormat;
  import org.apache.xml.serialize.XMLSerializer;
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
  import org.w3c.dom.Node;
  
  /**
   * Reads some number of hivemodule deployment descriptors (specified as a fileset)
   * and builds a composite registry by simply concatinating them all. 
   *
   * 
   * @author Howard Lewis Ship
   * @version $Id: ConstructRegistry.java,v 1.1 2003/06/12 20:57:40 hlship Exp $
   */
  public class ConstructRegistry extends Task
  {
      private File _output;
      private Path _descriptorsPath;
  
      public void execute() throws BuildException
      {
          if (_output == null)
              throw new BuildException("You must specify an output file");
  
          if (_descriptorsPath == null)
              throw new BuildException("You must specify a set of module descriptors");
  
          long outputStamp = _output.lastModified();
  
          String[] paths = _descriptorsPath.list();
          int count = paths.length;
  
          boolean needsUpdate = false;
  
          File[] descriptors = new File[count];
  
          for (int i = 0; i < count; i++)
          {
              File f = new File(paths[i]);
  
              if (f.lastModified() > outputStamp)
                  needsUpdate = true;
  
              descriptors[i] = f;
          }
  
          if (needsUpdate)
          {
              Document registry = constructRegistry(descriptors);
  
              log("Writing registry to " + _output);
  
              writeDocument(registry, _output);
          }
  
      }
  
      protected DocumentBuilder getBuilder() throws ParserConfigurationException
      {
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  
          factory.setIgnoringComments(true);
  
          return factory.newDocumentBuilder();
      }
  
      protected Document constructRegistry(File[] moduleDescriptors) throws BuildException
      {
          try
          {
              DocumentBuilder builder = getBuilder();
  
              Document result = builder.newDocument();
  
              Element registry = result.createElement("registry");
  
              result.appendChild(registry);
  
              for (int i = 0; i < moduleDescriptors.length; i++)
              {
                  File f = moduleDescriptors[i];
  
                  log("Reading " + f);
  
                  Document module = builder.parse(f);
  
                  Element e = module.getDocumentElement();
  
                  Node eCopy = result.importNode(e, true);
  
                  registry.appendChild(eCopy);
              }
  
              return result;
          }
          catch (Exception ex)
          {
              throw new BuildException(ex);
          }
      }
  
      protected void writeDocument(Document document, File file) throws BuildException
      {
          try
          {
              OutputStream out = new FileOutputStream(file);
              BufferedOutputStream buffered = new BufferedOutputStream(out);
  
              writeDocument(document, buffered);
  
              buffered.close();
          }
          catch (IOException ex)
          {
              throw new BuildException(
                  "Unable to write registry to " + file + ": " + ex.getMessage(),
                  ex);
          }
      }
  
      protected void writeDocument(Document document, OutputStream out) throws IOException
      {
          XMLSerializer serializer = new XMLSerializer(out, new OutputFormat(document, null, true));
  
          serializer.serialize(document);
      }
  
      public Path createDescriptors()
      {
          _descriptorsPath = new Path(project);
  
          return _descriptorsPath;
      }
  
      public File getOutput()
      {
          return _output;
      }
  
      public void setOutput(File file)
      {
          _output = file;
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org