hlship      2004/07/24 15:18:13

  Modified:    examples/src/documentation/content/xdocs/hivemind-examples
                        index.xml
               examples/src/java/com/panorama/startup/impl
                        TaskExecutor.java Task.java
               src/documentation/content/xdocs site.xml
               examples/src/conf log4j.properties
               .        status.xml
               hivebuild project.xml
               examples build.xml
  Added:       examples/src/descriptor/META-INF examples.sdl
               examples/src/documentation/content/xdocs/hivemind-examples
                        panorama.xml calc.xml
               examples/src/java/org/apache/hivemind/examples Adder.java
                        CalculatorMain.java Divider.java Multiplier.java
                        Subtracter.java Calculator.java
               examples/src/java/org/apache/hivemind/examples/impl
                        MultiplerImpl.java AdderImpl.java
                        CalculatorImpl.java SubtracterImpl.java
                        DividerImpl.java
  Removed:     src/documentation/content/xdocs case1.xml
  Log:
  Add more examples, and examples documentation.
  
  Revision  Changes    Path
  1.1                  
jakarta-hivemind/examples/src/descriptor/META-INF/examples.sdl
  
  Index: examples.sdl
  ===================================================================
  //  Copyright 2004 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")
  {
    service-point (id=Adder interface=org.apache.hivemind.examples.Adder)
    {
      create-instance (class=org.apache.hivemind.examples.impl.AdderImpl)
      interceptor (service-id=hivemind.LoggingInterceptor)
    }
    
    service-point (id=Subtracter 
interface=org.apache.hivemind.examples.Subtracter)
    {
      create-instance (class=org.apache.hivemind.examples.impl.SubtracterImpl)
      interceptor (service-id=hivemind.LoggingInterceptor)
    }
    
    service-point (id=Multiplier 
interface=org.apache.hivemind.examples.Multiplier)
    {
      create-instance (class=org.apache.hivemind.examples.impl.MultiplerImpl)
      interceptor (service-id=hivemind.LoggingInterceptor)    
    }
    
    service-point (id=Divider interface=org.apache.hivemind.examples.Divider)
    {
      create-instance (class=org.apache.hivemind.examples.impl.DividerImpl)
      interceptor (service-id=hivemind.LoggingInterceptor)
    }
    
    service-point (id=Calculator 
interface=org.apache.hivemind.examples.Calculator)
    {
      invoke-factory (service-id=hivemind.BuilderFactory)
      {
        construct (class=org.apache.hivemind.examples.impl.CalculatorImpl)
        
        // Note: services are autowired (as long as there's exactly one
        // service-point implementing the interface).   
      }
      interceptor (service-id=hivemind.LoggingInterceptor)
    }
  }
  
  
  1.2       +56 -2     
jakarta-hivemind/examples/src/documentation/content/xdocs/hivemind-examples/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/examples/src/documentation/content/xdocs/hivemind-examples/index.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- index.xml 20 Jul 2004 17:22:53 -0000      1.1
  +++ index.xml 24 Jul 2004 22:18:13 -0000      1.2
  @@ -18,15 +18,69 @@
   <document>
   
     <header>
  -    <title>HiveMind Examples</title>
  +    <title>HiveMind Example Code</title>
        </header>
        
     <body>
   
   <p>
  -Example code demonstrating many HiveMind features.
  +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>
       
     </body>
   </document>
  
  
  
  1.1                  
jakarta-hivemind/examples/src/documentation/content/xdocs/hivemind-examples/panorama.xml
  
  Index: panorama.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2004 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 "-//APACHE//DTD Documentation V1.2//EN" 
"./dtd/document-v12.dtd"
  [
    <!ENTITY projectroot '../'>
    <!ENTITY % common-links SYSTEM "../links.ent">
    %common-links;
  ]>
  <document>
  
    <header>
      <title>Panorama Startup</title>
    </header>
    
    <body>
  <p>
  Panorama is a disguised version of
  <link href="http://www.webct.com/";>WebCT</link>'s <strong>Vista</strong> 
application.  Vista is
  a truly massive web application, consisting of thousands of Java classes and 
JSPs and hundreds of EJBs. Vista is
  organized as a large number of somewhat inter-related <em>tools</em> with an 
underlying substrate of <em>services</em>.
  In fact, HiveMind was originally created to manage the complexity of Vista.
  </p>   
  
  <note>
  The reality is that Vista, a commercial project, has continued with an older 
version of HiveMind. Panorama
  is based on original code in Vista, but has been altered to take advantage of 
many features available
  in more recent versions of HiveMind. Keeping the names seperate keeps us 
honest about the differences between a
  product actually in production (Vista) versus an idealized version used for 
demonstration and tutorial purposes (Panorama).
  </note> 
  
  <p>
  With all these interrelated tools and services, the simple act of starting up 
the application was complex.  Many
  tools and services have <em>startup operations</em>, things that need to 
occur when the application first starts
  up within the application server. For example, the help service reads and 
caches help text stored within the database.
  The mail service creates periodic jobs to peform database garbage collection 
of deleted mail items.  All told, Vista had
  over 40 different tasks to perform at startup ... many with subtle 
dependencies (such as the mail tool
  needing the job scheduler service to be up and running).
  </p>
  
  <p>
  The <em>legacy</em>   version of Vista startup consisted of a WebLogic 
