hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r230544 [1/2] - in /jakarta/hivemind/trunk: examples/src/descriptor/META-INF/ examples/src/documentation/content/xdocs/hivemind-examples/ examples/src/java/com/panorama/startup/ examples/src/java/com/panorama/startup/impl/ examples/src/java...
Date Sat, 06 Aug 2005 11:57:42 GMT
Author: ahuegen
Date: Sat Aug  6 04:56:53 2005
New Revision: 230544

URL: http://svn.apache.org/viewcvs?rev=230544&view=rev
Log:
Added highlighting for xml and java source in forrest docs.
Added new example for setter based dependency injection.

Added:
    jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/setters.xml
    jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/
    jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/SetterService.java
    jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/setters.xml
    jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/textResource.properties
    jakarta/hivemind/trunk/examples/src/test/org/
    jakarta/hivemind/trunk/examples/src/test/org/apache/
    jakarta/hivemind/trunk/examples/src/test/org/apache/hivemind/
    jakarta/hivemind/trunk/examples/src/test/org/apache/hivemind/examples/
    jakarta/hivemind/trunk/examples/src/test/org/apache/hivemind/examples/setters/
    jakarta/hivemind/trunk/examples/src/test/org/apache/hivemind/examples/setters/TestSetters.java
    jakarta/hivemind/trunk/src/documentation/classes/
    jakarta/hivemind/trunk/src/documentation/classes/CatalogManager.properties
    jakarta/hivemind/trunk/src/documentation/resources/schema/
    jakarta/hivemind/trunk/src/documentation/resources/schema/catalog.xcat
    jakarta/hivemind/trunk/src/documentation/resources/schema/dtd/
    jakarta/hivemind/trunk/src/documentation/resources/schema/dtd/hm-document.dtd
    jakarta/hivemind/trunk/src/documentation/resources/stylesheets/
    jakarta/hivemind/trunk/src/documentation/resources/stylesheets/sourceHighlighter.xsl
    jakarta/hivemind/trunk/src/documentation/sitemap.xmap
    jakarta/hivemind/trunk/tools/
    jakarta/hivemind/trunk/tools/forrest/
    jakarta/hivemind/trunk/tools/forrest/.classpath
    jakarta/hivemind/trunk/tools/forrest/.project
    jakarta/hivemind/trunk/tools/forrest/src/
    jakarta/hivemind/trunk/tools/forrest/src/org/
    jakarta/hivemind/trunk/tools/forrest/src/org/apache/
    jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/
    jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/
    jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/
    jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/Java2XmlRenderer.java
    jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/SourceHighlighterTransformer.java
    jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/Xml2XmlRenderer.java
Modified:
    jakarta/hivemind/trunk/examples/src/descriptor/META-INF/examples.xml
    jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/calc.xml
    jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/index.xml
    jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/panorama.xml
    jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/Executable.java
    jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/PanoramaMain.java
    jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/ExecuteStatic.java
    jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/Task.java
    jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/TaskExecutor.java
    jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/ExampleUtils.java
    jakarta/hivemind/trunk/examples/src/test/com/panorama/startup/impl/TestTaskExecutor.java
    jakarta/hivemind/trunk/hivebuild/forrestdoc.xml
    jakarta/hivemind/trunk/jmx/src/documentation/content/xdocs/hivemind-jmx/measurePerformance.xml
    jakarta/hivemind/trunk/src/documentation/content/xdocs/site.xml
    jakarta/hivemind/trunk/src/documentation/skinconf.xml

Modified: jakarta/hivemind/trunk/examples/src/descriptor/META-INF/examples.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/descriptor/META-INF/examples.xml?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/descriptor/META-INF/examples.xml (original)
+++ jakarta/hivemind/trunk/examples/src/descriptor/META-INF/examples.xml Sat Aug  6 04:56:53 2005
@@ -1,20 +1,4 @@
 <?xml version="1.0"?>
-<!-- 
-   Copyright 2004, 2005 The Apache Software Foundation
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-
 <module id="examples" version="1.0.0" package="org.apache.hivemind.examples">
     <service-point id="Adder">
         <create-instance class="impl.AdderImpl"/>
@@ -34,7 +18,6 @@
     </service-point>
     <service-point id="Calculator">
         <invoke-factory>
-          
             <!-- Most properties are autowired by the BuilderFactory -->
             <construct class="impl.CalculatorImpl"/>
         </invoke-factory>

Modified: jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/calc.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/calc.xml?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/calc.xml (original)
+++ jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/calc.xml Sat Aug  6 04:56:53 2005
@@ -15,18 +15,19 @@
    limitations under the License.
 -->
 
-<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" "http://xml.apache.org/forrest/dtd/document-v13.dtd"
+<!DOCTYPE document PUBLIC "-//HM//DTD Documentation V1.0//EN" "hm-document.dtd"
+  
 [
-	<!ENTITY projectroot '../'>
-	<!ENTITY % common-links SYSTEM "../links.ent">
-	%common-links;
+    <!ENTITY projectroot '../'>
+    <!ENTITY % common-links SYSTEM "../links.ent">
+    %common-links;
 ]>
 <document>
 
   <header>
     <title>Calculator</title>
-	</header>
-	
+    </header>
+    
   <body>
 
 <p>
@@ -37,6 +38,39 @@
 </p>
 
 <p>
+The logging configuration enables logging for the <code>hivemind</code> logger; that and the logging interceptors produces
+quite a bit of output. You can see that a <em>proxy</em> is created for services initially, and that the "core service implementation" for the service
+is created later ... the core service implementation consists of an instance of the service's POJO class, wrapped with any interceptors
+(the logging interceptor, in this case).
+</p>
+
+<p>
+The Registry is built from the following module deployment descriptor:
+</p>
+<xmlsourcefile file="examples/src/descriptor/META-INF/examples.xml" />
+
+<p>
+The service-point for the Calculator service is very simple ... as the comment
+indicates, the BuilderFactory is capable of locating the other services (Adder, Subtracter, etc.) by their 
+<em>interface</em>, rather than requiring <code>set-service</code> elements to connect properites 
+to services (using the target service's ids). These <em>properties</em> of the Calculator <em>implementation</em>
+are <em>autowired</em> to the matching services.  Autowriring works only because just a single service within the
+<em>entire</em> Registry implements the specific interface.  You would see errors if no service implemented
+the interface, or if more than one did.
+</p>    
+
+<p>
+This module descriptor also demonstrates two new feature of HiveMind 1.1:
+</p>
+
+<ul>
+<li>A package name is provided
+in the &module; element, allowing class names to be abbreviated when referenced elsewhere in the descriptor.</li>
+<li>The interface attribute of &service-point; is omitted, because it defaults to the service point id.</li>
+</ul>
+<section>
+  <title>Running the examples</title>
+<p>
 After compiling the examples, you can use Ant to run them:
 </p>
 
@@ -87,65 +121,6 @@
 
 BUILD SUCCESSFUL
 Total time: 3 seconds]]></source>
