hlship 2003/06/17 14:13:07
Modified: hivemind/xdocs/images InterceptorStack.png
hivemind/src/java/org/apache/commons/hivemind/parse
HiveMind_1.0.xsd
hivemind/xdocs navigation.xml
hivemind maven.xml
hivemind/src/test/hivemind/test/services TestServices.java
hivemind/xdocs/ant ConstructRegistry.xml
hivemind/src/test/hivemind/test/ant
TestConstructRegistry.java
hivemind/src/META-INF hivemodule.xml
hivemind/src/test-data/TestConstructRegistry testBasic.xml
testUptoDate.xml
hivemind/src/images InterceptorStack.psp
hivemind/src/java/org/apache/commons/hivemind/ant
ConstructRegistry.java
Added: hivemind/src/test-data/sample sample-registry.xml
hivemind/src/test/hivemind/test/services TestLogging.xml
StoreAppender.java IDemoService.java
hivemind/src/xsl hivemind.css hivemind.xsl
hivemind/src/java/org/apache/commons/hivemind/impl
LoggingInterceptorFactory.java
hivemind/src/test/hivemind/test/services/impl
DemoService.java
Log:
Add in ability to generate HTML documentation from a set of module descriptors.
Revision Changes Path
1.2 +41 -37
jakarta-commons-sandbox/hivemind/xdocs/images/InterceptorStack.png
<<Binary file>>
1.5 +1 -11
jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/HiveMind_1.0.xsd
Index: HiveMind_1.0.xsd
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/HiveMind_1.0.xsd,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HiveMind_1.0.xsd 9 Jun 2003 22:23:08 -0000 1.4
+++ HiveMind_1.0.xsd 17 Jun 2003 21:13:04 -0000 1.5
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- edited with XMLSPY v5 rel. 4 U (http://www.xmlspy.com) by Howard M. Lewis Ship
(-self-) -->
+<!-- $Id$ -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="qualified">
<xs:simpleType name="occurance-count">
<xs:annotation>
@@ -294,16 +294,6 @@
<xs:documentation>Used to sort interceptor
contributions (from multiple Modules) into an order in which they will be applied.
Interceptors are applied in ascending order.</xs:documentation>
</xs:annotation>
</xs:attribute>
- </xs:complexType>
- </xs:element>
- <xs:element name="registry">
- <xs:annotation>
- <xs:documentation>Aggregates multiple modules together as a
single document.</xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:sequence maxOccurs="unbounded">
- <xs:element ref="module"/>
- </xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="qualified-id">
1.6 +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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- navigation.xml 12 Jun 2003 20:57:39 -0000 1.5
+++ navigation.xml 17 Jun 2003 21:13:04 -0000 1.6
@@ -9,6 +9,7 @@
<item name="Services" href="/services.html"/>
<item name="Configurations" href="/configuration.html"/>
<item name="Module Descriptor" href="/descriptor.html"/>
+ <item name="HiveMind Registry" href="/base-registry.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"/>
1.3 +40 -1 jakarta-commons-sandbox/hivemind/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/maven.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- maven.xml 12 Jun 2003 20:57:39 -0000 1.2
+++ maven.xml 17 Jun 2003 21:13:04 -0000 1.3
@@ -30,4 +30,43 @@
</jar>
</postGoal>
+
+ <postGoal name="xdoc:jelly-transform">
+
+ <!-- Some kind of voodoo magic I picked up from the docbook plugin. -->
+
+
${systemScope.setProperty('javax.xml.transform.TransformerFactory','org.apache.xalan.processor.TransformerFactoryImpl')}
+
+ <echo>Building HiveModule Registry docs ...</echo>
+
+ <taskdef name="constructRegistry"
classname="org.apache.commons.hivemind.ant.ConstructRegistry">
+ <classpath>
+ <pathelement location="${maven.build.dest}"/>
+ </classpath>
+ </taskdef>
+
+ <constructRegistry output="target/base-registry.xml">
+ <descriptors>
+ <fileset dir="src/META-INF">
+ <include name="hivemodule.xml"/>
+ </fileset>
+ </descriptors>
+
+ </constructRegistry>
+
+ <style in="target/base-registry.xml"
+ out="target/docs/base-registry.html"
+ style="src/xsl/hivemind.xsl"/>
+
+ <!-- Temporary, while testing the XSL stylesheet. -->
+
+ <style basedir="src/test-data/sample"
+ destdir="target/docs"
+ style="src/xsl/hivemind.xsl">
+ </style>
+
+ <copy todir="target/docs" file="src/xsl/hivemind.css"/>
+
+ </postGoal>
+
</project>
1.1
jakarta-commons-sandbox/hivemind/src/test-data/sample/sample-registry.xml
Index: sample-registry.xml
===================================================================
<?xml version="1.0"?>
<registry>
<module id="org.apache.commons.hivemind" uid="1" version="1.0.0">
<description>The master module.</description>
<dependency module-id="org.apache.commons.hivemind"/>
<meta key="key1" value="value1"/>
<meta key="key2" value="value2"/>
<library id="foo" version="1.0"/>
<library id="bar" version="2.0" export="true"/>
<configuration
element-type="org.apache.commons.hivemind.VariableSourceContribution"
id="org.apache.commons.hivemind.VariableSource" uid="2">
<description>Provides a list of sources for substitution
variables.</description>
<expression>foo.bar.baz</expression>
<value>zipzap</value>
<service-ref
service-id="org.apache.commons.hivemind.LoggingInterceptor"/>
<xml path="zigzap.xml"/>
<create-instance class="bip.bap.Boom"/>
<create-instance class="foo.bar.Baz">
<set-expression property="foo" expression="bar"/>
<set-expression property="baz">fubar</set-expression>
<set-create property="zip" class="org.foo.Bar"/>
<set-create property="zap" class="org.foo.Baz">
<set property="inner" value="level
3"/>
</set-create>
<set-factory property="fact"
service-id="org.apache.commons.hivemind.LoggingInterceptor"/>
<set-factory property="fact"
service-id="org.apache.commons.hivemind.LoggingInterceptor">
<set property="foo" value="bar"/>
<set property="baz">zip.zap.zoom!</set>
<set-service-ref property="service"
service-id="org.apache.commons.hivemind.LoggingInterceptor"/>
<set-xml property="element" path="zipdeedoo.xml"/>
</set-factory>
</create-instance>
<factory
service-id="org.apache.commons.hivemind.LoggingInterceptor"/>
<factory
service-id="org.apache.commons.hivemind.LoggingInterceptor">
<set property="foo" value="bar"/>
<set property="baz">zip.zap.zoom!</set>
<set-service-ref property="service"
service-id="org.apache.commons.hivemind.LoggingInterceptor"/>
<set-xml property="element" path="zipdeedoo.xml"/>
</factory>
</configuration>
<service id="org.apache.commons.hivemind.LoggingInterceptor"
interface="org.apache.commons.hivemind.IInterceptorFactory" uid="3">
<description>An interceptor factory for adding method
logging to a service.</description>
<create-instance
class="org.apache.commons.hivemind.impl.LoggingInterceptorFactory"/>
</service>
</module>
<module id="hivemind.test.config" uid="4" version="1.0.0">
<configuration count="1" element-type="java.lang.String"
id="hivemind.test.config.Required" uid="5"/>
</module>
<module id="zap.branigan" uid="6" version="1.0.1">
<service id="zap.branigan.Futurama" interface="futurama.Robot" uid="7">
<interceptor service-id="org.apache.commons.hivemind.LoggingInterceptor"
order="100"/>
<interceptor service-id="foo.bar.Baz"/>
</service>
<service id="zap.branigan.Magic"
interface="org.apache.commons.hivemind.IInterceptorFactory" uid="7"/>
<contribute-service
service-id="org.apache.commons.hivemind.LoggingInterceptor" uid="8">
<interceptor service-id="zap.branigan.Magic"/>
</contribute-service>
<contribute-configuration
configuration-id="org.apache.commons.hivemind.VariableSource" uid="9">
<value>foo</value>
</contribute-configuration>
</module>
</registry>
1.5 +73 -0
jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestServices.java
Index: TestServices.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestServices.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestServices.java 9 Jun 2003 22:23:08 -0000 1.4
+++ TestServices.java 17 Jun 2003 21:13:05 -0000 1.5
@@ -61,7 +61,16 @@
import hivemind.test.services.impl.CountFactory;
import hivemind.test.services.impl.TrackerFactory;
+import java.util.List;
+
import org.apache.commons.hivemind.IRegistry;
+import org.apache.commons.hivemind.impl.RegistryBuilder;
+import org.apache.commons.hivemind.parse.DescriptorParser;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.tapestry.ApplicationRuntimeException;
public class TestServices extends HiveMindTestCase
{
@@ -151,5 +160,69 @@
ICheckInitializeService.class);
assertEquals(true, c.didInitialize());
+ }
+
+ public void testLogging() throws Exception
+ {
+ RegistryBuilder b = new RegistryBuilder();
+ DescriptorParser p = new DescriptorParser();
+ b.processModule(_resolver, p.parse(getMasterModuleLocation()));
+ b.processModule(_resolver, p.parse(getLocation("TestLogging.xml")));
+
+ Logger logger = LogManager.getLogger("hivemind.test.services.Demo");
+ logger.removeAllAppenders();
+ logger.setLevel(Level.DEBUG);
+ logger.setAdditivity(false);
+
+ StoreAppender a = new StoreAppender();
+ logger.addAppender(a);
+
+ IRegistry r = b.constructRegistry();
+ IDemoService s =
+ (IDemoService) r.getService("hivemind.test.services.Demo",
IDemoService.class);
+
+ s.add(5, 3);
+
+ List l = a.getEvents();
+ assertEquals(2, l.size());
+
+ checkLoggingEvent("hivemind.test.services.Demo", "BEGIN add(5, 3)", l, 0);
+ checkLoggingEvent("hivemind.test.services.Demo", "END add() [8]", l, 1);
+
+ s.noResult();
+
+ l = a.getEvents();
+ assertEquals(2, l.size());
+
+ checkLoggingEvent("hivemind.test.services.Demo", "BEGIN noResult()", l, 0);
+ checkLoggingEvent("hivemind.test.services.Demo", "END noResult()", l, 1);
+
+ try
+ {
+ s.alwaysFail();
+ unreachable();
+ }
+ catch (ApplicationRuntimeException ex)
+ {
+ checkException(ex, "Failure in method alwaysFail.");
+ }
+
+ l = a.getEvents();
+ assertEquals(2, l.size());
+
+ checkLoggingEvent("hivemind.test.services.Demo", "BEGIN alwaysFail()", l,
0);
+ checkLoggingEvent(
+ "hivemind.test.services.Demo",
+ "EXCEPTION alwaysFail() --
org.apache.tapestry.ApplicationRuntimeException",
+ l,
+ 1);
+ }
+
+ private void checkLoggingEvent(String name, String message, List events, int
index)
+ {
+ LoggingEvent e = (LoggingEvent) events.get(index);
+
+ assertEquals("Logger name", name, e.getLoggerName());
+ assertEquals("Message", message, e.getMessage());
}
}
1.1
jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestLogging.xml
Index: TestLogging.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: TestLogging.xml,v 1.1 2003/06/17 21:13:05 hlship Exp $ -->
<module
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd"
id="hivemind.test.services"
version="1.0.0">
<service id="Demo" interface="hivemind.test.services.IDemoService">
<create-instance class="hivemind.test.services.impl.DemoService"/>
<interceptor service-id="org.apache.commons.hivemind.LoggingInterceptor"/>
</service>
</module>
1.1
jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/StoreAppender.java
Index: StoreAppender.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 [EMAIL PROTECTED]
*
* 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.services;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
/**
* Used to test logging provided by the [EMAIL PROTECTED]
org.apache.commons.hivemind.impl.LoggingInterceptorFactory}.
*
* @author Howard Lewis Ship
* @version $Id: StoreAppender.java,v 1.1 2003/06/17 21:13:05 hlship Exp $
*/
public class StoreAppender extends AppenderSkeleton
{
private List _events = new ArrayList(0);
/**
* Returns any accumulated events since the last invocations of the method.
* @return List of [EMAIL PROTECTED] LoggingEvent}.
*/
public List getEvents()
{
List result = new ArrayList(_events);
_events.clear();
return result;
}
protected void append(LoggingEvent event)
{
_events.add(event);
}
/**
* Does nothing.
*/
public void close()
{
}
/**
* Returns false.
*/
public boolean requiresLayout()
{
return false;
}
}
1.1
jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/IDemoService.java
Index: IDemoService.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 [EMAIL PROTECTED]
*
* 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.services;
/**
* A service interface used for testing the logging interceptor.
*
* @author Howard Lewis Ship
* @version $Id: IDemoService.java,v 1.1 2003/06/17 21:13:05 hlship Exp $
*/
public interface IDemoService extends ISimpleService
{
/**
* Used to test that void methods log properly.
*
*/
public void noResult();
/**
* Used to test runtime failures. This implementation
* always throws an exception.
*/
public void alwaysFail() throws RuntimeException;
}
1.1 jakarta-commons-sandbox/hivemind/src/xsl/hivemind.css
Index: hivemind.css
===================================================================
P {}
H1 {}
H2 {}
H3 {}
A {}
A:Visited {}
A:Active {}
A:Hover {}
BODY {
font-family : Trebuchet MS, San Serif;
}
TABLE.summary TH {
text-align : right;
border-style : dashed;
border-width : thin;
}
TABLE.summary TD {
border-style : dashed;
border-width : thin;
}
TABLE.summary TD.description {
font-style: italic;
padding-left: 20px;
}
TABLE.summary TH.subhead
{
text-align: center;
}
LI
{
list-style-type: none;
}
SPAN.missing
{
font-style: italic;
}
SPAN.tag
{
font-family: monospace;
color: Blue;
}
SPAN.attribute
{
font-family: monospace;
font-weight: bold;
color: Red;
}
SPAN.literal
{
font-family: monospace;
}
SPAN.expression
{
font-style: italic;
}
1.1 jakarta-commons-sandbox/hivemind/src/xsl/hivemind.xsl
Index: hivemind.xsl
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/registry">
<html>
<head>
<title>HiveMind Registry</title>
<link rel="STYLESHEET" type="text/css"
href="hivemind.css"/>
</head>
<body>
<h1>HiveMind Module Registry</h1>
<ul>
<xsl:apply-templates select="module"
mode="registry-toc">
<xsl:sort select="@id"/>
</xsl:apply-templates>
</ul>
<xsl:apply-templates select="module"
mode="module-summary">
<xsl:sort select="@id"/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="module" mode="registry-toc">
<li>
<a>
<xsl:attribute name="href">#<xsl:value-of
select="@uid"/></xsl:attribute>
<xsl:value-of select="@id"/>
</a>
</li>
</xsl:template>
<xsl:template match="module" mode="module-summary">
<hr/>
<h1> <xsl:attribute name="id"><xsl:value-of
select="@uid"/></xsl:attribute>
Module <xsl:value-of select="@id"/> </h1>
<table class="summary">
<tbody>
<tr>
<th>Version</th>
<td colspan="2">
<xsl:value-of select="@version"/>
</td>
</tr>
<tr>
<th>Class</th>
<td colspan="2">
<xsl:if test="not(@class)">
<span
class="missing">default</span>
</xsl:if>
<xsl:value-of select="@class"/>
</td>
</tr>
<xsl:if test="description">
<tr>
<td class="description" colspan="3">
<xsl:value-of
select="description"/>
</td>
</tr>
</xsl:if>
<xsl:if test="count(dependency)">
<tr>
<th>Dependencies</th>
<th class="subhead">Module</th>
<th class="subhead">Version</th>
</tr>
<xsl:for-each select="dependency">
<xsl:sort select="@module-id"/>
<tr>
<td/>
<td>
<a>
<xsl:attribute
name="href">#<xsl:value-of
select="/registry/[EMAIL PROTECTED] = current()/@module-id]/@uid"/></xsl:attribute>
<xsl:value-of
select="@module-id"/>
</a>
</td>
<td>
<xsl:if
test="not(@version)">
<span
class="missing">*</span>
</xsl:if>
<xsl:value-of
select="@version"/>
</td>
</tr>
</xsl:for-each>
</xsl:if>
<xsl:for-each select="library">
<xsl:sort select="@id"/>
<tr>
<th>
<xsl:if test="position() =
1">Libraries</xsl:if>
</th>
<td colspan="2"> <xsl:value-of
select="@id"/>-<xsl:value-of
select="@version"/>.jar
<xsl:if test="@export = 'true'">(exported)</xsl:if></td>
</tr>
</xsl:for-each>
<xsl:for-each select="meta">
<xsl:sort select="@key"/>
<xsl:if test="position() = 1">
<tr>
<th>Meta Data</th>
<th class="subhead">Key</th>
<th class="subhead">Value</th>
</tr>
</xsl:if>
<tr>
<th/>
<td>
<xsl:value-of select="@key"/>
</td>
<td>
<xsl:value-of select="@value"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
<!-- TODO: TOC for the Module -->
<xsl:apply-templates select="configuration">
<xsl:sort select="@id"/>
</xsl:apply-templates>
<xsl:apply-templates select="service">
<xsl:sort select="@id"/>
</xsl:apply-templates>
<xsl:apply-templates select="contribute-configuration">
<xsl:sort select="@configuration-id"/>
</xsl:apply-templates>
<xsl:apply-templates select="contribute-service">
<xsl:sort select="@service-id"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="configuration">
<h2> <xsl:attribute name="id"><xsl:value-of
select="@uid"/></xsl:attribute>
Configuration <xsl:value-of select="@id"/> </h2>
<table class="summary">
<tbody>
<tr>
<th>Element Type</th>
<td>
<xsl:value-of select="@element-type"/>
</td>
</tr>
<tr>
<th>Expected Count</th>
<td>
<xsl:if
test="not(@count)">unbounded</xsl:if>
<xsl:value-of select="@count"/>
</td>
</tr>
<tr>
<th>Cached</th>
<td>
<xsl:if
test="not(@cache-elements)">true</xsl:if>
<xsl:value-of
select="@cache-elements"/>
</td>
</tr>
<xsl:if test="description">
<tr>
<td colspan="2" class="description">
<xsl:value-of
select="description"/>
</td>
</tr>
</xsl:if>
</tbody>
</table>
<xsl:if test="*">
<ul>
<xsl:apply-templates/>
</ul>
</xsl:if>
</xsl:template>
<xsl:template match="contribute-configuration">
<h2> <xsl:attribute name="id"><xsl:value-of
select="@uid"/></xsl:attribute>
Contribute Configuration <xsl:value-of
select="@configuration-id"/> </h2>
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="service">
<h2> <xsl:attribute name="id"><xsl:value-of
select="@uid"/></xsl:attribute>
Service <xsl:value-of select="@id"/> </h2>
<table class="summary">
<tbody>
<tr>
<th>Interface</th>
<td>
<xsl:value-of select="@interface"/>
</td>
</tr>
<tr>
<th>Required</th>
<td>
<xsl:if
test="not(@required)">true</xsl:if>
<xsl:value-of select="@required"/>
</td>
</tr>
<xsl:if test="description">
<tr>
<td colspan="2" class="description">
<xsl:value-of
select="description"/>
</td>
</tr>
</xsl:if>
</tbody>
</table>
<xsl:if test="*">
<ul>
<xsl:apply-templates/>
</ul>
</xsl:if>
</xsl:template>
<xsl:template match="contribute-service">
<h2> <xsl:attribute name="id"><xsl:value-of
select="@uid"/></xsl:attribute>
Contribute Service <xsl:value-of select="@configuration-id"/>
</h2>
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="description">
<!-- Ignore, matched in places we'd rather not. -->
</xsl:template>
<xsl:template match="expression">
<li>
<span class="tag"><expression></span>
<span class="expression">
<xsl:value-of select="."/>
</span>
<span class="tag"></expression></span>
</li>
</xsl:template>
<xsl:template match="value">
<li>
<span class="tag"><value></span>
<span class="literal">
<xsl:value-of select="."/>
</span>
<span class="tag"></value></span>
</li>
</xsl:template>
<xsl:template match="service-ref">
<li> <span class="tag"><service-ref</span> <span class="attribute">
service-id</span>="<a> <xsl:attribute
name="href">#<xsl:value-of
select="/registry/module/[EMAIL PROTECTED] =
current()/@service-id]/@uid"/></xsl:attribute>
<xsl:value-of select="@service-id"/> </a>" <span
class="tag">/></span> </li>
</xsl:template>
<xsl:template match="xml">
<li> <span class="tag"><xml</span> <span class="attribute">
path</span>="
<xsl:value-of select="@path"/>" <span class="tag">/></span>
</li>
</xsl:template>
<xsl:template match="set-xml">
<li> <span class="tag"><set-xml</span> <span class="attribute">
property</span>
="<xsl:value-of select="@property"/>" <span class="attribute">
path</span>
="<xsl:value-of select="@path"/>" <span
class="tag">/></span> </li>
</xsl:template>
<xsl:template match="create-instance">
<li> <span class="tag"><create-instance</span> <span
class="attribute">
class</span>="<xsl:value-of select="@class"/>" <xsl:choose>
<xsl:when
test="*"> <span class="tag">></span> <ul>
<xsl:apply-templates/> </ul>
<span class="tag"></create-instance></span> </xsl:when>
<xsl:otherwise> <span class="tag">/></span>
</xsl:otherwise> </xsl:choose></li>
</xsl:template>
<xsl:template match="set-create">
<li> <span class="tag"><set-create</span> <span class="attribute">
property</span>="<xsl:value-of select="@property"/>" <span
class="attribute">class</span>="<xsl:value-of
select="@class"/>"
<xsl:choose> <xsl:when test="*"> <span class="tag">></span>
<ul>
<xsl:apply-templates/> </ul> <span
class="tag"></set-create></span> </xsl:when>
<xsl:otherwise> <span class="tag">/></span>
</xsl:otherwise> </xsl:choose></li>
</xsl:template>
<xsl:template match="factory">
<li> <span class="tag"><factory</span> <span class="attribute">
service-id</span>
="<a> <xsl:attribute name="href">#<xsl:value-of
select="/registry/module/[EMAIL PROTECTED] =
current()/@service-id]/@uid"/></xsl:attribute>
<xsl:value-of select="@service-id"/> </a>" <xsl:choose>
<xsl:when test="*"
> <span class="tag">></span> <ul> <xsl:apply-templates/>
</ul> <span
class="tag"></factory></span> </xsl:when>
<xsl:otherwise> <span
class="tag">/></span> </xsl:otherwise> </xsl:choose> </li>
</xsl:template>
<xsl:template match="set-factory">
<li> <span class="tag"><set-factory</span> <span class="attribute">
property</span>="<xsl:value-of select="@property"/>" <span
class="attribute">service-id</span>="<a> <xsl:attribute
name="href">#
<xsl:value-of
select="/registry/module/[EMAIL PROTECTED] =
current()/@service-id]/@uid"/></xsl:attribute>
<xsl:value-of select="@service-id"/> </a>" <xsl:choose>
<xsl:when test="*"
> <span class="tag">></span> <ul> <xsl:apply-templates/>
</ul> <span
class="tag"></set-factory></span> </xsl:when>
<xsl:otherwise> <span
class="tag">/></span> </xsl:otherwise> </xsl:choose> </li>
</xsl:template>
<xsl:template match="interceptor">
<li> <span class="tag"><interceptor</span> <span class="attribute">
service-id</span>="<a> <xsl:attribute
name="href">#<xsl:value-of
select="/registry/module/[EMAIL PROTECTED] =
current()/@service-id]/@uid"/></xsl:attribute>
<xsl:value-of select="@service-id"/> </a>"<xsl:if
test="@order"> <span
class="attribute">order</span>="<xsl:value-of
select="@order"/>"</xsl:if>
<span class="tag">/></span> </li>
</xsl:template>
<xsl:template match="set-expression">
<li> <span class="tag"><set-expression</span> <span
class="attribute">
property</span>="<xsl:value-of select="@property"/>" <xsl:if
test="@expression"> <span class="attribute">
expression</span>="<span
class="expression"><xsl:value-of
select="@expression"/></span>"</xsl:if>
<xsl:choose> <xsl:when test="normalize-space()"> <span
class="tag">></span>
<span class="expression"><xsl:value-of select="."/></span>
<span
class="tag"></set-expression></span> </xsl:when>
<xsl:otherwise>
<span class="tag">/></span> </xsl:otherwise> </xsl:choose>
</li>
</xsl:template>
<xsl:template match="set">
<li> <span class="tag"><set</span> <span class="attribute">
property</span>
="<xsl:value-of select="@property"/>" <xsl:if test="@value">
<span
class="attribute">value</span>="<span
class="literal"><xsl:value-of
select="@value"/></span>"</xsl:if> <xsl:choose> <xsl:when
test="normalize-space()"> <span class="tag">></span> <span
class="literal"><xsl:value-of select="."/></span> <span
class="tag"><
/set></span> </xsl:when> <xsl:otherwise> <span
class="tag">/></span></xsl:otherwise></xsl:choose></li>
</xsl:template>
<xsl:template match="set-service-ref">
<li> <span class="tag"><set-service-ref</span> <span
class="attribute">
property</span>="<xsl:value-of select="@property"/>" <span
class="attribute">service-id</span>="<a> <xsl:attribute
name="href">#
<xsl:value-of
select="/registry/module/[EMAIL PROTECTED] =
current()/@service-id]/@uid"/></xsl:attribute>
<xsl:value-of select="@service-id"/> </a>" <span
class="tag">/></span> </li>
</xsl:template>
</xsl:stylesheet>
1.1
jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/LoggingInterceptorFactory.java
Index: LoggingInterceptorFactory.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 [EMAIL PROTECTED]
*
* 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.impl;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.apache.commons.hivemind.IInterceptorFactory;
import org.apache.commons.hivemind.IInterceptorStack;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* An interceptor factory that adds logging capability to a service.
* The logging is based upon the Jakarta
* <a href="http://jakarta.apache.org/commons/logging.html">commons-logging</a>
toolkit,
* which makes
* it very transportable.
*
* <p>
* The interceptor will log entry to each method and exit from the method
* (with return value), plus log any exceptions thrown by the method.
* The logger used is the <em>id of the service</em>, which is not necessarily
* the name of the implementing class. Logging occurs at the debug level.
*
* @author Howard Lewis Ship
* @version $Id: LoggingInterceptorFactory.java,v 1.1 2003/06/17 21:13:06 hlship Exp
$
*/
public class LoggingInterceptorFactory implements IInterceptorFactory
{
private static class Handler implements InvocationHandler
{
private static final int BUFFER_SIZE = 100;
private Log _log;
private Object _inner;
private Handler(Log log, Object inner)
{
_log = log;
_inner = inner;
}
public Object invoke(Object proxy, Method method, Object[] args) throws
Throwable
{
boolean debug = _log.isDebugEnabled();
if (debug)
logEntry(method, args);
try
{
Object result = method.invoke(_inner, args);
if (debug)
logExit(method, result);
return result;
}
catch (InvocationTargetException ex)
{
Throwable t = ex.getTargetException();
logException(method, t);
throw t;
}
}
private void logEntry(Method m, Object[] args)
{
StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
buffer.append("BEGIN ");
buffer.append(m.getName());
buffer.append("(");
int count = (args == null) ? 0 : args.length;
for (int i = 0; i < count; i++)
{
Object arg = args[i];
if (i > 0)
buffer.append(", ");
buffer.append(arg);
}
buffer.append(")");
_log.debug(buffer.toString());
}
private void logExit(Method m, Object result)
{
StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
buffer.append("END ");
buffer.append(m.getName());
buffer.append("()");
if (m.getReturnType() != void.class)
{
buffer.append(" [");
buffer.append(result);
buffer.append("]");
}
_log.debug(buffer.toString());
}
private void logException(Method m, Throwable t)
{
StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
buffer.append("EXCEPTION ");
buffer.append(m.getName());
buffer.append("() -- ");
buffer.append(t.getClass().getName());
_log.debug(buffer.toString(), t);
}
}
public void createInterceptor(IInterceptorStack stack)
{
String id = stack.getServiceExtensionPoint().getExtensionPointId();
Log log = LogFactory.getLog(id);
ClassLoader loader =
stack.getServiceExtensionPoint().getModule().getResourceResolver().getClassLoader();
InvocationHandler handler = new Handler(log, stack.peek());
Object interceptor =
Proxy.newProxyInstance(loader, new Class[] {
stack.getServiceInterface()}, handler);
stack.push(interceptor);
}
}
1.2 +19 -3 jakarta-commons-sandbox/hivemind/xdocs/ant/ConstructRegistry.xml
Index: ConstructRegistry.xml
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/hivemind/xdocs/ant/ConstructRegistry.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConstructRegistry.xml 12 Jun 2003 20:57:39 -0000 1.1
+++ ConstructRegistry.xml 17 Jun 2003 21:13:06 -0000 1.2
@@ -18,6 +18,22 @@
The registry XML is only updated if it does not exist, or if any of the module
deployment descriptor
is newer.
</p>
+
+
+ <p>
+ The resulting XML file does not conform to the hivemind module deployment
+ descriptor schema. The following changes occur:
+ <ul>
+ <li>The outermost element is <registry> (which contains a list of
<module>)</li>
+ <li>Any namespace-related attributes are stripped from <module></li>
+ <li>A unique id (unique within the file) is assigned to each <module>,
<configuration>,
+ <service>, <configuration-contribution> and
<service-contribution> (this is
+ to make it easier to generate links and anchors)</li>
+ <li>The <code>id</code> attribute of <configuration> and <service> is
+ converted from a local id to a full id (by prefixing with the module id)</li>
+ </ul>
+ </p>
+
</section>
<section name="Parameters">
@@ -50,8 +66,8 @@
<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.
+Create <code>target/registry.xml</code> from all <code>hivemodule.xml</code>
descriptors
+found inside the <code>src</code> directory.
</p>
<source><![CDATA[
1.2 +10 -3
jakarta-commons-sandbox/hivemind/src/test/hivemind/test/ant/TestConstructRegistry.java
Index: TestConstructRegistry.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/ant/TestConstructRegistry.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestConstructRegistry.java 12 Jun 2003 20:57:39 -0000 1.1
+++ TestConstructRegistry.java 17 Jun 2003 21:13:06 -0000 1.2
@@ -73,6 +73,13 @@
import org.apache.tools.ant.Target;
import org.apache.tools.ant.types.Path;
+/**
+ * Tests for the [EMAIL PROTECTED]
org.apache.commons.hivemind.ant.ConstructRegistry}
+ * Ant task.
+ *
+ * @author Howard Lewis Ship
+ * @version $Id$
+ */
public class TestConstructRegistry extends HiveMindTestCase
{
protected Project _project = new Project();
@@ -113,7 +120,7 @@
{
ConstructRegistry cr = create();
- File f = File.createTempFile("registry-", ".xml");
+ File f = File.createTempFile("testNoDescriptors-", ".xml");
cr.setOutput(f);
@@ -140,7 +147,7 @@
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");
+ File output = File.createTempFile("testBasic-", ".xml");
// Delete the file, to force the task to re-create it.
@@ -162,7 +169,7 @@
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");
+ File output = File.createTempFile("testUptoDate-", ".xml");
// Delete the file, to force the task to re-create it.
1.1
jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/impl/DemoService.java
Index: DemoService.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 [EMAIL PROTECTED]
*
* 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.services.impl;
import org.apache.tapestry.ApplicationRuntimeException;
import hivemind.test.services.IDemoService;
/**
* Implementation of [EMAIL PROTECTED] hivemind.test.services.ITestService} used
* for testing logging interceptor.
*
* @author Howard Lewis Ship
* @version $Id: DemoService.java,v 1.1 2003/06/17 21:13:06 hlship Exp $
*/
public class DemoService extends SimpleService implements IDemoService
{
/**
* Does nothing.
*/
public void noResult()
{
}
/**
* Throws ApplicationRuntimeException.
*/
public void alwaysFail() throws RuntimeException
{
throw new ApplicationRuntimeException("Failure in method alwaysFail.",
(Throwable) null);
}
}
1.2 +9 -1 jakarta-commons-sandbox/hivemind/src/META-INF/hivemodule.xml
Index: hivemodule.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/META-INF/hivemodule.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- hivemodule.xml 4 Jun 2003 21:46:07 -0000 1.1
+++ hivemodule.xml 17 Jun 2003 21:13:06 -0000 1.2
@@ -4,8 +4,16 @@
<module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd"
id="org.apache.commons.hivemind" version="1.0.0">
+ <description>
+ The master module for HiveMind.
+ </description>
<configuration id="VariableSource"
element-type="org.apache.commons.hivemind.VariableSourceContribution">
<description>Provides a list of sources for substitution
variables.</description>
</configuration>
+
+ <service id="LoggingInterceptor"
interface="org.apache.commons.hivemind.IInterceptorFactory">
+ <description>An interceptor factory for adding method-level logging to
a service.</description>
+ <create-instance
class="org.apache.commons.hivemind.impl.LoggingInterceptorFactory"/>
+ </service>
</module>
1.2 +15 -7
jakarta-commons-sandbox/hivemind/src/test-data/TestConstructRegistry/testBasic.xml
Index: testBasic.xml
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/hivemind/src/test-data/TestConstructRegistry/testBasic.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- testBasic.xml 12 Jun 2003 20:57:40 -0000 1.1
+++ testBasic.xml 17 Jun 2003 21:13:07 -0000 1.2
@@ -1,21 +1,29 @@
<?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">
+ <module id="org.apache.commons.hivemind" uid="1" version="1.0.0">
+ <description uid="2"> The master module for HiveMind. </description>
<configuration
- element-type="org.apache.commons.hivemind.VariableSourceContribution"
id="VariableSource">
+ element-type="org.apache.commons.hivemind.VariableSourceContribution"
+ id="org.apache.commons.hivemind.VariableSource" uid="3">
<description>Provides a list of sources for substitution
variables.</description>
</configuration>
+ <service id="org.apache.commons.hivemind.LoggingInterceptor"
+ interface="org.apache.commons.hivemind.IInterceptorFactory" uid="4">
+ <description>An interceptor factory for adding method-level
+ logging to a service.</description>
+ <create-instance
class="org.apache.commons.hivemind.impl.LoggingInterceptorFactory"/>
+ </service>
</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">
+ <module id="hivemind.test.config" uid="5" version="1.0.0">
+ <contribute-configuration
+ configuration-id="org.apache.commons.hivemind.VariableSource" uid="6">
<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">
+ <configuration element-type="java.lang.String"
+ id="hivemind.test.config.Dogs" uid="7">
<value>${dog}</value>
</configuration>
</module>
1.2 +13 -6
jakarta-commons-sandbox/hivemind/src/test-data/TestConstructRegistry/testUptoDate.xml
Index: testUptoDate.xml
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/hivemind/src/test-data/TestConstructRegistry/testUptoDate.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- testUptoDate.xml 12 Jun 2003 20:57:40 -0000 1.1
+++ testUptoDate.xml 17 Jun 2003 21:13:07 -0000 1.2
@@ -1,14 +1,21 @@
<?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">
+ <module id="org.apache.commons.hivemind" uid="1" version="1.0.0">
+ <description uid="2"> The master module for HiveMind. </description>
<configuration
- element-type="org.apache.commons.hivemind.VariableSourceContribution"
id="VariableSource">
+ element-type="org.apache.commons.hivemind.VariableSourceContribution"
+ id="org.apache.commons.hivemind.VariableSource" uid="3">
<description>Provides a list of sources for substitution
variables.</description>
</configuration>
+ <service id="org.apache.commons.hivemind.LoggingInterceptor"
+ interface="org.apache.commons.hivemind.IInterceptorFactory" uid="4">
+ <description>An interceptor factory for adding method-level
+ logging to a service.</description>
+ <create-instance
class="org.apache.commons.hivemind.impl.LoggingInterceptorFactory"/>
+ </service>
</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 id="hivemind.test.config" uid="5" version="1.0.0">
+ <configuration count="1" element-type="java.lang.String"
+ id="hivemind.test.config.Required" uid="6"/>
</module>
</registry>
1.2 +1 -1 jakarta-commons-sandbox/hivemind/src/images/InterceptorStack.psp
<<Binary file>>
1.2 +72 -2
jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/ant/ConstructRegistry.java
Index: ConstructRegistry.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/ant/ConstructRegistry.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConstructRegistry.java 12 Jun 2003 20:57:40 -0000 1.1
+++ ConstructRegistry.java 17 Jun 2003 21:13:07 -0000 1.2
@@ -74,11 +74,26 @@
import org.apache.xml.serialize.XMLSerializer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
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.
+ * and builds a composite registry by simply concatinating them all. The resulting
+ * file is suitable for passing through an XSLT processor to create documentation.
+ *
+ * <p>
+ * The resulting XML file does not conform to the hivemind module deployment
+ * descriptor schema. The following changes occur:
+ * <ul>
+ * <li>The outermost element is <registry> (which contains a list of
<module>)
+ * <li>Any namespace-related attributes are stripped from <module>
+ * <li>A unique id (unique within the file) is assigned to each <module>,
<configuration>,
+ * <service>, <configuration-contribution> and
<service-contribution> (this is
+ * to make it easier to generate links and anchors)
+ * <li>The <code>id</code> attribute of <configuration> and <service> is
+ * converted from a local id to a full id (by prefixing with the module id).
+ * </ul>
*
*
* @author Howard Lewis Ship
@@ -86,6 +101,8 @@
*/
public class ConstructRegistry extends Task
{
+ private int _uid = 1;
+
private File _output;
private Path _descriptorsPath;
@@ -160,6 +177,8 @@
Node eCopy = result.importNode(e, true);
+ attachUIDs((Element) eCopy);
+
registry.appendChild(eCopy);
}
@@ -188,6 +207,57 @@
"Unable to write registry to " + file + ": " + ex.getMessage(),
ex);
}
+ }
+
+ protected void attachUIDs(Element module)
+ {
+ attachUID(module);
+
+ NamedNodeMap attributes = module.getAttributes();
+
+ String moduleId = attributes.getNamedItem("id").getNodeValue();
+
+ for (int i = attributes.getLength() - 1; i >= 0; i--)
+ {
+ Node attr = attributes.item(i);
+
+ String name = attr.getNodeName();
+
+ if (name.indexOf(':') > 0)
+ attributes.removeNamedItem(name);
+ }
+
+ module.setAttribute("uid", Integer.toString(_uid++));
+
+ Node node = module.getFirstChild();
+
+ while (node != null)
+ {
+ if (node instanceof Element)
+ {
+
+ Element e = (Element) node;
+
+ e.setAttribute("uid", Integer.toString(_uid++));
+
+ String name = e.getTagName();
+
+ if (name.equals("service") || name.equals("configuration"))
+ {
+ String fullId = moduleId + "." + e.getAttribute("id");
+
+ e.setAttribute("id", fullId);
+ }
+
+ }
+
+ node = node.getNextSibling();
+ }
+ }
+
+ protected void attachUID(Element node)
+ {
+
}
protected void writeDocument(Document document, OutputStream out) throws
IOException
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]