startup class that invoked an 
  central stateless session EJB. The startup EJB was responsible for performing 
all 40+  startup tasks ... typically
  by invoking a public static method of a class related to the tool.
  </p>
  
  <p>
  This was problematic for several reasons. It created a dependency on WebLogic 
to manage startup (really, a minor consideration,
  but one nonetheless). More importantly, it created an unneccessary binding 
between the startup EJB and all the other code
  in all the other tools. These unwanted dependencies created ripple effects 
throught the code base that impacted
  refactored efforts, and caused deployment problems that complicated the build 
(requiring the duplication of
  many common classes inside the startup EJB's JAR, to resolve runtime 
classloader dependencies).
  </p>
  
  <note>
  It's all about class loaders. The class loader that loaded the startup EJB 
didn't have visibliity to the contents
  of the other EJB JARs deployed within the Vista EAR. To satisfy WebLogic's 
ejbc command (EJB JAR packaging tool),
  and to succesfully locate the classes at runtime, it was necessary duplicate 
many classes from the other EJB JARs into the startup EJB JAR.
  With HiveMind, this issue goes away, since the module deployment descriptors 
store the class <em>name</em>, and the
  <em>servlet thread's context class loader</em> is used to resolve that name 
... and <em>it</em> has visibility
  to all the classes in all the EJB JARs.
  </note>
  
  <section>
    <title>Enter HiveMind</title>
    
  <p>
  HiveMind's ultimate purpose was to simplify all aspects of Vista development 
and create a simpler, faster,
  more robust development environment. The first step on this journey, a trial 
step, was to rationalize the startup process.
  </p>  
  
  <p>
  Each startup task would be given a unique id, a title and a set of 
<em>depencies</em> (on other tasks). How
  the task actually operated was left quite abstract ... with careful support 
for supporting the existing legacy approach
  (public static methods). What would change would be how these tasks were 
executed, 
  </p>
  
  <p>
  The advantage of HiveMind is that each <em>module</em> can contribute as many 
or as few startup tasks
  as necessary into the Startup configuration point as needed. This allows the 
startup logic to be
  properly <em>enapsulated</em> in the module. The startup logic can be easily 
changed without affecting
  other modules, and without having to change any single contentious resource 
(such as the legacy approach's
  startup EJB).
  </p>
  
  </section>
  
  <section>
    <title>Startup task schema</title>
  
  <p>
  The schema for startup tasks contributions must support the explicit ordering 
of execution based on dependencies.
  With HiveMind, there's no telling in what order modules will be processed, 
and so no telling in what order
  contributions will appear within a configuration point ... so it is necessary 
to make ordering explicit
  by giving each task a unique id, and listing dependencies (the ids of tasks 
that must precede, or must
  follow, any single task).
  </p>
  
  <p>
  Special consideration was given to supporting legacy startup code in the 
tools and services; code that stays
  in the form of a public static method.  As HiveMind is adopted, these static 
methods will go away, and be replaced
  with either HiveMind services, or simple objects.
  </p>
    
  <p>
  The schema definition (with desriptions removed, for compactness) follows:
  </p>  
  
  <source><![CDATA[    schema (id=Tasks)
    {
      element (name=task)
      {
        attribute (name=title required=true)
        attribute (name=id required=true)
        attribute (name=before)
        attribute (name=after)      
        attribute (name=executable required=true translator=object)
        
        conversion (class=com.panorama.startup.impl.Task)
      }
      
      element (name=static-task)
      {
        attribute (name=title required=true)
        attribute (name=id required=true)
        attribute (name=before)
        attribute (name=after)           
        attribute (name=class translator=class required=true)
        attribute (name=method)
        
        rules
        {
          create-object (class=com.panorama.startup.impl.Task)
          invoke-parent (method=addElement)
          
          read-attribute (attribute=id property=id)
          read-attribute (attribute=title property=title)
          read-attribute (attribute=before property=before)
          read-attribute (attribute=after property=after)
          
          create-object (class=com.panorama.startup.impl.ExecuteStatic)
          invoke-parent (method=setExecutable)
          
          read-attribute (attribute=class property=targetClass)
          read-attribute (attribute=method property=methodName)       
        }
      }
    }
  
  ]]></source>
  
  <note>
  For more details, see <link 
href="hivedocs/schema/panorama.startup.Tasks.html">the HiveDoc for
    the Tasks schema</link>.
  </note>
  
  <p>
  This schema supports contributions in two formats.  The first format allows 
an arbitrary object or 
  service to be contributed:
  </p>
  
  <source><![CDATA[
    task (id=mail title=Mail executable=service:MailStartup)
  ]]></source>
  
  <p>
  The <code>executable</code> attribute is converted into an object or service; 
here the <code>service:</code>
  prefix indicates that the rest of the string, <code>MailStartup</code>, is a 
service id
  (other prefixes are defined by the &hivemind.ObjectProviders; configuration). 
If this task
  has dependencies, the <code>before</code> and <code>after</code> attributes 
can be specified as well.
  </p>
  
  <p>
  To support legacy code, a second option, <code>static-task</code>, is 
provided:
  </p>
  <source><![CDATA[  contribution (configuration-id=panorama.startup.Startup)
    {
      static-task (id=discussions title=Discussions after=mail 
class=com.panorama.discussions.DiscussionsStartup)
    }
  ]]></source>
  
  <p>
  The <code>static-task</code> element duplicates the <code>id</code>, 
