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/20 16:00:30 UTC
cvs commit: jakarta-commons-sandbox/hivemind/src/test/hivemind/test HiveMindTestCase.java
hlship 2003/06/20 07:00:30
Modified: hivemind/src/java/org/apache/commons/hivemind/impl
BaseModule.java ConfigurationExtensionPoint.java
ServiceExtensionPoint.java
hivemind/src/test/hivemind/test/services TestServices.java
hivemind/xdocs descriptor.xml navigation.xml
hivemind project.xml maven.xml
hivemind/common links.xml
hivemind/src/xsl hivemind.xsl
hivemind/src/java/org/apache/commons/hivemind
HiveMindMessages.properties
hivemind/src/test/hivemind/test/config
TestConfiguration.java
hivemind/src/test/hivemind/test HiveMindTestCase.java
Added: hivemind/src/test/hivemind/test/services
RecursiveService.xml
hivemind/xdocs registry.xml
hivemind/src/test-data/sample org.example.boostrap.xml
org.example.toolbar.ui.xml
hivemind/src/test/hivemind/test/config
RecursiveConfiguration.xml
Removed: hivemind/src/test-data/sample sample-registry.xml
Log:
Add checks for recursive service and configuration builds.
Improve generation of registry documentation (to use chunked output).
Revision Changes Path
1.4 +1 -3 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/BaseModule.java
Index: BaseModule.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/BaseModule.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BaseModule.java 4 Jun 2003 23:52:48 -0000 1.3
+++ BaseModule.java 20 Jun 2003 14:00:29 -0000 1.4
@@ -112,8 +112,6 @@
private Map _configurations;
- // TODO: checks for recursive service build!
-
public void addServiceExtensionPoint(IServiceExtensionPoint point)
{
if (_serviceExtensionPoints == null)
1.6 +24 -3 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ConfigurationExtensionPoint.java
Index: ConfigurationExtensionPoint.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ConfigurationExtensionPoint.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ConfigurationExtensionPoint.java 10 Jun 2003 17:57:08 -0000 1.5
+++ ConfigurationExtensionPoint.java 20 Jun 2003 14:00:29 -0000 1.6
@@ -93,6 +93,7 @@
private Class _elementType;
private String _elementTypeName;
private boolean _cacheElements;
+ private boolean _building;
protected void extendDescription(ToStringBuilder builder)
{
@@ -179,7 +180,27 @@
return _sharedConfigurationContributions;
}
- public List constructConfiguration()
+ public synchronized List constructConfiguration()
+ {
+ if (_building)
+ throw new ApplicationRuntimeException(
+ HiveMind.format(
+ "ConfigurationExtensionPoint.recursive-configuration",
+ getExtensionPointId()));
+
+ try
+ {
+ _building = true;
+
+ return constructConfigurationInner();
+ }
+ finally
+ {
+ _building = false;
+ }
+ }
+
+ protected List constructConfigurationInner()
{
if (LOG.isDebugEnabled())
LOG.debug("Constructing configuration " + getExtensionPointId());
@@ -300,7 +321,7 @@
LOG.error(message);
}
-
+
public boolean getCacheElements()
{
return _cacheElements;
1.6 +23 -2 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ServiceExtensionPoint.java
Index: ServiceExtensionPoint.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ServiceExtensionPoint.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ServiceExtensionPoint.java 9 Jun 2003 22:23:09 -0000 1.5
+++ ServiceExtensionPoint.java 20 Jun 2003 14:00:29 -0000 1.6
@@ -89,6 +89,7 @@
private List _interceptorContributions;
private List _sortedInterceptorContributions;
private boolean _required;
+ private boolean _building;
protected void extendDescription(ToStringBuilder builder)
{
@@ -210,7 +211,27 @@
return _sortedInterceptorContributions;
}
- public Object constructService()
+ public synchronized Object constructService()
+ {
+ if (_building)
+ throw new ApplicationRuntimeException(
+ HiveMind.format(
+ "ServiceExtensionPoint.recursive-service-build",
+ getExtensionPointId()));
+
+ try
+ {
+ _building = true;
+
+ return constructServiceInner();
+ }
+ finally
+ {
+ _building = false;
+ }
+ }
+
+ protected Object constructServiceInner()
{
IFactoryContribution fc = getFactoryContribution();
1.6 +28 -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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestServices.java 17 Jun 2003 21:13:05 -0000 1.5
+++ TestServices.java 20 Jun 2003 14:00:29 -0000 1.6
@@ -72,6 +72,12 @@
import org.apache.log4j.spi.LoggingEvent;
import org.apache.tapestry.ApplicationRuntimeException;
+/**
+ * Tests involving creating and using services.
+ *
+ * @author Howard Lewis Ship
+ * @version $Id$
+ */
public class TestServices extends HiveMindTestCase
{
@@ -224,5 +230,27 @@
assertEquals("Logger name", name, e.getLoggerName());
assertEquals("Message", message, e.getMessage());
+ }
+
+ /**
+ * Checks for the detection of a recursive service; one that is dependant on
+ * itself.
+ */
+ public void testRecursiveService() throws Exception
+ {
+ IRegistry r = buildRegistry("RecursiveService.xml");
+
+ try
+ {
+ r.getService("hivemind.test.services.tracker.Fred", Object.class);
+ unreachable();
+ }
+ catch (Exception ex)
+ {
+ checkException(
+ ex,
+ "A recursive call to construct service hivemind.test.services.tracker.Fred has occured.");
+ }
+
}
}
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/RecursiveService.xml
Index: RecursiveService.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: RecursiveService.xml,v 1.1 2003/06/20 14:00:29 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.tracker"
version="0.0.1">
<service id="Fred" interface="org.apache.commons.hivemind.IInterceptorFactory">
<create-instance class="hivemind.test.services.impl.TrackerFactory">
<set property="name" value="Fred"/>
</create-instance>
<interceptor service-id="hivemind.test.services.tracker.Barney"/>
</service>
<service id="Barney" interface="org.apache.commons.hivemind.IInterceptorFactory">
<create-instance class="hivemind.test.services.impl.TrackerFactory">
<set property="name" value="Barney"/>
</create-instance>
<interceptor service-id="hivemind.test.services.tracker.Wilma"/>
</service>
<service id="Wilma" interface="org.apache.commons.hivemind.IInterceptorFactory">
<create-instance class="hivemind.test.services.impl.TrackerFactory">
<set property="name" value="Wilma"/>
</create-instance>
<!-- Here's the cycle! -->
<interceptor service-id="hivemind.test.services.tracker.Fred"/>
</service>
</module>
1.6 +3 -44 jakarta-commons-sandbox/hivemind/xdocs/descriptor.xml
Index: descriptor.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/descriptor.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- descriptor.xml 18 Jun 2003 18:47:00 -0000 1.5
+++ descriptor.xml 20 Jun 2003 14:00:29 -0000 1.6
@@ -12,7 +12,7 @@
<body>
<section name="Purpose">
<p>The purpose of the module descriptor is to provide a runtime and
- compile-time descriptor of a module: its dependencies, services,
+ compile-time descriptioin of a module: its dependencies, services,
configurations and contributions.</p>
<p>The descriptor is named <code>hivemodule.xml</code> and is stored in
the META-INF directory of the module.</p>
@@ -92,13 +92,6 @@
</tr>
<tr>
<td colspan="2">
- <a href="#library">library</a>
- </td>
- <td>0..n</td>
- <td>Dependencies on other libraries.</td>
- </tr>
- <tr>
- <td colspan="2">
<a href="#service">service</a>
</td>
<td>0..n</td>
@@ -183,41 +176,7 @@
</tr>
</table>
</section>
- <section name="library">
- <p>The &_library; element identifies an external library and version
- required by this module.</p>
- <table>
- <tr>
- <th>Attribute</th>
- <th>Type</th>
- <th>Required ?</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>id</td>
- <td>string</td>
- <td>yes</td>
- <td>The base name of the library jar.</td>
- </tr>
- <tr>
- <td>version</td>
- <td>string</td>
- <td>yes</td>
- <td>The version portion of the library jar. The jar is named: <code>
- <i>id</i>-<i>version</i>.jar</code> </td>
- </tr>
- <tr>
- <td>export</td>
- <td>boolean</td>
- <td>no</td>
- <td>If true, then the library is exported with the module; the library
- will be added to the classpath of any other module which depends on
- this module. The default is false, appropriate when the classes in
- the library are only needed by the module itself.</td>
- </tr>
- </table>
- </section>
- <section name="service">
+ <section name="service">
<p>The &_service; element defines a service extension point.</p>
<table>
<tr>
1.7 +1 -1 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- navigation.xml 17 Jun 2003 21:13:04 -0000 1.6
+++ navigation.xml 20 Jun 2003 14:00:29 -0000 1.7
@@ -9,7 +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="HiveMind Registry" href="/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.1 jakarta-commons-sandbox/hivemind/xdocs/registry.xml
Index: registry.xml
===================================================================
<?xml version="1.0"?>
<!-- $Id: registry.xml,v 1.1 2003/06/20 14:00:29 hlship Exp $ -->
<!DOCTYPE document [
<!ENTITY % common-links SYSTEM "../common/links.xml">
%common-links;
]>
<document>
<properties>
<title>HiveMind Registry Documentation</title>
<author email="hlship@apache.org">Howard M. Lewis Ship</author>
</properties>
<body>
<section name="HiveMind Registry Documentation">
<p>
HiveMind includes tools for documentating a HiveMind registry. At build time, all related
<code>hivemodule.xml</code> descriptors are parsed, combined into a single file,
and then converted using XSLT. The end result is much like JavaDoc ... its fully
hyperlinked and allows you to see all services and contributions clearly.
</p>
<table>
<tr>
<th>Registry</th> <th>Description</th>
</tr>
<tr>
<td>
<a href="base-registry/index.html">base-registry</a>
</td>
<td>
Documentation for just the core HiveMind module.
</td>
</tr>
<tr>
<td>
<a href="sample-registry/index.html">sample-registry</a></td>
<td>
Documentation for a hypothetical application; this allow you to see
more clearly how the hyperlinking occurs.
</td>
</tr>
</table>
</section>
<section name="Building the Documentation">
<p>
Currently, there isn't an easy way to do this! Something will
be forthcoming in the future. See
the <code>maven.xml</code> file for the HiveMind project
to see how the examples were generated. The necessary CSS and XSL files
are included in the source distribution.
</p>
<p>
The XSLT uses a single XSLT 1.1 feature (<xs:document>, used
to chunk output to multiple files). The documentation
is generated using <a href="http://saxon.sf.net">Saxon</a> 6.5.2.
</p>
</section>
</body>
</document>
1.9 +8 -2 jakarta-commons-sandbox/hivemind/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/project.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- project.xml 12 Jun 2003 21:14:38 -0000 1.8
+++ project.xml 20 Jun 2003 14:00:29 -0000 1.9
@@ -90,12 +90,18 @@
<version>1.0.b2</version>
<url>http://xml.apache.org/xerces/</url>
</dependency>
-
+
<dependency>
<id>ognl</id>
<version>2.4.1</version>
<url>http://www.ognl.org/</url>
</dependency>
+
+ <dependency>
+ <id>saxon</id>
+ <version>6.5.2</version>
+ <url>http://saxon.sf.net</url>
+ </dependency>
<dependency>
<!-- Note: just until the Maven folks put this in the right spot! -->
1.4 +62 -49 jakarta-commons-sandbox/hivemind/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/maven.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- maven.xml 17 Jun 2003 21:13:04 -0000 1.3
+++ maven.xml 20 Jun 2003 14:00:29 -0000 1.4
@@ -1,72 +1,85 @@
<?xml version="1.0"?>
<!-- $Id$ -->
-<project xmlns:j="jelly:core">
+<project xmlns:j="jelly:core" xmlns:u="jelly:util">
<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 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>
+ <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}"/>
+ <attribute name="Class-Path" value="${hivemind.manifest.class.path}"/>
</manifest>
-
</jar>
</postGoal>
-
- <postGoal name="xdoc:jelly-transform">
-
+ <preGoal 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>
+ <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>
-
+ <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"/>
+ <mkdir dir="target/docs/base-registry"/>
+ <j:set var="output.dir" value="target/docs/base-registry"/>
+ <mkdir dir="${output.dir}"/>
+ <java fork="true" classname="com.icl.saxon.StyleSheet">
+ <arg line="-o ${output.dir}/index.html"/>
+ <arg line="target/base-registry.xml"/>
+ <arg line="src/xsl/hivemind.xsl"/>
+ <arg line="base.dir=${output.dir}"/>
+ <classpath>
+ <pathelement location="${pom.getDependencyPath('saxon')}"/>
+ </classpath>
+ </java>
+ <copy todir="${output.dir}" file="src/xsl/hivemind.css"/>
- </postGoal>
+ <j:set var="sample.registry" value="target/sample-registry.xml"/>
+
+ <constructRegistry output="${sample.registry}">
+ <descriptors>
+ <fileset dir="src/META-INF">
+ <include name="hivemodule.xml"/>
+ </fileset>
+ <fileset dir="src/test-data/sample">
+ <include name="*.xml"/>
+ </fileset>
+ </descriptors>
+ </constructRegistry>
+ <j:set var="output.dir" value="target/docs/sample-registry"/>
+
+ <mkdir dir="${output.dir}"/>
+ <java fork="true" classname="com.icl.saxon.StyleSheet">
+ <arg line="-o ${output.dir}/index.html"/>
+ <arg line="${sample.registry}"/>
+ <arg line="src/xsl/hivemind.xsl"/>
+ <arg line="base.dir=${output.dir}"/>
+ <classpath>
+ <pathelement location="${pom.getDependencyPath('saxon')}"/>
+ </classpath>
+ </java>
+ <copy todir="${output.dir}" file="src/xsl/hivemind.css"/>
+ </preGoal>
</project>
1.1 jakarta-commons-sandbox/hivemind/src/test-data/sample/org.example.boostrap.xml
Index: org.example.boostrap.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: org.example.boostrap.xml,v 1.1 2003/06/20 14:00:30 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="org.example.bootstrap" version="1.0.0">
<description>
Contains the boostrap service used to startup the application.
</description>
<configuration id="Bootstrap"
element-type="java.lang.Runnable"
cache-elements="false">
<description>Provides a list of Runnable objects used to startup the application.</description>
</configuration>
<service id="Bootstrap" interface="java.lang.Runnable">
<description>The service which actually bootstraps the application.</description>
<create-instance class="org.examples.boostrap.impl.BoostrapService"/>
</service>
</module>
1.1 jakarta-commons-sandbox/hivemind/src/test-data/sample/org.example.toolbar.ui.xml
Index: org.example.toolbar.ui.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: org.example.toolbar.ui.xml,v 1.1 2003/06/20 14:00:30 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="org.example.ui.toolbar" version="1.0.1">
<description>
Module for managing the application toolbar.
</description>
<dependency module-id="org.example.bootstrap"/>
<configuration id="Toolbar"
element-type="org.example.ui.toolbar.ToolbarItem"
count="1..n">
<description>
Items which may appear on the toolbar.
</description>
<create-instance class="org.example.ui.toolbar.ToolbarItem">
<set property="label" value="Quit"/>
<set property="mneumonic" value="Q"/>
<set property="order" value="1"/>
<set-create property="callback" class="org.example.ui.toolbar.impl.QuitCallback"/>
</create-instance>
</configuration>
<service id="ToolbarManager" interface="org.example.ui.toolbar.IToolbarManager">
<description>Service for accessing the toolbar.</description>
<create-instance class="org.example.ui.toolbar.impl.ToolbarManagerService"/>
<interceptor service-id="org.apache.commons.hivemind.LoggingInterceptor"/>
</service>
<contribute-configuration configuration-id="org.apache.commons.hivemind.VariableSource">
<create-instance class="org.apache.commons.hivemind.VariableSourceContribution">
<set property="order" value="100"/>
<set-create property="source" class="org.example.toolbar.ui.impl.PreferencesVariableSource"/>
</create-instance>
</contribute-configuration>
<contribute-configuration configuration-id="org.example.bootstrap.Bootstrap">
<create-instance class="org.example.ui.toolbar.impl.ToolbarStartup"/>
</contribute-configuration>
</module>
1.5 +1 -4 jakarta-commons-sandbox/hivemind/common/links.xml
Index: links.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/common/links.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- links.xml 11 Jun 2003 18:43:12 -0000 1.4
+++ links.xml 20 Jun 2003 14:00:30 -0000 1.5
@@ -37,9 +37,6 @@
<!ENTITY _dependency '<code><dependency></code>'>
<!ENTITY dependency '<a href="descriptor.html#dependency">&_dependency;</a>'>
-<!ENTITY _library '<code><library></code>'>
-<!ENTITY library '<a href="descriptor.html#library">&_library;</a>'>
-
<!ENTITY _configuration '<code><configuration></code>'>
<!ENTITY configuration '<a href="descriptor.html#configuration">&_configuration;</a>'>
1.3 +236 -108 jakarta-commons-sandbox/hivemind/src/xsl/hivemind.xsl
Index: hivemind.xsl
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/xsl/hivemind.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- hivemind.xsl 18 Jun 2003 18:47:01 -0000 1.2
+++ hivemind.xsl 20 Jun 2003 14:00:30 -0000 1.3
@@ -1,6 +1,11 @@
<?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:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:exsl="http://exslt.org/common"
+
+ extension-element-prefixes="exsl">
+
+ <xsl:param name="base.dir"/>
+
<xsl:template match="/registry">
<html>
<head>
@@ -9,27 +14,53 @@
</head>
<body>
<h1>HiveMind Module Registry</h1>
- <ul>
- <xsl:apply-templates select="module" mode="registry-toc">
+
+ <table class="summary">
+ <tbody>
+ <tr>
+ <th class="subhead">Module</th>
+ <th class="subhead">Version</th>
+ </tr>
+
+ <xsl:for-each select="module">
<xsl:sort select="@id"/>
- </xsl:apply-templates>
- </ul>
- <xsl:apply-templates select="module" mode="module-summary">
- <xsl:sort select="@id"/>
- </xsl:apply-templates>
+
+ <tr>
+ <td>
+ <a href="{@id}.html">
+ <xsl:value-of select="@id"/>
+ </a>
+ </td>
+ <td>
+ <xsl:value-of select="@version"/>
+ </td>
+ </tr>
+
+ </xsl:for-each>
+
+ </tbody>
+ </table>
+
+ <xsl:apply-templates select="module"/>
+
</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/>
+
+ <xsl:template match="module">
+
+ <xsl:message>Writing summary for module <xsl:value-of select="@id"/></xsl:message>
+
+ <xsl:document href="{$base.dir}/{@id}.html">
+
+ <html>
+ <head>
+ <title>HiveMind Registry</title>
+ <link rel="stylesheet" type="text/css" href="hivemind.css"/>
+ </head>
+ <body>
+
+
<h1> <xsl:attribute name="id"><xsl:value-of select="@uid"/></xsl:attribute>
Module <xsl:value-of select="@id"/> </h1>
<table class="summary">
@@ -67,9 +98,7 @@
<tr>
<td/>
<td>
- <a>
- <xsl:attribute name="href">#<xsl:value-of
- select="/registry/module[@id = current()/@module-id]/@uid"/></xsl:attribute>
+ <a href="{@module-id}.html">
<xsl:value-of select="@module-id"/>
</a>
</td>
@@ -82,16 +111,6 @@
</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">
@@ -126,9 +145,26 @@
<xsl:apply-templates select="contribute-service">
<xsl:sort select="@service-id"/>
</xsl:apply-templates>
+
+ <hr/>
+
+ <a href="index.html">Back to index</a>
+
+ </body>
+ </html>
+
+ </xsl:document>
+
</xsl:template>
+
+ <xsl:template match="configuration" mode="link">
+
+ <a href="{../@id}.html#{@uid}"><xsl:value-of select="@id"/></a>
+
+ </xsl:template>
+
<xsl:template match="configuration">
- <h2> <xsl:attribute name="id"><xsl:value-of select="@uid"/></xsl:attribute>
+ <h2 id="{@uid}">
Configuration <xsl:value-of select="@id"/> </h2>
<table class="summary">
<tbody>
@@ -172,8 +208,8 @@
<xsl:sort select="../@id"/>
<h3>Contributions from Module
- <a>
- <xsl:attribute name="href">#<xsl:value-of select="@uid"/></xsl:attribute>
+
+ <a href="{../@id}.html#{@uid}">
<xsl:value-of select="../@id"/>
</a>
</h3>
@@ -186,14 +222,12 @@
</xsl:template>
+
<xsl:template match="contribute-configuration">
<h2> <xsl:attribute name="id"><xsl:value-of select="@uid"/></xsl:attribute>
Contribute Configuration
- <a>
- <xsl:attribute name="href">#<xsl:value-of select="/registry/module/configuration[@id = current()/@configuration-id]/@uid"/></xsl:attribute>
- <xsl:value-of select="@configuration-id"/>
- </a>
+ <xsl:apply-templates select="/registry/module/configuration[@id = current()/@configuration-id]" mode="link"/>
</h2>
@@ -201,8 +235,15 @@
<xsl:apply-templates/>
</ul>
</xsl:template>
+
+ <xsl:template match="service" mode="link">
+
+ <a href="{../@id}.html#{@uid}"><xsl:value-of select="@id"/></a>
+
+ </xsl:template>
+
<xsl:template match="service">
- <h2> <xsl:attribute name="id"><xsl:value-of select="@uid"/></xsl:attribute>
+ <h2 id="{@uid}">
Service <xsl:value-of select="@id"/> </h2>
<table class="summary">
<tbody>
@@ -239,8 +280,7 @@
<xsl:sort select="../@id"/>
<h3>Contributions from Module
- <a>
- <xsl:attribute name="href">#<xsl:value-of select="@uid"/></xsl:attribute>
+ <a href="{../@id}.html#{@uid}">
<xsl:value-of select="../@id"/>
</a>
</h3>
@@ -252,23 +292,23 @@
</xsl:for-each>
</xsl:template>
+
<xsl:template match="contribute-service">
<h2> <xsl:attribute name="id"><xsl:value-of select="@uid"/></xsl:attribute>
Contribute Service
- <a>
- <xsl:attribute name="href">#<xsl:value-of select="/registry/module/service[@id = current()/@service-id]/@uid"/></xsl:attribute>
- <xsl:value-of select="@service-id"/>
- </a>
+ <xsl:apply-templates select="/registry/module/service[@id = current()/@service-id]" mode="link"/>
</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>
@@ -278,6 +318,7 @@
<span class="tag"></expression></span>
</li>
</xsl:template>
+
<xsl:template match="value">
<li>
<span class="tag"><value></span>
@@ -287,89 +328,176 @@
<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/service[@id = current()/@service-id]/@uid"/></xsl:attribute>
- <xsl:value-of select="@service-id"/> </a>" <span class="tag">/></span> </li>
+ <li>
+ <span class="tag"><service-ref</span>
+ <span class="attribute"> service-id</span>="<xsl:apply-templates select="/registry/module/service[@id = current()/@service-id]" mode="link"/>"
+ <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>
+ <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>
+ <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>
+ <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>
+ <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/service[@id = 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>
+ <li>
+ <span class="tag"><factory</span>
+ <span class="attribute"> service-id</span>="<xsl:apply-templates select="/registry/module/service[@id = current()/@service-id]" mode="link"/>"
+
+ <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/service[@id = 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>
+ <li>
+ <span class="tag"><set-factory</span>
+ <span class="attribute"> property</span>="<xsl:value-of select="@property"/>"
+ <span class="attribute"> service-id</span>="<xsl:apply-templates select="/registry/module/service[@id = current()/@service-id]" mode="link"/>"
+
+ <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/service[@id = 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>
+ <li>
+ <span class="tag"><interceptor</span>
+ <span class="attribute"> service-id</span>="<xsl:apply-templates select="/registry/module/service[@id = current()/@service-id]" mode="link"/>"
+
+ <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>
+ <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>
+ <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/service[@id = current()/@service-id]/@uid"/></xsl:attribute>
- <xsl:value-of select="@service-id"/> </a>" <span class="tag">/></span> </li>
+ <li>
+ <span class="tag"><set-service-ref</span>
+ <span class="attribute"> property</span>="<xsl:value-of select="@property"/>"
+ <span class="attribute"> service-id</span>="<xsl:apply-templates select="/registry/module/service[@id = current()/@service-id]" mode="link"/>"
+ <span class="tag">/></span>
+ </li>
</xsl:template>
</xsl:stylesheet>
1.5 +3 -1 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMindMessages.properties
Index: HiveMindMessages.properties
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMindMessages.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HiveMindMessages.properties 9 Jun 2003 22:23:07 -0000 1.4
+++ HiveMindMessages.properties 20 Jun 2003 14:00:30 -0000 1.5
@@ -19,11 +19,13 @@
ConfigurationExtensionPoint.element-not-allowed=Module {0} has contributed element {1} to service extension point {2} (at {3}). The element may not be converted to the declared element type, {5}, as has been ignored.
ConfigurationExtensionPoint.element-is-null=Module {0} has contributed a null element to configuration extension point {1} (at {2}). The contribution has been ignored.
ConfigurationExtensionPoint.unable-to-convert=Unable to convert {0} to type {1}: {2}
+ConfigurationExtensionPoint.recursive-configuration=A recursive call to construct configuration {0} has occured. This indicates a cycle between one or more configurations or services.
ServiceExtensionPoint.request-for-missing-service=Unable to provide required service {0} because no module contributed a factory.
ServiceExtensionPoint.unable-to-construct-service=Unable to construct service {0}: {1}
ServiceExtensionPoint.factory-returned-null=Instance factory for service {0} returned null.
ServiceExtensionPoint.factory-wrong-interface=Instance factory for service {0} returned {1} which does not implement the {2} interface declared by the extension point.
+ServiceExtensionPoint.recursive-service-build=A recursive call to construct service {0} has occured. This indicates a cycle between one or more services or configurations.
DescriptorParser.missing-resource=Unable to find resource {0}.
DescriptorParser.error-reading-descriptor=Unable to read descriptor {0}: {1}
1.8 +27 -3 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/TestConfiguration.java
Index: TestConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/TestConfiguration.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TestConfiguration.java 10 Jun 2003 21:29:25 -0000 1.7
+++ TestConfiguration.java 20 Jun 2003 14:00:30 -0000 1.8
@@ -63,10 +63,13 @@
import java.util.List;
import java.util.Locale;
+import ognl.MethodFailedException;
+
import org.apache.commons.hivemind.HiveMind;
import org.apache.commons.hivemind.IRegistry;
import org.apache.commons.hivemind.impl.RegistryBuilder;
import org.apache.commons.hivemind.parse.DescriptorParser;
+import org.apache.tapestry.ApplicationRuntimeException;
import org.apache.tapestry.ILocation;
import org.apache.tapestry.IResourceLocation;
@@ -219,9 +222,7 @@
}
catch (Exception ex)
{
- checkException(
- ex,
- "Unable to convert zaphod to type java.lang.Integer");
+ checkException(ex, "Unable to convert zaphod to type java.lang.Integer");
}
}
@@ -359,5 +360,28 @@
String dog = (String) l.get(0);
assertEquals("Dino", dog);
+ }
+
+ public void testRecursiveConfiguration() throws Exception
+ {
+ IRegistry r = buildRegistry("RecursiveConfiguration.xml");
+
+ HiveMind.setDefault(r);
+
+ try
+ {
+ r.getConfiguration("hivemind.test.config.Config");
+ unreachable();
+ }
+ catch (ApplicationRuntimeException ex)
+ {
+ MethodFailedException mf = (MethodFailedException) findNestedException(ex);
+
+ ApplicationRuntimeException inner = (ApplicationRuntimeException) mf.getReason();
+
+ checkException(
+ inner,
+ "A recursive call to construct configuration hivemind.test.config.Config has occured.");
+ }
}
}
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/RecursiveConfiguration.xml
Index: RecursiveConfiguration.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: RecursiveConfiguration.xml,v 1.1 2003/06/20 14:00:30 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.config"
version="1.0.0">
<configuration id="Config" element-type="java.util.List">
<create-instance class="java.util.ArrayList"/>
<expression>
getConfiguration("hivemind.test.config.Config")
</expression>
</configuration>
</module>
1.7 +22 -2 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HiveMindTestCase.java 12 Jun 2003 20:57:39 -0000 1.6
+++ HiveMindTestCase.java 20 Jun 2003 14:00:30 -0000 1.7
@@ -69,6 +69,7 @@
import org.apache.commons.hivemind.parse.DescriptorParser;
import org.apache.commons.hivemind.parse.ModuleDescriptor;
import org.apache.commons.hivemind.util.URLResourceLocation;
+import org.apache.tapestry.ApplicationRuntimeException;
import org.apache.tapestry.IResourceLocation;
import org.apache.tapestry.IResourceResolver;
import org.apache.tapestry.util.DefaultResourceResolver;
@@ -147,7 +148,7 @@
assertEquals("list length", expected.length, actual.length);
}
- protected void checkException(Exception ex, String substring)
+ protected void checkException(Throwable ex, String substring)
{
String message = ex.getMessage();
assertNotNull(message);
@@ -164,6 +165,7 @@
*/
protected void tearDown() throws Exception
{
+ HiveMind.setDefault(null);
HiveMind.setBrittle(false);
}
@@ -183,4 +185,22 @@
return new URLResourceLocation(f.toURL());
}
+
+ /**
+ * Digs down through a stack of ARE's to find the first non-ARE, or
+ * the deepest ARE.
+ */
+
+ protected Throwable findNestedException(ApplicationRuntimeException ex)
+ {
+ Throwable cause = ex.getRootCause();
+
+ if (cause == null || cause == ex)
+ return ex;
+
+ if (cause instanceof ApplicationRuntimeException)
+ return findNestedException((ApplicationRuntimeException)cause);
+
+ return cause;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org