-
-<p>
-The logging configuration enables logging for the <code>hivemind</code> logger; that and the logging interceptors produces
-quite a bit of output. You can see that a <em>proxy</em> is created for services initially, and that the "core service implementation" for the service
-is created later ... the core service implementation consists of an instance of the service's POJO class, wrapped with any interceptors
-(the logging interceptor, in this case).
-</p>
-
-<p>
-The Registry is built from the following module deployment descriptor:
-</p>
-
-<source><![CDATA[
-<?xml version="1.0"?>
-<module id="examples" version="1.0.0" package="org.apache.hivemind.examples">
-    <service-point id="Adder">
-        <create-instance class="impl.AdderImpl"/>
-        <interceptor service-id="hivemind.LoggingInterceptor"/>
-    </service-point>
-    <service-point id="Subtracter">
-        <create-instance class="impl.SubtracterImpl"/>
-        <interceptor service-id="hivemind.LoggingInterceptor"/>
-    </service-point>
-    <service-point id="Multiplier">
-        <create-instance class="impl.MultiplierImpl"/>
-        <interceptor service-id="hivemind.LoggingInterceptor"/>
-    </service-point>
-    <service-point id="Divider">
-        <create-instance class="impl.DividerImpl"/>
-        <interceptor service-id="hivemind.LoggingInterceptor"/>
-    </service-point>
-    <service-point id="Calculator">
-        <invoke-factory>
-            <!-- Most properties are autowired by the BuilderFactory -->
-            <construct class="impl.CalculatorImpl"/>
-        </invoke-factory>
-        <interceptor service-id="hivemind.LoggingInterceptor"/>
-    </service-point>
-</module>]]></source>
-    
-<p>
-The service-point for the Calculator service is very simple ... as the comment
-indicates, the BuilderFactory is capable of locating the other services (Adder, Subtracter, etc.) by their 
-<em>interface</em>, rather than requiring <code>set-service</code> elements to connect properites 
-to services (using the target service's ids). These <em>properties</em> of the Calculator <em>implementation</em>
-are <em>autowired</em> to the matching services.  Autowriring works only because just a single service within the
-<em>entire</em> Registry implements the specific interface.  You would see errors if no service implemented
-the interface, or if more than one did.
-</p>    
-
-<p>
-This module descriptor also demonstrates two new feature of HiveMind 1.1:
-</p>
-
-<ul>
-<li>A package name is provided
-in the &module; element, allowing class names to be abbreviated when referenced elsewhere in the descriptor.</li>
-<li>The interface attribute of &service-point; is omitted, because it defaults to the service point id.</li>
-</ul>
-
+</section>
   </body>
 </document>

Modified: jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/index.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/index.xml?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/index.xml (original)
+++ jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/index.xml Sat Aug  6 04:56:53 2005
@@ -24,64 +24,24 @@
 	
   <body>
 
-<p>
-Provided with HiveMind is sample application code, used to demonstrate ideas and features of the framework.
-</p>
-
-<p>
-The example source code is provided with the standard distribution. You can build the code using Ant:
-</p>
-
-<source><![CDATA[bash-2.05b$ ant compile
-Buildfile: build.xml
-
-compile:
-
--display-download-warning:
-    [mkdir] Created dir: C:\workspace\jakarta-hivemind\examples\target\module-lib\compile
-     [copy] Copying 1 file to C:\workspace\jakarta-hivemind\examples\target\module-lib\compile
-
--display-download-warning:
-     [copy] Copying 1 file to C:\workspace\jakarta-hivemind\examples\target\module-lib\compile
-
--display-download-warning:
-     [copy] Copying 1 file to C:\workspace\jakarta-hivemind\examples\target\module-lib\compile
-
--display-download-warning:
-    [mkdir] Created dir: C:\workspace\jakarta-hivemind\examples\target\module-lib\run
-     [copy] Copying 1 file to C:\workspace\jakarta-hivemind\examples\target\module-lib\run
-
--display-download-warning:
-     [copy] Copying 1 file to C:\workspace\jakarta-hivemind\examples\target\module-lib\run
-
--display-download-warning:
-     [copy] Copying 1 file to C:\workspace\jakarta-hivemind\examples\target\module-lib\run
-
--display-download-warning:
-    [mkdir] Created dir: C:\workspace\jakarta-hivemind\examples\target\module-lib\test
-     [copy] Copying 1 file to C:\workspace\jakarta-hivemind\examples\target\module-lib\test
-     [copy] Copying 1 file to C:\workspace\jakarta-hivemind\examples\target\module-lib\compile
-
--compile-init:
-    [mkdir] Created dir: C:\workspace\jakarta-hivemind\examples\target\generated-java
-    [mkdir] Created dir: C:\workspace\jakarta-hivemind\examples\target\classes
-     [echo]
-     [echo]
-     [echo] *** Compiling Java sources to target/classes ...
-     [echo]
-    [javac] Compiling 17 source files to C:\workspace\jakarta-hivemind\examples\target\classes
-     [echo]
-     [echo]
-     [echo] *** Copying resources to target/classes ...
-     [echo]
-
-BUILD SUCCESSFUL
-Total time: 4 seconds]]>
-</source>
-
-<warning>
-  Details on how to setup your local build environment are forthcoming.
-</warning>
+	<p>
+	Provided with HiveMind is sample application code, used to demonstrate ideas and features of the framework.
+	</p>
+	
+	<p>
+	The example source code is provided with the standard distribution. You can build the code using ant.
+	Execute the "compile" target of the build.xml in the examples folder.
+	</p>
     
+	<section>
+		<title>Index of examples</title>
+		<ul>
+			<li><link href="site:examples.calc">Calculator</link>: Service construction, autowiring</li>
+			<li><link href="site:examples.panorama">Panorama Startup</link>: Schemas, contributions, unit testing</li>
+			<li><link href="site:examples.logging">Logging Interceptor</link>: Interceptors, ServiceInterceptorFactory</li>
+			<li><link href="site:examples.setters">Setters</link>: Setter based dependency injection</li>
+		</ul>
+	</section>
+		
   </body>
 </document>

Modified: jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/panorama.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/panorama.xml?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/panorama.xml (original)
+++ jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/panorama.xml Sat Aug  6 04:56:53 2005
@@ -15,7 +15,7 @@
    limitations under the License.
 -->
 
-<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" "http://xml.apache.org/forrest/dtd/document-v13.dtd"
+<!DOCTYPE document PUBLIC "-//HM//DTD Documentation V1.0//EN" "hm-document.dtd"
 [
   <!ENTITY projectroot '../'>
   <!ENTITY % common-links SYSTEM "../links.ent">
@@ -25,7 +25,7 @@
 
   <header>
     <title>Panorama Startup</title>
-  </header>
+  </header> 
   
   <body>
 <p>
@@ -121,7 +121,7 @@
 The schema definition (with desriptions removed, for compactness) follows:
 </p>  
 
-<source><![CDATA[
+<xmlsource><![CDATA[
 <schema id="Tasks">
   <element name="task">
     <attribute name="title" required="true"/>
@@ -157,7 +157,7 @@
       <read-attribute attribute="method" property="methodName"/>       
     </rules>
   </element>
-</schema>]]></source>
+</schema>]]></xmlsource>
 
 <note>
 For more details, see <link href="hivedocs/schema/panorama.startup.Tasks.html">the HiveDoc for
@@ -204,7 +204,7 @@
   a Startup service that uses the configuration point.
 </p>  
 
-<source><![CDATA[
+<xmlsource><![CDATA[
 <configuration-point id="Startup" schema-id="Tasks"/>
 
 <service-point id="Startup" interface="java.lang.Runnable">
@@ -217,7 +217,7 @@
 
 <contribution id="hivemind.Startup">
   <startup object="service:Startup"/>
-</contribution>]]></source>
+</contribution>]]></xmlsource>
   
 
 <p>
@@ -237,18 +237,7 @@
 <section>
   <title>Executable.java</title>
 
-<source><![CDATA[package com.panorama.startup;
-
-/**
- * Much like {@link java.lang.Runnable}, but allows the caller
- * to handle any exceptions thrown.
- *
- * @author Howard Lewis Ship
- */
-public interface Executable
-{
-    public void execute() throws Exception;
-}]]></source>
+<javasourcefile file="examples/src/java/com/panorama/startup/Executable.java" />
 
 <p>
 The Executable interface is implemented by tasks, and by services or other objects that need to
@@ -262,82 +251,7 @@
 <section>
   <title>Task.java</title>
   
-<source><![CDATA[package com.panorama.startup.impl;
-
-import org.apache.hivemind.impl.BaseLocatable;
-
-import com.panorama.startup.Executable;
-
-/**
- * An operation that may be executed. A Task exists to wrap
- * an {@link com.panorama.startup.Executable} object with
- * a title and ordering information (id, after, before).
- *
- * @author Howard Lewis Ship
- */
-public class Task extends BaseLocatable implements Executable
-{
-    private String _id;
-    private String _title;
-    private String _after;
-    private String _before;
-    private Executable _executable;
-
-    public String getBefore()
-    {
-        return _before;
-    }
-
-    public String getId()
-    {
-        return _id;
-    }
-
-    public String getAfter()
-    {
-        return _after;
-    }
-
-    public String getTitle()
-    {
-        return _title;
-    }
-
-    public void setExecutable(Executable executable)
-    {
-        _executable = executable;
-    }
-
-    public void setBefore(String string)
-    {
-        _before = string;
-    }
-
-    public void setId(String string)
-    {
-        _id = string;
-    }
-
-    public void setAfter(String string)
-    {
-        _after = string;
-    }
-
-    public void setTitle(String string)
-    {
-        _title = string;
-    }
-
-    /**
-     * Delegates to the {@link #setExecutable(Executable) executable} object.
-     */
-    public void execute() throws Exception
-    {
-        _executable.execute();
-    }
-
-}
-]]></source>  
+<javasourcefile file="examples/src/java/com/panorama/startup/impl/Task.java" />
 
 <p>
 The Task class is a wrapper around an Executable object; whether that's a service, some arbitrary object,
@@ -350,50 +264,7 @@
   <title>ExecuteStatic.java</title>
 
 
-<source><![CDATA[package com.panorama.startup.impl;
-
-import java.lang.reflect.Method;
-
-import com.panorama.startup.Executable;
-
-/**
- * Used to access the legacy startup code that is in the form
- * of a public static method (usually <code>init()</code>) on some
- * class.
- *
- * @author Howard Lewis Ship
- */
-public class ExecuteStatic implements Executable
-{
-    private String _methodName = "init";
-    private Class _targetClass;
-
-    public void execute() throws Exception
-    {
-        Method m = _targetClass.getMethod(_methodName, null);
-
-        m.invoke(null, null);
-    }
-
-    /**
-     * Sets the name of the method to invoke; if not set, the default is <code>init</code>.
-     * The target class must have a public static method with that name taking no
-     * parameters.
-     */
-    public void setMethodName(String string)
-    {
-        _methodName = string;
-    }
-
-    /**
-     * Sets the class to invoke the method on.
-     */
-    public void setTargetClass(Class targetClass)
-    {
-        _targetClass = targetClass;
-    }
-}
-]]></source>
+<javasourcefile file="examples/src/java/com/panorama/startup/impl/ExecuteStatic.java" />
 
 <p>
 ExecuteStatic uses Java reflection to invoke a public static method of a particular class.
@@ -404,141 +275,7 @@
 <section>
   <title>TaskExecutor.java</title>
   
-<source><![CDATA[package com.panorama.startup.impl;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.hivemind.ErrorLog;
-import org.apache.hivemind.Messages;
-import org.apache.hivemind.order.Orderer;
-
-/**
- * A service that executes a series of {@link com.panorama.startup.impl.Task}s. Tasks have
- * an ordering based on pre- and post-requisites.
- *
- * @author Howard Lewis Ship
- */
-public class TaskExecutor implements Runnable
-{
-    private ErrorLog _errorLog;
-    private Log _log;
-    private List _tasks;
-    private Messages _messages;
-
-    /**
-     * Orders the {@link #setTasks(List) tasks} into an execution order, and executes
-     * each in turn.  Logs the elapsed time, number of tasks, and the number of failures (if any).
-     */
-    public void run()
-    {
-        long startTime = System.currentTimeMillis();
- 
-        Orderer orderer = new Orderer(_errorLog, task());
-
-        Iterator i = _tasks.iterator();
-        while (i.hasNext())
-        {
-            Task t = (Task) i.next();
-
-            orderer.add(t, t.getId(), t.getAfter(), t.getBefore());
-        }
-
-        List orderedTasks = orderer.getOrderedObjects();
-
-        int failures = 0;
-
-        i = orderedTasks.iterator();
-        while (i.hasNext())
-        {
-            Task t = (Task) i.next();
-
-            if (!execute(t))
-                failures++;
-        }
-
-        long elapsedTime = System.currentTimeMillis() - startTime;
-
-        if (failures == 0)
-            _log.info(success(orderedTasks.size(), elapsedTime));
-        else
-            _log.info(failure(failures, orderedTasks.size(), elapsedTime));
-    }
-
-    /**
-     * Execute a single task.
-     * 
-     * @return true on success, false on failure
-     */
-    private boolean execute(Task t)
-    {
-        _log.info(executingTask(t));
-
-        try
-        {
-            t.execute();
-
-            return true;
-        }
-        catch (Exception ex)
-        {
-            _errorLog.error(exceptionInTask(t, ex), t.getLocation(), ex);
-
-            return false;
-        }
-    }
-
-    private String task()
-    {
-        return _messages.getMessage("task");
-    }
-
-    private String executingTask(Task t)
-    {
-        return _messages.format("executing-task", t.getTitle());
-    }
-
-    private String exceptionInTask(Task t, Throwable cause)
-    {
-        return _messages.format("exception-in-task", t.getTitle(), cause);
-    }
-
-    private String success(int count, long elapsedTimeMillis)
-    {
-        return _messages.format("success", new Integer(count), new Long(elapsedTimeMillis));
-    }
-
-    private String failure(int failureCount, int totalCount, long elapsedTimeMillis)
-    {
-        return _messages.format(
-            "failure",
-            new Integer(failureCount),
-            new Integer(totalCount),
-            new Long(elapsedTimeMillis));
-    }
-
-    public void setErrorLog(ErrorLog errorLog)
-    {
-        _errorLog = errorLog;
-    }
-
-    public void setLog(Log log)
-    {
-        _log = log;
-    }
-
-    public void setMessages(Messages messages)
-    {
-        _messages = messages;
-    }
-
-    public void setTasks(List list)
-    {
-        _tasks = list;
-    }
-
-}]]></source>
+<javasourcefile file="examples/src/java/com/panorama/startup/impl/TaskExecutor.java" />
   
 <p>
 This class is where it all comes together; it is the core service implementation for the
@@ -573,108 +310,7 @@
   <title>TestTaskExcecutor.java</title>
 </section>
 
-<source><![CDATA[package com.panorama.startup.impl;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.commons.logging.Log;
-import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.ErrorLog;
-import org.apache.hivemind.Messages;
-import org.apache.hivemind.Resource;
-import org.apache.hivemind.impl.MessagesImpl;
-import org.apache.hivemind.test.ExceptionAwareArgumentsMatcher;
-import org.apache.hivemind.test.HiveMindTestCase;
-import org.apache.hivemind.test.RegexpArgumentsMatcher;
-import org.apache.hivemind.util.FileResource;
-import org.easymock.MockControl;
-
-import com.panorama.startup.Executable;
-
-/**
- * Tests for the {@link com.panorama.startup.impl.TaskExecutor} service.
- *
- * @author Howard Lewis Ship
- */
-public class TestTaskExecutor extends HiveMindTestCase
-{
-    private static List _tokens = new ArrayList();
-
-    protected void setUp()
-    {
-        _tokens.clear();
-    }
-
-    protected void tearDown()
-    {
-        _tokens.clear();
-    }
-
-    public static void addToken(String token)
-    {
-        _tokens.add(token);
-    }
-
-    public Messages getMessages()
-    {
-      . . .
-    }
-
-    public void testSuccess()
-    {
-        ExecutableFixture f1 = new ExecutableFixture("f1");
-
-        Task t1 = new Task();
-
-        t1.setExecutable(f1);
-        t1.setId("first");
-        t1.setAfter("second");
-        t1.setTitle("Fixture #1");
-
-        ExecutableFixture f2 = new ExecutableFixture("f2");
-
-        Task t2 = new Task();
-        t2.setExecutable(f2);
-        t2.setId("second");
-        t2.setTitle("Fixture #2");
-
-        List tasks = new ArrayList();
-        tasks.add(t1);
-        tasks.add(t2);
-
-        MockControl logControl = newControl(Log.class);
-        Log log = (Log) logControl.getMock();
-
-        TaskExecutor e = new TaskExecutor();
-
-        ErrorLog errorLog = (ErrorLog) newMock(ErrorLog.class);
-
-        e.setErrorLog(errorLog);
-        e.setLog(log);
-        e.setMessages(getMessages());
-        e.setTasks(tasks);
-
-        // Note the ordering; explicitly set, to check that ordering does
-        // take place.
-        log.info("Executing task Fixture #2.");
-        log.info("Executing task Fixture #1.");
-        log.info("Executed 2 tasks \\(in \\d+ milliseconds\\)\\.");
-        logControl.setMatcher(new RegexpArgumentsMatcher());
-
-        replayControls();
-
-        e.run();
-
-        assertListsEqual(new String[] { "f2", "f1" }, _tokens);
-
-        verifyControls();
-    }
-
-}
-]]></source>  
+<javasourcefile file="examples/src/test/com/panorama/startup/impl/TestTaskExecutor.java" />
  
 <p>
 In this listing (which is a paired down version of the real class), you can see how 

Added: jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/setters.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/setters.xml?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/setters.xml (added)
+++ jakarta/hivemind/trunk/examples/src/documentation/content/xdocs/hivemind-examples/setters.xml Sat Aug  6 04:56:53 2005
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<!-- 
+   Copyright 2004, 2005 The Apache Software Foundation
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<!DOCTYPE document PUBLIC "-//HM//DTD Documentation V1.0//EN" "hm-document.dtd"
+  
+[
+    <!ENTITY projectroot '../'>
+    <!ENTITY % common-links SYSTEM "../links.ent">
+    %common-links;
+]>
+<document>
+
+  <header>
+    <title>Setter based dependency injection</title>
+    </header>
+    
+  <body>
+
+	<p>
+	This example demonstrates the use of setter based injection for the
+	construction of service points. All "set-xxx" elements that are understood
+	by the BuilderFactory are used.
+	</p>
+	<section>
+		<title>settersRegistry.xml</title>
+		<xmlsourcefile file="examples/src/java/org/apache/hivemind/examples/setters/setters.xml" />
+	</section>
+	<section>
+		<title>SetterService.java</title>
+		<javasourcefile file="examples/src/java/org/apache/hivemind/examples/setters/SetterService.java" />
+	</section>
+
+  </body>
+</document>

Modified: jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/Executable.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/Executable.java?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/Executable.java (original)
+++ jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/Executable.java Sat Aug  6 04:56:53 2005
@@ -1,17 +1,3 @@
-// Copyright 2004, 2005 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
 package com.panorama.startup;
 
 /**

Modified: jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/PanoramaMain.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/PanoramaMain.java?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/PanoramaMain.java (original)
+++ jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/PanoramaMain.java Sat Aug  6 04:56:53 2005
@@ -1,17 +1,3 @@
-// Copyright 2004, 2005 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
 package com.panorama.startup;
 
 import org.apache.hivemind.Registry;

Modified: jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/ExecuteStatic.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/ExecuteStatic.java?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/ExecuteStatic.java (original)
+++ jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/ExecuteStatic.java Sat Aug  6 04:56:53 2005
@@ -1,17 +1,3 @@
-// Copyright 2004, 2005 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
 package com.panorama.startup.impl;
 
 import java.lang.reflect.Method;

Modified: jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/Task.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/Task.java?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/Task.java (original)
+++ jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/Task.java Sat Aug  6 04:56:53 2005
@@ -1,17 +1,3 @@
-// Copyright 2004, 2005 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
 package com.panorama.startup.impl;
 
 import org.apache.hivemind.impl.BaseLocatable;

Modified: jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/TaskExecutor.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/TaskExecutor.java?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/TaskExecutor.java (original)
+++ jakarta/hivemind/trunk/examples/src/java/com/panorama/startup/impl/TaskExecutor.java Sat Aug  6 04:56:53 2005
@@ -1,17 +1,3 @@
-// Copyright 2004, 2005 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
 package com.panorama.startup.impl;
 
 import java.util.Iterator;

Modified: jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/ExampleUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/ExampleUtils.java?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/ExampleUtils.java (original)
+++ jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/ExampleUtils.java Sat Aug  6 04:56:53 2005
@@ -14,14 +14,20 @@
 
 package org.apache.hivemind.examples;
 
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Locale;
 
 import org.apache.hivemind.ClassResolver;
+import org.apache.hivemind.ModuleDescriptorProvider;
 import org.apache.hivemind.Registry;
+import org.apache.hivemind.Resource;
 import org.apache.hivemind.impl.DefaultClassResolver;
 import org.apache.hivemind.impl.RegistryBuilder;
 import org.apache.hivemind.impl.XmlModuleDescriptorProvider;
 import org.apache.hivemind.util.FileResource;
+import org.apache.hivemind.util.URLResource;
 
 /**
  * Utilities needed by the examples.
@@ -46,16 +52,67 @@
         String path = projectRoot + "/examples/src/descriptor/META-INF/" + fileName;
 
         ClassResolver resolver = new DefaultClassResolver();
-        RegistryBuilder builder = new RegistryBuilder();
-
-        builder.addModuleDescriptorProvider(new XmlModuleDescriptorProvider(resolver));
 
         // Register the examples.xml file, which (given its non-standard name)
         // is not visible.
-        builder.addModuleDescriptorProvider(new XmlModuleDescriptorProvider(resolver,
-                new FileResource(path)));
+        ModuleDescriptorProvider provider = new XmlModuleDescriptorProvider(resolver,
+                new FileResource(path));
+        return buildRegistry(provider);
+    }
+    
+    /**
+     * Convenience method for invoking {@link #buildClasspathRegistry(String[])} with only a single
+     * file.
+     */
+    public static Registry buildClasspathRegistry(String file) throws Exception
+    {
+        return buildClasspathRegistry(new String[] { file });
+    }
+
+    /**
+     * Builds a registry for files in the classpath.
+     */
+    public static Registry buildClasspathRegistry(String[] files) throws Exception
+    {
+        ClassResolver resolver = new DefaultClassResolver();
+
+        List descriptorResources = new ArrayList();
+        for (int i = 0; i < files.length; i++)
+        {
+            Resource resource = getResource(files[i]);
+            descriptorResources.add(resource);
+        }
+
+        ModuleDescriptorProvider provider = new XmlModuleDescriptorProvider(resolver,
+                descriptorResources);
+
+        return buildRegistry(provider);
+    }
+    
+    protected static Registry buildRegistry(ModuleDescriptorProvider customProvider)
+    {
+        ClassResolver resolver = new DefaultClassResolver();
+
+        RegistryBuilder builder = new RegistryBuilder();
+
+        builder.addModuleDescriptorProvider(new XmlModuleDescriptorProvider(resolver));
+        builder.addModuleDescriptorProvider(customProvider);
 
         return builder.constructRegistry(Locale.getDefault());
+    }
+    
+    /**
+     * Returns the given file as a {@link Resource} from the classpath. Typically, this is to find
+     * files in the same folder as the invoking class.
+     */
+    protected static Resource getResource(String file)
+    {
+        URL url = ExampleUtils.class.getResource(file);
+
+        if (url == null)
+            throw new NullPointerException("No resource named '" + file + "'.");
+
+        return new URLResource(url);
     }
 
 }

Added: jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/SetterService.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/SetterService.java?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/SetterService.java (added)
+++ jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/SetterService.java Sat Aug  6 04:56:53 2005
@@ -0,0 +1,94 @@
+package org.apache.hivemind.examples.setters;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.hivemind.Resource;
+import org.apache.hivemind.examples.Adder;
+
+/**
+ * Demonstrates the use of setter based dependency injection using the BuilderFactory.
+ * 
+ * @author Achim Huegen
+ */
+public class SetterService implements Runnable
+{
+    private String _stringValue;
+
+    private int _intValue;
+
+    private double _doubleValue;
+
+    private Adder _adderService;
+
+    private List _configuration;
+
+    private Collection _container;
+
+    private Resource _textResource;
+
+    public void setAdderService(Adder adderService)
+    {
+        _adderService = adderService;
+    }
+
+    public void setConfiguration(List configuration)
+    {
+        _configuration = configuration;
+    }
+
+    public void setContainer(Collection container)
+    {
+        _container = container;
+    }
+
+    public void setDoubleValue(double doubleValue)
+    {
+        _doubleValue = doubleValue;
+    }
+
+    public void setIntValue(int intValue)
+    {
+        _intValue = intValue;
+    }
+
+    public void setStringValue(String stringValue)
+    {
+        _stringValue = stringValue;
+    }
+
+    public void setTextResource(Resource textResource)
+    {
+        _textResource = textResource;
+    }
+
+    public void run()
+    {
+        System.out.println("StringValue: " + _stringValue);
+        System.out.println("IntValue: " + _intValue);
+        System.out.println("DoubleValue: " + _doubleValue);
+        System.out.println("AdderService result: " + _adderService.add(10, 20));
+        System.out.println("Configuration size: " + _configuration.size());
+        System.out.println("Container type: " + _container.getClass().getName());
+        Properties properties = loadResource();
+        System.out.println("Text resource content: " + properties.toString());
+    }
+
+    /**
+     * Loads the properties file reference by property textResource
+     */
+    private Properties loadResource()
+    {
+        Properties properties = new Properties();
+        try
+        {
+            properties.load(_textResource.getResourceURL().openStream());
+        }
+        catch (IOException ignore)
+        {
+        }
+        return properties;
+    }
+}

Added: jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/setters.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/setters.xml?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/setters.xml (added)
+++ jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/setters.xml Sat Aug  6 04:56:53 2005
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module id="hivemind.examples.setters" version="1.0.0">
+	
+	<service-point id="Service" interface="java.lang.Runnable">
+		<invoke-factory>			
+			<construct class="org.apache.hivemind.examples.setters.SetterService">
+				<set property="stringValue" value="Hello world." />
+				<set property="intValue" value="20" />
+				<set property="doubleValue" value="11.23" />
+				<set-object property="container" value="instance:java.util.HashSet" />
+				<set-configuration property="configuration" configuration-id="hivemind.Translators" />
+				<set-resource property="textResource" path="textResource.properties" />
+				<set-service property="adderService" service-id="Adder"/>
+			</construct>
+		</invoke-factory>
+	</service-point>
+	
+	<service-point id="Adder" interface="org.apache.hivemind.examples.Adder">
+		<create-instance class="org.apache.hivemind.examples.impl.AdderImpl"/>
+	</service-point>
+	
+</module>
\ No newline at end of file

Added: jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/textResource.properties
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/textResource.properties?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/textResource.properties (added)
+++ jakarta/hivemind/trunk/examples/src/java/org/apache/hivemind/examples/setters/textResource.properties Sat Aug  6 04:56:53 2005
@@ -0,0 +1,2 @@
+Key1		= Text1
+Key2		= Text2
\ No newline at end of file

Modified: jakarta/hivemind/trunk/examples/src/test/com/panorama/startup/impl/TestTaskExecutor.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/test/com/panorama/startup/impl/TestTaskExecutor.java?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/examples/src/test/com/panorama/startup/impl/TestTaskExecutor.java (original)
+++ jakarta/hivemind/trunk/examples/src/test/com/panorama/startup/impl/TestTaskExecutor.java Sat Aug  6 04:56:53 2005
@@ -1,17 +1,3 @@
-// Copyright 2004, 2005 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
 package com.panorama.startup.impl;
 
 import java.util.ArrayList;

Added: jakarta/hivemind/trunk/examples/src/test/org/apache/hivemind/examples/setters/TestSetters.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/examples/src/test/org/apache/hivemind/examples/setters/TestSetters.java?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/examples/src/test/org/apache/hivemind/examples/setters/TestSetters.java (added)
+++ jakarta/hivemind/trunk/examples/src/test/org/apache/hivemind/examples/setters/TestSetters.java Sat Aug  6 04:56:53 2005
@@ -0,0 +1,21 @@
+package org.apache.hivemind.examples.setters;
+
+import org.apache.hivemind.Registry;
+import org.apache.hivemind.examples.ExampleUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Runs the setters example.
+ * 
+ * @author Achim Huegen
+ */
+public class TestSetters extends TestCase
+{
+    public void testRun() throws Exception
+    {
+        Registry registry = ExampleUtils.buildClasspathRegistry("/org/apache/hivemind/examples/setters/setters.xml");
+        Runnable setterService = (Runnable) registry.getService("hivemind.examples.setters.Service", Runnable.class);
+        setterService.run();
+    }
+}

Modified: jakarta/hivemind/trunk/hivebuild/forrestdoc.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/hivebuild/forrestdoc.xml?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/hivebuild/forrestdoc.xml (original)
+++ jakarta/hivemind/trunk/hivebuild/forrestdoc.xml Sat Aug  6 04:56:53 2005
@@ -17,33 +17,77 @@
 
 <project name="forrestdoc">
 	
+		<property name="jhighlight.lib" value="${external.lib.dir}/jhighlight-1.0rc.jar" />
+
 		<fail unless="ant.file.hivebuild" message="Must import hivebuild.xml first."/>
 		<fail unless="ant.file.dependency" message="Must import dependency.xml first."/>
 
-		<property name="forrest-package-dir" value="${external.package.dir}/apache-forrest-0.6"/>
-    <property name="forrest.home" location="${forrest-package-dir}/src/core"/>
+	  <!-- compile additional transformers (sourceHighlighter) -->
+		<target name="-compileForrestTransformer" description="">
+			<!-- jhighlight is currently not available on ibiblio but this will change soon ... -->  
+			<antcall target="-display-download-warning"/>
+			<grab-file dest="${jhighlight.lib}"
+				src="http://www.yagni.de/download/jhighlight-1.0rc.jar" />
+				
+      <mkdir dir="${hivebuild.classes.dir}"/>
+      <property environment="env"/>
+      <javac srcdir="tools/forrest/src"
+        destdir="${hivebuild.classes.dir}" debug="on" verbose="on" debuglevel="lines,vars,source">
+				<classpath>
+					<pathelement location="${jhighlight.lib}"/>
+					<fileset dir="${env.FORREST_HOME}" id="id">
+					    <include name="**/*.jar"/>
+					</fileset>
+				</classpath>
+      </javac>
+			<!-- Create a jar in forrest optional lib folder -->
+			<jar destfile="${env.FORREST_HOME}/lib/optional/hivemindTransformers.jar"
+						update="false">
+				<fileset dir="${hivebuild.classes.dir}">
+			  	<include name="**/*.class"/>
+				</fileset>
+			</jar>
+			<copy todir="${env.FORREST_HOME}/lib/optional" file="${jhighlight.lib}">
+			</copy>
+	  </target>
+	
+	  <!-- macro for launching forrest (0.7) -->
+		<macrodef name="forrest">
+			<attribute name="target" default="run" description="target for forrest to execute"/>
+			<sequential>
+	      <property environment="env"/>
+				<property name="forrest.home" location="${env.FORREST_HOME}" />
+			  <property name="forrest.ant.home" location="${forrest.home}/tools/ant" />
+			  <java classname="org.apache.tools.ant.Main" fork="true" failonerror="true" maxmemory="128M">
+			    <classpath>
+						<pathelement location="${jhighlight.lib}"/>
+			      <fileset dir="${forrest.ant.home}/lib">
+			        <include name="*.jar" />
+			      </fileset>
+			      <pathelement path="${java.home}/../lib/tools.jar" />
+			    </classpath>
+			    <sysproperty key="ant.home" value="${forrest.ant.home}" />
+			    <sysproperty key="forrest.home" value="${forrest.home}" />
+			    <sysproperty key="basedir" value="${basedir}" />
+			    <sysproperty key="java.endorsed.dirs" value="${forrest.home}/lib/endorsed" />
+			    <arg line="-f ${forrest.home}/main/forrest.build.xml @{target}" />
+			  </java>
+			</sequential>
+		</macrodef>
 
  		<target name="run-forrest" description="Runs Forrest to generate final site documentation.">
 			<announce message="Invoking Forrest ..."/>
       
-      <property environment="env"/>
-      
-      <!-- The extension is a problem; this will work for Windows and Cygwin but not pure Windows  -->
-      
-      <exec dir="${basedir}" executable="${env.FORREST_HOME}/bin/forrest.bat"/>
+      <antcall target="-compileForrestTransformer" />
+ 			
+      <forrest target="site" />
  
 		</target>
     
     <target name="live-forrest" description="Runs Forrest interactively.">
       <announce message="Invoking Forrest.  Open a browser to http://localhost:8888 ..."/>
       
-      <property environment="env"/>
-      
-      <!-- The extension is a problem; this will work for Windows and Cygwin but not pure Windows  -->
-      
-      <exec dir="${basedir}" executable="${env.FORREST_HOME}/bin/forrest.bat">
-        <arg line="run"/>
-      </exec>
+      <forrest target="run" />
     </target>
 		
 		<macrodef name="add-report-to-menu">

Modified: jakarta/hivemind/trunk/jmx/src/documentation/content/xdocs/hivemind-jmx/measurePerformance.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/jmx/src/documentation/content/xdocs/hivemind-jmx/measurePerformance.xml?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/jmx/src/documentation/content/xdocs/hivemind-jmx/measurePerformance.xml (original)
+++ jakarta/hivemind/trunk/jmx/src/documentation/content/xdocs/hivemind-jmx/measurePerformance.xml Sat Aug  6 04:56:53 2005
@@ -15,12 +15,12 @@
    limitations under the License.
 -->
 
-<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" 
-  "http://xml.apache.org/forrest/dtd/document-v13.dtd" [
+<!DOCTYPE document PUBLIC "-//HM//DTD Documentation V1.0//EN" "hm-document.dtd"
+  [
   <!ENTITY projectroot '../'>
   <!ENTITY % common-links SYSTEM "../links.ent">
   %common-links;
-  ]>
+  ]> 
 <document>
   <header>
     <title>Measure service performance</title>
@@ -32,7 +32,8 @@
   		execution duration.<br/>
   		Add the Interceptor to your service and choose which methods
   		are to be intercepted by inclusion and exclusion:</p>
-			<source><![CDATA[
+
+			<xmlsource><![CDATA[
 <service-point id="Calculator" 
     interface="org.apache.hivemind.management.Calculator">
   <invoke-factory>
@@ -43,7 +44,7 @@
     <include method="add"/>
     <include method="subtract"/>
   </interceptor>
-</service-point>]]></source>
+</service-point>]]></xmlsource>
 	<p>
 		The statistics are displayed by a MBean named like your service, 
 		with an additional name part "decorator=PerformanceCollector":<br/><br/>

Added: jakarta/hivemind/trunk/src/documentation/classes/CatalogManager.properties
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/src/documentation/classes/CatalogManager.properties?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/src/documentation/classes/CatalogManager.properties (added)
+++ jakarta/hivemind/trunk/src/documentation/classes/CatalogManager.properties Sat Aug  6 04:56:53 2005
@@ -0,0 +1,30 @@
+# verbosity:
+# The level of messages for status/debug (messages go to standard output).
+# The setting here is for your own local catalogs.
+# The verbosity of Forrest's core catalogs is controlled via
+#  main/webapp/WEB-INF/cocoon.xconf
+#
+# The following messages are provided ...
+#  0 = none
+#  1 = ? (... not sure yet)
+#  2 = 1+, Loading catalog, Resolved public, Resolved system
+#  3 = 2+, Catalog does not exist, resolvePublic, resolveSystem
+#  10 = 3+, List all catalog entries when loading a catalog
+#    (Cocoon also logs the "Resolved public" messages.)
+verbosity=1
+
+# catalogs ... list of additional catalogs to load
+#  (Note that Apache Forrest will automatically load its own default catalog
+#  from main/webapp/resources/schema/catalog.xcat)
+# Use either full pathnames or relative pathnames.
+# pathname separator is always semi-colon (;) regardless of operating system
+# directory separator is always slash (/) regardless of operating system
+catalogs=../resources/schema/catalog.xcat
+
+# relative-catalogs
+# If false, relative catalog URIs are made absolute with respect to the
+# base URI of the CatalogManager.properties file. This setting only 
+# applies to catalog URIs obtained from the catalogs property in the
+# CatalogManager.properties file
+# Example: relative-catalogs=[yes|no]
+relative-catalogs=no

Modified: jakarta/hivemind/trunk/src/documentation/content/xdocs/site.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/src/documentation/content/xdocs/site.xml?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/src/documentation/content/xdocs/site.xml (original)
+++ jakarta/hivemind/trunk/src/documentation/content/xdocs/site.xml Sat Aug  6 04:56:53 2005
@@ -177,6 +177,7 @@
       <examples.calc label="Calculator" href="calc.html"/>
       <examples.panorama label="Panorama Startup" href="panorama.html"/>
       <examples.logging label="Logging Interceptor" href="logging.html"/>
+      <examples.setters href="setters.html"/>
       
       <reports label="Reports">
         &hivemind-examples-report-menu.ent;

Added: jakarta/hivemind/trunk/src/documentation/resources/schema/catalog.xcat
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/src/documentation/resources/schema/catalog.xcat?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/src/documentation/resources/schema/catalog.xcat (added)
+++ jakarta/hivemind/trunk/src/documentation/resources/schema/catalog.xcat Sat Aug  6 04:56:53 2005
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<!-- Defines the new document type that allows source highlighting sections -->
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+  <public publicId="-//HM//DTD Documentation V1.0//EN"
+    uri="dtd/hm-document.dtd"/>
+</catalog>

Added: jakarta/hivemind/trunk/src/documentation/resources/schema/dtd/hm-document.dtd
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/src/documentation/resources/schema/dtd/hm-document.dtd?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/src/documentation/resources/schema/dtd/hm-document.dtd (added)
+++ jakarta/hivemind/trunk/src/documentation/resources/schema/dtd/hm-document.dtd Sat Aug  6 04:56:53 2005
@@ -0,0 +1,46 @@
+<!-- =============================================================== -->
+<!-- Include the Common ISO Character Entity Sets -->
+<!-- =============================================================== -->
+
+<!ENTITY % common-charents PUBLIC
+"-//APACHE//ENTITIES Common Character Entity Sets V1.0//EN"
+"common-charents-v10.mod">
+%common-charents;
+
+<!-- =============================================================== -->
+<!-- Document -->
+<!-- =============================================================== -->
+
+<!ENTITY % document PUBLIC "-//APACHE//ENTITIES Documentation V1.3//EN"
+"document-v13.mod">
+
+<!-- Override this entity so that 'javasource' is allowed below 'section' -->
+<!ENTITY % local.sections "|javasource|javasourcefile|xmlsource|xmlsourcefile">
+
+%document;
+
+<!ELEMENT javasource (%content.mix;)*>
+<!ATTLIST javasource
+  %common.att; 
+  %xmlspace.att; 
+>
+
+<!ELEMENT javasourcefile EMPTY>
+<!ATTLIST javasourcefile
+  file CDATA #REQUIRED
+>
+
+<!ELEMENT xmlsource (%content.mix;)*>
+<!ATTLIST xmlsource
+  %common.att; 
+  %xmlspace.att; 
+>
+
+<!ELEMENT xmlsourcefile EMPTY>
+<!ATTLIST xmlsourcefile
+  file CDATA #REQUIRED
+>
+
+<!-- =============================================================== -->
+<!-- End of DTD -->
+<!-- =============================================================== -->

Added: jakarta/hivemind/trunk/src/documentation/resources/stylesheets/sourceHighlighter.xsl
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/src/documentation/resources/stylesheets/sourceHighlighter.xsl?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/src/documentation/resources/stylesheets/sourceHighlighter.xsl (added)
+++ jakarta/hivemind/trunk/src/documentation/resources/stylesheets/sourceHighlighter.xsl Sat Aug  6 04:56:53 2005
@@ -0,0 +1,109 @@
+<?xml version="1.0"?>
+<!-- 
+   Copyright 2004, 2005 The Apache Software Foundation
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+  <!-- Template that transforms source code that was already processed
+		   by the SourceHighlighter transformer to xhtml markup -->
+		
+	<xsl:template match="/">
+			<xsl:apply-templates/>
+	</xsl:template>
+	
+	<!-- the obligatory copy-everything -->
+	
+	<xsl:template match="node() | @*">
+			<xsl:copy>
+				<xsl:apply-templates select="@*"/>
+				<xsl:apply-templates/>
+			</xsl:copy>
+	</xsl:template>
+	
+	<!-- java code -->
+	<xsl:template match="javasource-processed">
+			<pre class="java-code">    
+				<xsl:apply-templates mode="javasource"/>
+			</pre>
+	</xsl:template>
+	
+	<xsl:template match="java-plain" mode="javasource">
+			<xsl:apply-templates/>
+	</xsl:template>
+	
+	<xsl:template match="java-keyword" mode="javasource">
+			<span class="java-keyword"><xsl:apply-templates/></span>
+	</xsl:template>
+	
+	<xsl:template match="java-type" mode="javasource">
+			<span class="java-type"><xsl:apply-templates/></span>
+	</xsl:template>
+
+	<xsl:template match="java-operator" mode="javasource">
+			<span class="java-operator"><xsl:apply-templates/></span>
+	</xsl:template>
+
+	<xsl:template match="java-separator" mode="javasource">
+			<span class="java-separator"><xsl:apply-templates/></span>
+	</xsl:template>
+
+	<xsl:template match="java-literal" mode="javasource">
+			<span class="java-literal"><xsl:apply-templates/></span>
+	</xsl:template>
+
+	<xsl:template match="java-comment" mode="javasource">
+			<span class="java-comment"><xsl:apply-templates/></span>
+	</xsl:template>
+
+	<xsl:template match="java-javadoc_comment" mode="javasource">
+			<span class="java-javadoc-comment"><xsl:apply-templates/></span>
+	</xsl:template>
+	
+	<xsl:template match="java-javadoc_tag" mode="javasource">
+			<span class="java-javadoc-tag"><xsl:apply-templates/></span>
+	</xsl:template>
+	
+	<!-- xml code -->
+	<xsl:template match="xmlsource-processed">
+			<pre class="xml-code">    
+				<xsl:apply-templates mode="xmlsource"/>
+			</pre>
+	</xsl:template>
+	
+	<xsl:template match="xml-plain" mode="xmlsource">
+			<span class="xml-plain"><xsl:apply-templates/></span>
+	</xsl:template>
+	
+	<xsl:template match="xml-tag" mode="xmlsource">
+			<span class="xml-tag"><xsl:apply-templates/></span>
+	</xsl:template>
+	
+	<xsl:template match="xml-attribute" mode="xmlsource">
+			<span class="xml-attribute"><xsl:apply-templates/></span>
+	</xsl:template>
+	
+	<xsl:template match="xml-attribute-value" mode="xmlsource">
+			<span class="xml-attribute-value"><xsl:apply-templates/></span>
+	</xsl:template>
+	
+	<xsl:template match="xml-cdata" mode="xmlsource">
+			<span class="xml-cdata"><xsl:apply-templates/></span>
+	</xsl:template>
+	
+	<xsl:template match="xml-comment" mode="xmlsource">
+			<span class="xml-comment"><xsl:apply-templates/></span>
+	</xsl:template>
+
+</xsl:stylesheet>

Added: jakarta/hivemind/trunk/src/documentation/sitemap.xmap
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/src/documentation/sitemap.xmap?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/src/documentation/sitemap.xmap (added)
+++ jakarta/hivemind/trunk/src/documentation/sitemap.xmap Sat Aug  6 04:56:53 2005
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+	<!-- custom sitemap needed for support of javasource elements -->
+  <map:components>
+    <map:actions>
+      <map:action logger="sitemap.action.sourcetype" name="sourcetype" src="org.apache.forrest.sourcetype.SourceTypeAction">
+        <sourcetype name="hm-document">
+          <document-declaration public-id="-//HM//DTD Documentation V1.0//EN" />
+        </sourcetype>
+      </map:action>
+    </map:actions>   
+    
+    <map:selectors default="parameter">
+	    <map:selector logger="sitemap.selector.parameter" name="parameter" src="org.apache.cocoon.selection.ParameterSelector" />
+    </map:selectors>
+    
+    <map:transformers >
+         <map:transformer name="sourceHighlighter" 
+           src="org.apache.hivemind.tools.forrest.SourceHighlighterTransformer" 
+           logger="SourceHighlighterTransformer" >    
+           
+         </map:transformer>
+    </map:transformers>
+    
+  </map:components>
+  
+  <map:resources>    
+    <map:resource name="transform-to-document">
+      <map:act type="sourcetype" src="{src}">
+        <map:select type="parameter">
+          <map:parameter name="parameter-selector-test" value="{sourcetype}" />
+
+					<!-- add transformer to documents that use the hm-document dtd -->
+          <map:when test="hm-document">
+		        <map:generate src="{project:content.xdocs}{../../1}.xml" />
+		        <map:transform type="sourceHighlighter" >
+          	  <map:parameter name="sourcepath" value="{project:content}../../../" />
+          	</map:transform>
+     				<map:transform src="{project:resources.stylesheets}/sourceHighlighter.xsl"/>
+            <map:serialize type="xml-document"/>
+          </map:when>
+        </map:select>
+      </map:act>
+    </map:resource>
+  </map:resources>
+  
+	 <map:pipelines>
+		  <map:pipeline>
+		   <!-- intercept the standard processing -->
+		   <map:match pattern="**.xml">
+		      <map:call resource="transform-to-document">
+		        <map:parameter name="src" value="{project:content.xdocs}{1}.xml" />
+		      </map:call>
+		    </map:match>
+		  </map:pipeline>
+	 </map:pipelines>
+</map:sitemap>
+
+

Modified: jakarta/hivemind/trunk/src/documentation/skinconf.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/src/documentation/skinconf.xml?rev=230544&r1=230543&r2=230544&view=diff
==============================================================================
--- jakarta/hivemind/trunk/src/documentation/skinconf.xml (original)
+++ jakarta/hivemind/trunk/src/documentation/skinconf.xml Sat Aug  6 04:56:53 2005
@@ -151,6 +151,74 @@
       padding: 2px;
       background-color: #ffffcc;
     }