<code>title</code>,
  <code>before</code> and <code>after</code> attributes, but replaces 
<code>executable</code>
  with <code>class</code> (the name of the class containing the method) and
  <code>method</code> (the name of the method to invoke, defaulting to "init").
  </p>
  </section>
  
  
  <section>
    <title>Startup Service</title>
  
  <p>
    The schema just defines what contributions <em>look like</em> and how they 
are converted
    to objects; we need to define a Startup configuration point using the 
schema, and
    a Startup service that uses the configuration point.
  </p>  
  
  <source><![CDATA[  configuration-point (id=Startup schema-id=Tasks)
      
    service-point (id=Startup interface=java.lang.Runnable)
    {
      invoke-factory (service-id=hivemind.BuilderFactory)
      {
        construct (class=com.panorama.startup.impl.TaskExecutor)
        {
          set-configuration (property=tasks configuration-id=Startup)
        }
      }
    }
    
    contribution (configuration-id=hivemind.Startup)
    {
      service (service-id=Startup)
    }]]></source>
    
  
  
  <p>
  The <code>hivemind.Startup</code> configuration point is used to ensure that 
the Panorama Startup service is
  executed when the Registry itself is constructed.
  </p>
  
  </section>
  
  <section>
    <title>Implementation</title>
    
  <p>
  All that remains is the implementations of the service and task classes.
  </p>  
  
  <section>
    <title>Executable.java</title>
  
  <source><![CDATA[package com.panorama.startup;
  
  /**
   * Much like [EMAIL PROTECTED] 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>
  
  <p>
  The Executable interface is implemented by tasks, and by services or other 
objects that need to
  be executed.  It <code>throws Exception</code> so that exception catching and 
reporting can be
  centralized inside the Startup service.
  </p>
  
  
  </section>
  
  <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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] #setExecutable(Executable) 
executable} object.
       */
      public void execute() throws Exception
      {
          _executable.execute();
      }
  
  }
  ]]></source>  
  
  <p>
  The Task class is a wrapper around an Executable object; whether that's a 
service, some arbitrary object,
  or a StaticTask.
  </p>
  
  </section>
  
  <section>
    <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>
  
  <p>
  ExecuteStatic uses Java reflection to invoke a public static method of a 
particular class.
  </p>
  
  </section>
  
  <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.ErrorHandler;
  import org.apache.hivemind.Messages;
  import org.apache.hivemind.order.Orderer;
  
  /**
   * A service that executes a series of [EMAIL PROTECTED] 
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 ErrorHandler _errorHandler;
      private Log _log;
      private List _tasks;
      private Messages _messages;
  
      /**
       * Orders the [EMAIL PROTECTED] #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()
      {
          Orderer orderer = new Orderer(_log, _errorHandler, 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;
          long startTime = System.currentTimeMillis();
  
          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)
          {
              _errorHandler.error(_log, 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 setErrorHandler(ErrorHandler handler)
      {
          _errorHandler = handler;
      }
  
      public void setLog(Log log)
      {
          _log = log;
      }
  
      public void setMessages(Messages messages)
      {
          _messages = messages;
      }
  
      public void setTasks(List list)
      {
          _tasks = list;
      }
  
  }]]></source>
    
  <p>
  This class is where it all comes together; it is the core service 
implementation for the
  <code>panorama.startup.Startup</code>  service.  It is constructed by the 
&hivemind.BuilderFactory;, which
  autowires the <code>errorHandler</code>, <code>log</code> and 
<code>messages</code> properties, as
  well as the <code>tasks</code> property (which is explicitly set in the 
module deployment descriptor).
  </p>  
  
  
  <p>
    Most of the <code>run()</code> method is concerned with ordering the 
contributed tasks into
    execution order and reporting the results. 
  </p>
    
  </section>
  
  </section>
  
  <section>
    <title>Unit Testing</title>
    
  <p>
  Unit testing in HiveMind is accomplished by <em>acting like the 
container</em>; that is, your code
  is responsible for instantiating the core service implementation and setting 
its properties.  In many cases,
  you will set the properties to mock objects ... HiveMind uses
  <link href="http://www.easymock.org/";>EasyMock</link> extensively, and
  provides a base class, <code>HiveMindTestCase</code>, that contains much 
support for creating of Mock controls
  and objects.
  </p>
  
  <section>
    <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.ErrorHandler;
  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 [EMAIL PROTECTED] 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();
  
          ErrorHandler errorHandler = (ErrorHandler) 
newMock(ErrorHandler.class);
  
          e.setErrorHandler(errorHandler);
          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>  
   
  <p>
  In this listing (which is a paired down version of the real class), you can 
see how 
  mock objects, including EasyMock objects, are used. The ExecutableFixture 
classes will invoke
  the <code>addToken()</code> method; the point is to provide, in the tasks 
List,
  those fixtures wrapped in Task objects and see that they are invoked in the 
correct order.
  </p>
  
  <p>
  We create a Mock Log object, and check that the correct messages are logged 
int the correct order.  Once
  we have set the expectations for all the EasyMock controls, we invoke 
<code>replayControls()</code> and
  continue with our test.  The <code>verifyControls()</code> method ensures 
that all mock objects
  have had all expected methods invoked on them.
  </p>
  
  <p>
  That's just <em>unit</em> testing; you always want to supplement that with 
<em>integration</em>
  testing ... to ensure, at the very least, that your schema is valid, the 
conversion rules work, and the contributions
  are correct.  However, as the <link 
href="clover/com/panorama/startup/impl/pkg-summary.html">code coverage 
report</link>
    shows, you can reach very high levels of code coverage (and code 
<em>confidence</em>) using unit tests.
  </p>
    
    
  </section>
  
  
    </body>
  </document>
  
  
  
  1.1                  
jakarta-hivemind/examples/src/documentation/content/xdocs/hivemind-examples/calc.xml
  
  Index: calc.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2004 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 "-//APACHE//DTD Documentation V1.2//EN" 
"./dtd/document-v12.dtd"
  [
        <!ENTITY projectroot '../'>
        <!ENTITY % common-links SYSTEM "../links.ent">
        %common-links;
  ]>
  <document>
  
    <header>
      <title>Calculator</title>
        </header>
        
    <body>
  
  <p>
  The calculator example demonstates the most basic concepts of HiveMind; the 
difference
  between &create-instance; and &invoke-factory;, the the fact that services 
are, by default, created only as needed,
  and the ability of &hivemind.BuilderFactory; to automatically wire services 
together. It also demonstrates the behavior of the
  &hivemind.LoggingInterceptor;.
  </p>
  
  <p>
  After compiling the examples, you can use Ant to run examples:
  </p>
  
  <source><![CDATA[bash-2.05b$ ant run-calculator
  Buildfile: build.xml
  
  run-calculator:
       [java] Calculator [DEBUG] Creating SingletonProxy for service 
examples.Calculator
       [java] Inputs:   28.0 and 4.75
       [java] Calculator [DEBUG] Constructing core service implementation for 
service examples.Calculator
       [java] Subtracter [DEBUG] Creating SingletonProxy for service 
examples.Subtracter
       [java] Calculator [DEBUG] Autowired service property subtracter to 
<SingletonProxy for 
examples.Subtracter(org.apache.hivemind.examples.Subtracter)>
       [java] Divider [DEBUG] Creating SingletonProxy for service 
examples.Divider
       [java] Calculator [DEBUG] Autowired service property divider to 
<SingletonProxy for examples.Divider(org.apache.hivemind.examples.Divider)>
       [java] Multiplier [DEBUG] Creating SingletonProxy for service 
examples.Multiplier
       [java] Calculator [DEBUG] Autowired service property multiplier to 
<SingletonProxy for 
examples.Multiplier(org.apache.hivemind.examples.Multiplier)>
       [java] Adder [DEBUG] Creating SingletonProxy for service examples.Adder
       [java] Calculator [DEBUG] Autowired service property adder to 
<SingletonProxy for examples.Adder(org.apache.hivemind.examples.Adder)>
       [java] Calculator [DEBUG] Applying interceptor factory 
hivemind.LoggingInterceptor
       [java] Calculator [DEBUG] BEGIN add(28.0, 4.75)
       [java] Adder [DEBUG] Constructing core service implementation for 
service examples.Adder
       [java] Adder [DEBUG] Applying interceptor factory 
hivemind.LoggingInterceptor
       [java] Adder [DEBUG] BEGIN add(28.0, 4.75)
       [java] Adder [DEBUG] END add() [32.75]
       [java] Calculator [DEBUG] END add() [32.75]
       [java] Add:      32.75
       [java] Calculator [DEBUG] BEGIN subtract(28.0, 4.75)
       [java] Subtracter [DEBUG] Constructing core service implementation for 
service examples.Subtracter
       [java] Subtracter [DEBUG] Applying interceptor factory 
hivemind.LoggingInterceptor
       [java] Subtracter [DEBUG] BEGIN subtract(28.0, 4.75)
       [java] Subtracter [DEBUG] END subtract() [23.25]
       [java] Calculator [DEBUG] END subtract() [23.25]
       [java] Subtract: 23.25
       [java] Calculator [DEBUG] BEGIN multiply(28.0, 4.75)
       [java] Multiplier [DEBUG] Constructing core service implementation for 
service examples.Multiplier
       [java] Multiplier [DEBUG] Applying interceptor factory 
hivemind.LoggingInterceptor
       [java] Multiplier [DEBUG] BEGIN multiply(28.0, 4.75)
       [java] Multiplier [DEBUG] END multiply() [133.0]
       [java] Calculator [DEBUG] END multiply() [133.0]
       [java] Multiply: 133.0
       [java] Calculator [DEBUG] BEGIN divide(28.0, 4.75)
       [java] Divider [DEBUG] Constructing core service implementation for 
service examples.Divider
       [java] Divider [DEBUG] Applying interceptor factory 
hivemind.LoggingInterceptor
       [java] Divider [DEBUG] BEGIN divide(28.0, 4.75)
       [java] Divider [DEBUG] END divide() [5.894736842105263]
       [java] Calculator [DEBUG] END divide() [5.894736842105263]
       [java] Divide:   5.894736842105263
  
  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[module (id=examples version="1.0.0")
  {
    service-point (id=Adder interface=org.apache.hivemind.examples.Adder)
    {
      create-instance (class=org.apache.hivemind.examples.impl.AdderImpl)
      interceptor (service-id=hivemind.LoggingInterceptor)
    }
    
    service-point (id=Subtracter 
interface=org.apache.hivemind.examples.Subtracter)
    {
      create-instance (class=org.apache.hivemind.examples.impl.SubtracterImpl)
      interceptor (service-id=hivemind.LoggingInterceptor)
    }
    
    service-point (id=Multiplier 
interface=org.apache.hivemind.examples.Multiplier)
    {
      create-instance (class=org.apache.hivemind.examples.impl.MultiplerImpl)
      interceptor (service-id=hivemind.LoggingInterceptor)    
    }
    
    service-point (id=Divider interface=org.apache.hivemind.examples.Divider)
    {
      create-instance (class=org.apache.hivemind.examples.impl.DividerImpl)
      interceptor (service-id=hivemind.LoggingInterceptor)
    }
    
    service-point (id=Calculator 
interface=org.apache.hivemind.examples.Calculator)
    {
      invoke-factory (service-id=hivemind.BuilderFactory)
      {
        construct (class=org.apache.hivemind.examples.impl.CalculatorImpl)
        
        // Note: services are autowired (as long as there's exactly one
        // service-point implementing the interface).   
      }
      interceptor (service-id=hivemind.LoggingInterceptor)
    }
  }]]></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>    
  
    </body>
  </document>
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/Adder.java
  
  Index: Adder.java
  ===================================================================
  //  Copyright 2004 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.examples;
  
  /**
   * A service that adds two numbers together.
   *
   * @author Howard Lewis Ship
   */
  public interface Adder
  {
        public double add(double arg0, double arg1);
  }
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/CalculatorMain.java
  
  Index: CalculatorMain.java
  ===================================================================
  //  Copyright 2004 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.examples;
  
  import java.util.Locale;
  
  import org.apache.hivemind.ClassResolver;
  import org.apache.hivemind.Registry;
  import org.apache.hivemind.impl.DefaultClassResolver;
  import org.apache.hivemind.impl.RegistryBuilder;
  import org.apache.hivemind.util.FileResource;
  
  public class CalculatorMain
  {
      public static void main(String[] args)
      {
          double arg0 = Double.parseDouble(args[0]);
          double arg1 = Double.parseDouble(args[1]);
  
          Registry registry = buildRegistry();
          
          // Since we know there's exactly *one* service-point implementing 
Calculator,
          // we can get it this way, and never have to know its service id.
          
          Calculator calculator = (Calculator) 
registry.getService(Calculator.class);
          
          System.out.println("Inputs:   " + arg0 + " and " + arg1);
          System.out.println("Add:      " + calculator.add(arg0, arg1));
          System.out.println("Subtract: " + calculator.subtract(arg0, arg1));
          System.out.println("Multiply: " + calculator.multiply(arg0, arg1));
          System.out.println("Divide:   " + calculator.divide(arg0, arg1));
      }
  
      private static Registry buildRegistry()
      {
          // The examples package is structured oddly (so that it doesn't 
interfere with
          // the main HiveMind framework tests), so we have to go through some 
gyrations
          // here that aren't necessary in an ordinary HiveMind application.
  
          String projectRoot = System.getProperty("PROJECT_ROOT");
          String path = projectRoot + 
"/examples/src/descriptor/META-INF/examples.sdl";
  
          RegistryBuilder builder = new RegistryBuilder();
          ClassResolver resolver = new DefaultClassResolver();
  
          // Process standard files, on the classpath.
  
          builder.processModules(resolver);
  
          // Process the examples.sdl file, which (given its non-standard name) 
          // is not visible.
  
          builder.processModule(resolver, new FileResource(path));
  
          return builder.constructRegistry(Locale.getDefault());
      }
  }
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/Divider.java
  
  Index: Divider.java
  ===================================================================
  //  Copyright 2004 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.examples;
  
  /**
   * Service that divides two numbers.
   *
   * @author Howard Lewis Ship
   */
  public interface Divider
  {
      public double divide(double arg0, double arg1);
  }
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/Multiplier.java
  
  Index: Multiplier.java
  ===================================================================
  //  Copyright 2004 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.examples;
  
  /**
   * Service that multiplies two numbers together.
   *
   * @author Howard Lewis Ship
   */
  public interface Multiplier
  {
      public double multiply(double arg0, double arg1);
  }
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/Subtracter.java
  
  Index: Subtracter.java
  ===================================================================
  //  Copyright 2004 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.examples;
  
  /**
   * Service that subtracts two numbers.
   *
   * @author Howard Lewis Ship
   */
  public interface Subtracter
  {
      public double subtract(double arg0, double arg1);
  }
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/Calculator.java
  
  Index: Calculator.java
  ===================================================================
  //  Copyright 2004 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.examples;
  
  /**
   * Service that provides a number of basic math operations.
   *
   * @author Howard Lewis Ship
   */
  public interface Calculator extends Adder, Subtracter, Multiplier, Divider
  {
  
  }
  
  
  
  1.3       +4 -4      