+		
+		/* Styles for syntax highlighting of java code */
+		
+		.java-code { 
+			border: solid thin;
+			padding: 2px;
+			padding-left: 4px;
+			background-color: #ffffcc;
+		}
+		
+		.java-keyword {
+			color: #7F0055;
+			font-weight: bold;
+		}
+		
+		.java-comment {
+			color: #3F7F5F;
+			font-style: italic;
+		}
+		
+		.java-javadoc-comment {
+			color: #5078A0;
+			font-weight: normal;
+		}
+		
+		.java-javadoc-tag {
+			color: #5078A0;
+			font-weight: bold;
+		}
+		
+		.java-literal {
+			color: #2A00FF;
+		}
+		
+		.java-type,.java-operator,.java-separator {
+		}
+		
+		/* Styles for syntax highlighting of xml code */
+		
+		.xml-code { 
+			border: solid thin;
+			padding: 2px;
+			padding-left: 4px;
+			background-color: #ffffcc;
+		}
+		
+		.xml-plain {
+			color: #3F7F5F;
+		}
+		
+		.xml-tag {
+			color: #000080;
+			font-weight: bold;
+		}
+
+		.xml-attribute {
+			color: #7F0055;
+			font-weight: bold;
+		}
+		
+		.xml-attribute-value, .xml-cdata {
+		}
+  
+		.xml-comment {
+			color: #3F7F5F;
+			font-style: italic;
+		}
+		
   </extra-css>
 
   <colors>