jakarta-hivemind/examples/src/java/com/panorama/startup/impl/TaskExecutor.java
  
  Index: TaskExecutor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/examples/src/java/com/panorama/startup/impl/TaskExecutor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TaskExecutor.java 24 Jul 2004 13:51:27 -0000      1.2
  +++ TaskExecutor.java 24 Jul 2004 22:18:13 -0000      1.3
  @@ -35,10 +35,10 @@
       private List _tasks;
       private Messages _messages;
   
  -     /**
  -      * Orderes the [EMAIL PROTECTED] #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).
  -      */
  +    /**
  +     * Orders the [EMAIL PROTECTED] #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()
       {
           Orderer orderer = new Orderer(_log, _errorHandler, task());
  
  
  
  1.3       +1 -1      
jakarta-hivemind/examples/src/java/com/panorama/startup/impl/Task.java
  
  Index: Task.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/examples/src/java/com/panorama/startup/impl/Task.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Task.java 24 Jul 2004 13:51:27 -0000      1.2
  +++ Task.java 24 Jul 2004 22:18:13 -0000      1.3
  @@ -21,7 +21,7 @@
   /**
    * An operation that may be executed. A Task exists to wrap
    * an [EMAIL PROTECTED] com.panorama.startup.Executable} object with
  - * a title and ordering information (name, followingNames, precedingNames).
  + * a title and ordering information (id, after, before).
    *
    * @author Howard Lewis Ship
    */
  
  
  
  1.22      +3 -1      jakarta-hivemind/src/documentation/content/xdocs/site.xml
  
  Index: site.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/src/documentation/content/xdocs/site.xml,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- site.xml  20 Jul 2004 17:26:39 -0000      1.21
  +++ site.xml  24 Jul 2004 22:18:13 -0000      1.22
  @@ -50,7 +50,6 @@
                
                <tutorials label="Tutorials and Information">
                        <bootstrap label="Bootstrapping the Registry" 
href="bootstrap.html"/>
  -                     <case1 label="Case Study #1: Panorama Startup" 
href="case1.html"/>
                        <ioc label="Inversion Of Control" href="ioc.html"/>
                        <localization label="Localization" 
href="localization.html"/>
                        <multithreading label="Multi-Threading" 
href="multithreading.html"/>
  @@ -130,6 +129,9 @@
     <hivemind-examples label="Example Code" tab="hivemind-examples" 
href="hivemind-examples/">
       
         <index href="index.html"/>
  +      
  +      <examples.calc label="Calculator" href="calc.html"/>
  +      <examples.panorama label="Panorama Startup" href="panorama.html"/>
        
         <reports label="Reports">
           &hivemind-examples-report-menu.ent;
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/impl/MultiplerImpl.java
  
  Index: MultiplerImpl.java
  ===================================================================
  //  Copyright 2004 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.examples.impl;
  
  import org.apache.hivemind.examples.Multiplier;
  
  /**
   * Implementation of the [EMAIL PROTECTED] 
org.apache.hivemind.examples.Multiplier} interface.
   *
   * @author Howard Lewis Ship
   */
  public class MultiplerImpl implements Multiplier
  {
  
      public double multiply(double arg0, double arg1)
      {
          return arg0 * arg1;
      }
  
  }
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/impl/AdderImpl.java
  
  Index: AdderImpl.java
  ===================================================================
  //  Copyright 2004 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.examples.impl;
  
  import org.apache.hivemind.examples.Adder;
  
  /**
   * Implementation of the [EMAIL PROTECTED] 
org.apache.hivemind.examples.Adder} interface.
   *
   * @author Howard Lewis Ship
   */
  public class AdderImpl implements Adder
  {
  
      public double add(double arg0, double arg1)
      {
          return arg0 + arg1;
      }
  
  }
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/impl/CalculatorImpl.java
  
  Index: CalculatorImpl.java
  ===================================================================
  //  Copyright 2004 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.examples.impl;
  
  import org.apache.hivemind.examples.Adder;
  import org.apache.hivemind.examples.Calculator;
  import org.apache.hivemind.examples.Divider;
  import org.apache.hivemind.examples.Multiplier;
  import org.apache.hivemind.examples.Subtracter;
  
  /**
   * Implementation of the [EMAIL PROTECTED] 
org.apache.hivemind.examples.Calculator}
   * service interface. Acts as a facade, delegating each operation to other
   * services.  The <code>hivemind.BuilderFactory</code>
   *
   * @author Howard Lewis Ship
   */
  public class CalculatorImpl implements Calculator
  {
      private Adder _adder;
      private Subtracter _subtracter;
      private Multiplier _multiplier;
      private Divider _divider;
  
      public double add(double arg0, double arg1)
      {
          return _adder.add(arg0, arg1);
      }
  
      public double subtract(double arg0, double arg1)
      {
          return _subtracter.subtract(arg0, arg1);
      }
  
      public double multiply(double arg0, double arg1)
      {
          return _multiplier.multiply(arg0, arg1);
      }
  
      public double divide(double arg0, double arg1)
      {
          return _divider.divide(arg0, arg1);
      }
  
      public void setAdder(Adder adder)
      {
          _adder = adder;
      }
  
      public void setDivider(Divider divider)
      {
          _divider = divider;
      }
  
      public void setMultiplier(Multiplier multiplier)
      {
          _multiplier = multiplier;
      }
  
      public void setSubtracter(Subtracter subtracter)
      {
          _subtracter = subtracter;
      }
  
  }
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/impl/SubtracterImpl.java
  
  Index: SubtracterImpl.java
  ===================================================================
  //  Copyright 2004 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.examples.impl;
  
  import org.apache.hivemind.examples.Subtracter;
  
  /**
   * Implementation of the [EMAIL PROTECTED] 
org.apache.hivemind.examples.Subtracter} interface.
   *
   * @author Howard Lewis Ship
   */
  public class SubtracterImpl implements Subtracter
  {
  
      public double subtract(double arg0, double arg1)
      {
          return arg0 - arg1;
      }
  
  }
  
  
  
  1.1                  
jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/impl/DividerImpl.java
  
  Index: DividerImpl.java
  ===================================================================
  //  Copyright 2004 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.examples.impl;
  
  import org.apache.hivemind.examples.Divider;
  
  /**
   * Implementation of the [EMAIL PROTECTED] 
org.apache.hivemind.examples.Divider} interface.
   *
   * @author Howard Lewis Ship
   */
  public class DividerImpl implements Divider
  {
  
      public double divide(double arg0, double arg1)
      {
          return arg0 / arg1;
      }
  
  }
  
  
  
  1.2       +2 -0      jakarta-hivemind/examples/src/conf/log4j.properties
  
  Index: log4j.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/examples/src/conf/log4j.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- log4j.properties  20 Jul 2004 17:22:53 -0000      1.1
  +++ log4j.properties  24 Jul 2004 22:18:13 -0000      1.2
  @@ -23,5 +23,7 @@
   log4j.appender.A1.layout.ConversionPattern=%c{1} [%p] %m%n
   
   log4j.category.panorama=info
  +log4j.category.examples=debug
  +
   
   
  
  
  
  1.30      +12 -6     jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- status.xml        21 Jul 2004 13:32:20 -0000      1.29
  +++ status.xml        24 Jul 2004 22:18:13 -0000      1.30
  @@ -39,20 +39,20 @@
           Removed dependency on Werkz.
         </action>
         <action type="update" dev="HLS">
  -        Add link to the Jakarta mailing lists page.
  +        Added link to the Jakarta mailing lists page.
         </action>
         <action type="fix" dev="HLS" fixes-bug="HIVEMIND-21" due-to="Achim 
Hügen">
  -        Modify build scripts to properly include variable info when 
compiling.
  +        Modifed the build scripts to properly include variable info when 
compiling.
         </action>
         <action type="update" dev="HLS">
  -        Move the Ant build scripts to a new directory, hivebuild, in 
preparation
  +        Moved the Ant build scripts to a new directory, hivebuild, in 
preparation
           for making hivebuild reusable on new projects.
         </action>
         <action type="update" dev="HLS">
           Added protected method constructRegistry() to HiveMindFilter.
         </action>
         <action type="update" dev="HLS">
  -        Rename existing 'object' translator to 'instance', and create
  +        Renamed existing 'object' translator to 'instance', and created
           a new 'object' translator with great flexibility. Extend 
BuilderFactory
           to add a set-object element that leverages the object translator.
         </action>
  @@ -60,11 +60,11 @@
           Created service-property object translator.
         </action>
         <action type="update" dev="HLS" fixes-bug="HIVEMIND-20" due-to="Marcus 
Brito">
  -       Add a version of <code>Registry.getService()</code> that omits the 
service id
  +       Added a version of <code>Registry.getService()</code> that omits the 
service id
          (but requires that exactly one service point implements the service 
interface).
         </action>
         <action type="update" dev="HLS" fixes-bug="HIVEMIND-22">
  -        Extend the BuilderFactory to autowire services.
  +        Extended the BuilderFactory to autowire services.
         </action>
         <action type="add" dev="HLS">
           Added a new module that contains HiveMind example code.
  @@ -73,6 +73,12 @@
           Fixed some latent bugs related to submodules inside the 
constructRegistry task.
           Made some more improvements to the hivebuild scripts.
         </action> 
  +      <action type="update" dev="HLS">
  +        Updated the download location for the Forrest distribution.
  +      </action>
  +      <action type="update" dev="HLS">
  +        Added more examples and examples documentation.
  +      </action>
        
       </release>
     
  
  
  
  1.2       +2 -2      jakarta-hivemind/hivebuild/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/hivebuild/project.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.xml       11 Jul 2004 17:14:43 -0000      1.1
  +++ project.xml       24 Jul 2004 22:18:13 -0000      1.2
  @@ -63,7 +63,7 @@
                <target name="site" description="Build site documentation using 
Forrest.">
                
                        <unpacked-zip-dependency
  -                                     
url="http://www.apache.org/dist/xml/forrest/binaries";
  +                                     
url="http://www.apache.org/dist/forrest/";
                                        zip="apache-forrest-0.5.1-bin.zip"
                                        dir="${forrest-package-dir}"/>
                        
  
  
  
  1.3       +52 -49    jakarta-hivemind/examples/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/examples/build.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- build.xml 21 Jul 2004 13:32:43 -0000      1.2
  +++ build.xml 24 Jul 2004 22:18:13 -0000      1.3
  @@ -15,54 +15,57 @@
      limitations under the License.
   -->
   <project name="HiveMind Examples" default="jar">
  -
  -     <property name="module.name" value="hivemind-examples"/>
  -     <property name="javadoc.package" value="com.panorama.*"/>
  -     
  -     <property name="module.install.dir" value="target"/>
  -     
  -     <property name="root.dir" value=".."/>
  -     <import file="${root.dir}/hivebuild/jar-module.xml"/>
  -     <import file="${hivebuild.dir}/javadoc-report.xml"/>    
  -     <import file="${hivebuild.dir}/clover-report.xml"/>
  -             
  -     <!-- HiveDoc report is normally setup for project level, but we're 