Added: jakarta/hivemind/trunk/tools/forrest/.classpath
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/tools/forrest/.classpath?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/tools/forrest/.classpath (added)
+++ jakarta/hivemind/trunk/tools/forrest/.classpath Sat Aug  6 04:56:53 2005
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="lib" path="lib/jhighlight-1.0rc.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="var" path="FORREST_HOME/lib/core/avalon-framework-api-4.1.5.jar"/>
+	<classpathentry kind="var" path="FORREST_HOME/lib/core/cocoon-2.2.0-dev-r125082.jar"/>
+	<classpathentry kind="var" path="FORREST_HOME/lib/core/commons-logging-1.0.4.jar"/>
+	<classpathentry kind="var" path="FORREST_HOME/lib/core/excalibur-pool-api-2.0.0.jar"/>
+	<classpathentry kind="var" path="FORREST_HOME/lib/core/excalibur-xmlutil-1.0.jar"/>
+	<classpathentry kind="output" path="target/eclipse-classes"/>
+</classpath>

Added: jakarta/hivemind/trunk/tools/forrest/.project
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/tools/forrest/.project?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/tools/forrest/.project (added)
+++ jakarta/hivemind/trunk/tools/forrest/.project Sat Aug  6 04:56:53 2005
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>SourceHighlighter</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/Java2XmlRenderer.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/Java2XmlRenderer.java?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/Java2XmlRenderer.java (added)
+++ jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/Java2XmlRenderer.java Sat Aug  6 04:56:53 2005
@@ -0,0 +1,141 @@
+// Copyright 2004, 2005 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.hivemind.tools.forrest;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.cocoon.transformation.AbstractSAXTransformer;
+import com.uwyn.jhighlight.highlighter.JavaHighlighter;
+import com.uwyn.jhighlight.tools.StringUtils;
+
+/**
+ * Renders java code as xml markup that can be transformed to html.
+ * Parses the code using the JHighlight library and outputs
+ * the code embedded in special xml-elements that mark the type
+ * of the tokens. For example a java keyword is embedded
+ * in a &lt;java-keyword&gt; element.
+ * 
+ * @author Achim Huegen
+ */
+public class Java2XmlRenderer
+{
+
+    /**
+     * Processes java code. Outputs the xml code by creating sax events in the sax transformer.
+     * 
+     * @param in
+     * @param sax
+     * @param spacesPerTab
+     * @throws Exception
+     */
+    public void process(InputStream in, AbstractSAXTransformer sax, int spacesPerTab) throws Exception
+    {
+        JavaHighlighter highlighter = new JavaHighlighter();
+
+        JavaHighlighter.ASSERT_IS_KEYWORD = true;
+        Reader isr = new InputStreamReader(in);
+
+        BufferedReader r = new BufferedReader(isr);
+        String line;
+        String token;
+        int length;
+        int style;
+        String css_class;
+        String previous_class = null;
+
+        int previous_style = 0;
+
+        // Read source line by line and apply styles
+        while ((line = r.readLine()) != null)
+        {
+            line += "\n";
+            line = StringUtils.convertTabsToSpaces(line, spacesPerTab);
+
+            Reader lineReader = new StringReader(line);
+
+            highlighter.setReader(lineReader);
+
+            int index = 0;
+            while (index < line.length())
+            {
+                style = highlighter.getNextToken();
+                length = highlighter.getTokenLength();
+                token = line.substring(index, index + length);
+                if (style != previous_style)
+                {
+                    css_class = getCssClass(style);
+                    if (css_class != null)
+                    {
+                        if (previous_class != null)
+                        {
+                            sax.sendEndElementEvent(previous_class);
+                        }
+                        sax.sendStartElementEvent(css_class);
+                        previous_class = css_class;
+                        previous_style = style;
+                    }
+                }
+
+                sax.sendTextEvent(token);
+                index += length;
+
+            }
+
+        }
+        if (previous_class != null)
+        {
+            sax.sendEndElementEvent(previous_class);
+        }
+    }
+
+    /**
+     * Map the jhighlighter styles to css styles
+     * @param style
+     * @return css style
+     */
+    protected String getCssClass(int style)
+    {
+        switch (style)
+        {
+        case JavaHighlighter.PLAIN_STYLE:
+            return "java-plain";
+        case JavaHighlighter.KEYWORD_STYLE:
+            return "java-keyword";
+        case JavaHighlighter.TYPE_STYLE:
+            return "java-type";
+        case JavaHighlighter.OPERATOR_STYLE:
+            return "java-operator";
+        // ignore separators, special formatting not needed
+        // case JavaHighlighter.SEPARATOR_STYLE:
+        // return "java-separator";
+        case JavaHighlighter.LITERAL_STYLE:
+            return "java-literal";
+        case JavaHighlighter.JAVA_COMMENT_STYLE:
+            return "java-comment";
+        case JavaHighlighter.JAVADOC_COMMENT_STYLE:
+            return "java-javadoc_comment";
+        case JavaHighlighter.JAVADOC_TAG_STYLE:
+            return "java-javadoc_tag";
+        }
+
+        return null;
+
+    }
+
+}
\ No newline at end of file