using it
  +  <property name="module.name" value="hivemind-examples"/>
  +  <property name="javadoc.package" value="com.panorama.*"/>
  +  <property name="module.install.dir" value="target"/>
  +  <property name="root.dir" value=".."/>
  +  <import file="${root.dir}/hivebuild/jar-module.xml"/>
  +  <import file="${hivebuild.dir}/javadoc-report.xml"/>
  +  <import file="${hivebuild.dir}/clover-report.xml"/>
  +  <!-- HiveDoc report is normally setup for project level, but we're using it
             at the module level, so we need to tweak. -->
  -                     
  -     <path id="hivedoc.taskdef.classpath">
  -       <fileset dir="${module.lib.dir}" includes="**/*.jar"/>
  -       <pathelement location="${conf.src.dir}"/>
  -     </path>
  -     
  -     <path id="hivedoc.classpath">
  -       <path refid="hivedoc.taskdef.classpath"/>
  -       <pathelement location="${descriptor.src.dir}/META-INF/panorama.sdl"/>
  -     </path>
  -             
  -     <property name="hivedoc.output.dir" 
location="${module.docs.target.dir}/hivedocs"/>
  -     
  -     <import file="${hivebuild.dir}/hivedoc-report.xml"/>
  -                     
  -     <target name="compile">
  -             <ibiblio-dependency jar="geronimo-spec-ejb-1.0-M1.jar" 
group-id="geronimo-spec"/>
  -             <ibiblio-dependency jar="spring-full-1.0.1.jar" 
group-id="springframework"/>
  -             <ibiblio-dependency jar="commons-logging-1.0.3.jar" 
group-id="commons-logging"/>
  -             
  -             <ibiblio-dependency jar="log4j-1.2.7.jar" group-id="log4j" 
use="run"/>                          
  -             <ibiblio-dependency jar="javassist-2.6.jar" group-id="jboss" 
use="run"/>                        
  -             <ibiblio-dependency jar="oro-2.0.6.jar" group-id="oro" 
use="run"/>                      
  -             <ibiblio-dependency jar="easymock-1.1.jar" group-id="easymock" 
use="test"/>
  -             
  -             <project-dependency name="hivemind"/>
  -             
  -             <default-compile/>
  -     </target>
  -     
  -     <target name="run-reports">
  -       <javadoc-report/>
  -       <hivedoc-report doc-path-id="hivedoc.classpath" 
taskdef-path-id="hivedoc.taskdef.classpath"/>
  -       <clover-report/>
  -     </target>
  -
  -
  +  <path id="hivedoc.taskdef.classpath">
  +    <fileset dir="${module.lib.dir}" includes="**/*.jar"/>
  +    <pathelement location="${conf.src.dir}"/>
  +  </path>
  +  <path id="hivedoc.classpath">
  +    <path refid="hivedoc.taskdef.classpath"/>
  +    <fileset dir="${descriptor.src.dir}/META-INF">
  +      <include name="panorama.sdl"/>
  +      <include name="examples.sdl"/>
  +    </fileset>
  +  </path>
  +  <path id="runtime.classpath">
  +    <fileset dir="${module.lib.dir}">
  +      <include name="compile/*.jar"/>
  +      <include name="run/*.jar"/>
  +    </fileset>
  +    <pathelement location="${java.classes.dir}"/>
  +    <pathelement location="${conf.src.dir}"/>
  +  </path>
  +  <property name="hivedoc.output.dir" 
location="${module.docs.target.dir}/hivedocs"/>
  +  <import file="${hivebuild.dir}/hivedoc-report.xml"/>
  +  <target name="compile">
  +    <ibiblio-dependency jar="geronimo-spec-ejb-1.0-M1.jar" 
group-id="geronimo-spec"/>
  +    <ibiblio-dependency jar="spring-full-1.0.1.jar" 
group-id="springframework"/>
  +    <ibiblio-dependency jar="commons-logging-1.0.3.jar" 
group-id="commons-logging"/>
  +    <ibiblio-dependency jar="log4j-1.2.7.jar" group-id="log4j" use="run"/>
  +    <ibiblio-dependency jar="javassist-2.6.jar" group-id="jboss" use="run"/>
  +    <ibiblio-dependency jar="oro-2.0.6.jar" group-id="oro" use="run"/>
  +    <ibiblio-dependency jar="easymock-1.1.jar" group-id="easymock" 
use="test"/>
  +    <project-dependency name="hivemind"/>
  +    <default-compile/>
  +  </target>
  +  <target name="run-reports">
  +    <javadoc-report/>
  +    <hivedoc-report doc-path-id="hivedoc.classpath" 
taskdef-path-id="hivedoc.taskdef.classpath"/>
  +    <clover-report/>
  +  </target>
  +  <target name="run-calculator" description="Execute the calculator 
example.">
  +    <java classname="org.apache.hivemind.examples.CalculatorMain">
  +      <classpath refid="runtime.classpath"/>
  +      <sysproperty key="PROJECT_ROOT" value="${project.dir}"/>
  +      <arg line="28 4.75"/>
  +    </java>
  +  </target>
   </project>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to