Added: jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/SourceHighlighterTransformer.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/SourceHighlighterTransformer.java?rev=230544&view=auto
==============================================================================
--- jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/SourceHighlighterTransformer.java (added)
+++ jakarta/hivemind/trunk/tools/forrest/src/org/apache/hivemind/tools/forrest/SourceHighlighterTransformer.java Sat Aug  6 04:56:53 2005
@@ -0,0 +1,245 @@
+// Copyright 2004, 2005 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.hivemind.tools.forrest;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.sitemap.PatternException;
+import org.apache.cocoon.transformation.AbstractSAXTransformer;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * Cocoon transformer that highlights java and xml source code.
+ * Supports the javasource, xmlsource, javasourcefiles and 
+ * xmlsourcefile attributes.
+ * javasource/xmlsource: the content embedded in the tag is highlighted
+ * javasourcefile/xmlsourcefile: the file referenced by the file attribute 
+ * is loaded, hightlighted and inserted at the tag position.
+ * 
+ * The source file names must be defined relative. Multiple root
+ * folders can be defined in sitemap.xmap by the parameter <code>sourcepath</code>.
+ * Multiple paths must be separated by semicolons. A file is searched
+ * for in all root paths in the order of definition.
+ * 
+ * @author Achim Huegen
+ */
+public class SourceHighlighterTransformer extends AbstractSAXTransformer
+{
+    private static final String JAVASOURCE_TAG_NAME = "javasource";
+    private static final String JAVASOURCEFILE_TAG_NAME = "javasourcefile";
+    private static final String XMLSOURCE_TAG_NAME = "xmlsource";
+    private static final String XMLSOURCEFILE_TAG_NAME = "xmlsourcefile";
+    
+    private List _sourcepaths = new ArrayList();
+    private int javaSourceSpacesPerTab = 2;
+    private int xmlSourceSpacesPerTab = 2;
+    
+    static
+    {
+        System.out.println("SourceHighlighterTransformer activated");
+    }
+
+    public SourceHighlighterTransformer()
+    {
+    }
+
+    public void endElement(String uri, String name, String raw) throws SAXException
+    {
+        try
+        {
+            if (name.equals(JAVASOURCE_TAG_NAME))
+            {
+                String srcStr = this.endTextRecording();
+                Java2XmlRenderer render = new Java2XmlRenderer();
+                // Highlight code that is embedded in tag
+                sendStartElementEvent("javasource-processed");
+                InputStream codeStream = new ByteArrayInputStream(srcStr.getBytes());
+                render.process(codeStream, this, javaSourceSpacesPerTab);
+                sendEndElementEvent("javasource-processed");
+            }
+            else if (name.equals(JAVASOURCEFILE_TAG_NAME)) {
+                // don't call super
+            }
+            else if (name.equals(XMLSOURCE_TAG_NAME))
+            {
+                String srcStr = this.endTextRecording();
+                Xml2XmlRenderer render = new Xml2XmlRenderer();
+                // Highlight code that is embedded in tag
+                sendStartElementEvent("xmlsource-processed");
+                InputStream codeStream = new ByteArrayInputStream(srcStr.getBytes());
+                render.process(codeStream, this, xmlSourceSpacesPerTab);
+                sendEndElementEvent("xmlsource-processed");
+            }
+            else if (name.equals(XMLSOURCEFILE_TAG_NAME)) {
+                // don't call super
+            }
+            else {
+                super.endElement(uri, name, raw);
+            }
+        }
+        catch (RuntimeException e)
+        {
+            // Forrest/Cocoon error handling needs some support
+            e.printStackTrace();
+            throw e;
+        }
+        catch (Throwable e)
+        {
+            e.printStackTrace();
+            throw new SAXException(e.getMessage());
+        }
+
+    }
+    
+    public void startElement(String uri, String name, String raw, Attributes attr) throws SAXException
+    {
+        try
+        {
+            if (name.equals(JAVASOURCE_TAG_NAME))
+            {
+                this.startTextRecording();
+            }
+            else if (name.equals(JAVASOURCEFILE_TAG_NAME)) {
+                System.out.println("Highlighting file started");  
+                // Read java source file and highlight content
+                String fileName = attr.getValue("file");
+                InputStream codeStream = readSourceFile(fileName);
+                if (codeStream != null) {
+                    Java2XmlRenderer render = new Java2XmlRenderer();
+                    sendStartElementEvent("javasource-processed");
+                    render.process(codeStream, this, javaSourceSpacesPerTab);
+                    sendEndElementEvent("javasource-processed");
+                }
+                System.out.println("Highlighting file finished");  
+            } 
+            else if (name.equals(XMLSOURCE_TAG_NAME))
+            {
+                this.startTextRecording();
+            }
+            else if (name.equals(XMLSOURCEFILE_TAG_NAME)) {
+                System.out.println("Highlighting file started");  
+                // Read xml file and highlight content
+                String fileName = attr.getValue("file");
+                InputStream codeStream = readSourceFile(fileName);
+                if (codeStream != null) {
+                    Xml2XmlRenderer render = new Xml2XmlRenderer();
+                    sendStartElementEvent("xmlsource-processed");
+                    render.process(codeStream, this, xmlSourceSpacesPerTab);
+                    sendEndElementEvent("xmlsource-processed");
+                }
+                System.out.println("Highlighting file finished");  
+            } 
+            else {
+                super.startElement(uri, name, raw, attr);
+            }
+        }
+        catch (FileNotFoundException e) {
+            throw new SAXException(e.getMessage());
+        }
+        catch (RuntimeException e)
+        {
+            // Forrest/Cocoon error handling needs some support
+            e.printStackTrace();
+            throw e;
+        }
+        catch (Throwable e)
+        {
+            e.printStackTrace();
+            throw new SAXException(e.getMessage());
+        }
+    }
+
+    /**
+     * Reads a source file 
+     * @param fileName  path relative to a root folder
+     * @return
+     * @throws FileNotFoundException
+     */
+    protected InputStream readSourceFile(String fileName) throws FileNotFoundException
+    {
+        for (Iterator iter = _sourcepaths.iterator(); iter.hasNext();)
+        {
+            String sourcepath = (String) iter.next();
+            String absFileName = sourcepath + File.separator + fileName;
+            File file = new File(absFileName);
+            if (file.exists()) {
+                InputStream result = new FileInputStream(absFileName);
+                return result;
+            }
+        }
+        throw new FileNotFoundException("Source File " + fileName + " couldn't be found.");
+    }
+
+    /**
+     * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
+     */
+    public void setup(SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws ProcessingException, SAXException, IOException
+    {
+        super.setup(resolver, objectModel, source, parameters);
+        try {
+            String sourcePaths = parameters.getParameter("sourcepath", "");
+            StringTokenizer tokenizer = new StringTokenizer(sourcePaths, ";");
+            while (tokenizer.hasMoreElements())
+            {
+                String path = (String) tokenizer.nextElement();
+                path = makeAbsolutePath(path);
+                _sourcepaths.add(path);
+            }
+        } catch (Throwable e) {
+            e.printStackTrace();
+            throw new ProcessingException(e.getMessage());
+        }
+    }
+    
+    /**
+     * Resolves variables in path and makes it absolute
+     * @param path
+     * @return
+     * @throws ProcessingException
+     * @throws IOException
+     */
+    private String makeAbsolutePath(String path) throws ProcessingException, IOException 
+    {
+        String resolvedPath = null;
+        try
+        {
+            VariableResolver resolver = VariableResolverFactory.getResolver(path, manager);
+            resolvedPath = resolver.resolve(null, objectModel);
+        }
+        catch (PatternException e)
+        {
+            throw new ProcessingException(e);
+        }
+        File pathFile = new File(resolvedPath);
+        return pathFile.getCanonicalPath();
+    }
+
+}
\ No newline at end of file



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


Mime
View raw message