hlship      2003/09/09 07:51:58

  Modified:    hivemind/xdocs case1.xml
  Log:
  Update case study #1.
  
  Revision  Changes    Path
  1.2       +51 -207   jakarta-commons-sandbox/hivemind/xdocs/case1.xml
  
  Index: case1.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/case1.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- case1.xml 8 Sep 2003 23:07:22 -0000       1.1
  +++ case1.xml 9 Sep 2003 14:51:58 -0000       1.2
  @@ -32,10 +32,11 @@
   
   <p>
   Prior to HiveMind, a single EJB was the focus of all this startup and shutdown 
activity.
  -The small WebLogic startup class would invoke the EJB, and the EJB would invoke 
static methods
  -on many other classes.  This approach had grown quite unwieldy, especially in lite 
of efforts
  +A small WebLogic startup class would invoke the EJB, and the EJB would invoke 
static methods
  +on many other classes (some of which would lookup other EJBs and invoke methods on 
them).  
  +This approach had grown quite unwieldy, especially in light of efforts
   to improve and modularize the Vista build process.   HiveMind was brought in to 
rationalize
  -this aspect of Vista, with the goal being to make the fewest possible number of 
changes
  +this aspect of Vista, with the goal being to make the fewest possible changes
   to existing code.
   </p>
   
  @@ -70,82 +71,10 @@
   Java classes corresponding to task contributions.
   </p> 
        
  -<source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
  +<source><![CDATA[<?xml version="1.0"?>
   <module id="vista.framework.initshut" version="1.0.0">
        <description>Module for startup and shutdown code within Vista.</description>
        
  -     <extension-point id="Bootstrap">
  -             <description>Bootstrap elements are simple Runnable objects. The
  -                     contributed elements will each be executed in turn. The order 
of
  -                     execution is not defined.</description>
  -             <schema id="run-schema">
  -                     <element name="run">
  -                             <description>Contributes a Runnable object or 
service.</description>
  -                             <attribute name="runnable">
  -                                     <description>The name of a class implementing 
Runnable.</description>
  -                             </attribute>
  -                             <attribute name="service-id">
  -                                     <description>The id of a service implementing 
Runnable.</description>
  -                             </attribute>
  -                             <rules>
  -                                     <create-object
  -                                             
class="com.webct.platform.framework.initshut.service.RunnableWrapper"
  -                                             />
  -                                     <read-attribute attribute="runnable" 
property="runnable"
  -                                             translator="class"/>
  -                                     <read-attribute attribute="service-id" 
property="runnable"
  -                                             translator="service"/>
  -                                     <invoke-parent method="addElement"/>
  -                             </rules>
  -                     </element>
  -             </schema>
  -     </extension-point>
  -     
  -     <extension point-id="Bootstrap">
  -             <run service-id="Startup"/>
  -     </extension>
  -     
  -     <service id="Bootstrap" interface="java.lang.Runnable">
  -             <description>The Boostrap service reads the Bootstrap configuration and
  -                     executes each element.</description>
  -             <invoke-factory service-id="hivemind.BuilderFactory">
  -                     <construct
  -                             
class="com.webct.platform.framework.initshut.service.BootstrapImpl"
  -                             log-property="log"
  -                             messages-property="messages"
  -                             >
  -                             <set-extension-point property="runnables" 
point-id="Bootstrap"/>
  -                     </construct>
  -             </invoke-factory>
  -             <interceptor service-id="hivemind.LoggingInterceptor"/>
  -     </service>
  -     
  -     <extension-point id="Teardown">
  -             <description>Similar to the Bootstrap, except it occurs when the
  -                     application is being shutdown.</description>
  -             <schema ref-id="run-schema"/>
  -     </extension-point>
  -     
  -     <extension point-id="Teardown">
  -             <run service-id="Shutdown"/>
  -     </extension>
  -     
  -     <service id="Teardown" interface="java.lang.Runnable">
  -             <description>The Teardown service reads the Teardown configuration and
  -                     executes each element.</description>
  -             <invoke-factory service-id="hivemind.BuilderFactory">
  -                     <construct
  -                             
class="com.webct.platform.framework.initshut.service.BootstrapImpl"
  -                             log-property="log"
  -                             messages-property="messages"
  -                             >
  -                             <set property="failureKey" value="teardown-failure"/>
  -                             <set-extension-point property="runnables" 
point-id="Teardown"/>
  -                     </construct>
  -             </invoke-factory>
  -             <interceptor service-id="hivemind.LoggingInterceptor"/>
  -     </service>
  -     
        <extension-point id="Startup">
                <description>Defines startup tasks.</description>
                <schema id="task-schema">
  @@ -205,7 +134,7 @@
        </extension-point>
        
        <extension-point id="Shutdown">
  -             <description>Defines startup tasks.</description>
  +             <description>Defines shutdown tasks.</description>
                <schema ref-id="task-schema"/>
        </extension-point>
        
  @@ -214,14 +143,12 @@
                        
class="com.webct.platform.framework.initshut.ejb.PythonStartup"/>
        </extension>
        
  -     <extension point-id="Shutdown">
  -             
  +     <extension point-id="Shutdown">         
                <task title="Update Status" order="100">
                        <invoke-static
                                
class="com.webct.platform.framework.initshut.ejb.VistaStatus"
                                method="shutdown"/>
                </task>
  -
        </extension>
        
        <service id="Startup" interface="java.lang.Runnable">
  @@ -229,8 +156,7 @@
                        <construct
                                
class="com.webct.platform.framework.initshut.service.TaskExecutor"
                                log-property="log"
  -                             messages-property="messages"
  -                             >
  +                             messages-property="messages">
                                <set-extension-point property="tasks" 
point-id="Startup"/>
                                <set property="kind" value="%startup"/>
                        </construct>
  @@ -243,8 +169,7 @@
                        <construct
                                
class="com.webct.platform.framework.initshut.service.TaskExecutor"
                                log-property="log"
  -                             messages-property="messages"    
  -                             >
  +                             messages-property="messages">
                                <set-extension-point property="tasks" 
point-id="Shutdown"/>
                                <set property="kind" value="%shutdown"/>
                        </construct>
  @@ -255,121 +180,23 @@
   </module>]]></source>
   
   <p>
  -HiveMind does not require that the module id match a package name; in this case,
  +Notes:
  +<ul>
  +<li>HiveMind does not require that the module id match a package name; in this case,
   the module id ("vista.framework.initshut") is shorter and simpler than the
  -principal package ("com.webct.platform.framework.initshut"). 
  -</p>
  -
  -<subsection name="Bootstrap extension point">
  -
  -<p>
  -At runtime, the servlet will construct the registry and use the Bootstrap extension 
point
  -to kick off the startup process.  The parameter schema for the Bootstrap extension 
point
  -allows for contributions that identify runnable objects; objects that 
  -implement the interface <code>java.lang.Runnable</code>.
  +principal package ("com.webct.platform.framework.initshut"). </li>   
  +<li>
  +We use the <code>ref-id</code>        attribute of &schema; to avoid unwanted 
duplication.
  +</li>
  +<li>
  +Extension points, extensions and services can be specified in any order.     
  +</li>
  +<li>
  +We use the simplest possible interface for the services: 
<code>java.lang.Runnable</code>.    
  +</li>
  +</ul>        
   </p>
   
  -<p>
  -The schema allows for contributions of the form:
  -<code>
  -&lt;run runnable="..."/&gt;
  -</code>      
  -or
  -<code>
  -&lt;run service-id="..."/&gt;
  -</code>.
  -</p>
  -
  -<p>
  -The first form allows an arbitrary Java object, implementing the interface, to be
  -specified; the second allows a HiveMind service (also implementing the interface)
  -to be specified.     
  -</p>
  -
  -<p>
  -The only contribution is the Startup service itself.
  -</p>
  -
  -     
  -</subsection>
  -
  -<subsection name="Bootstrap service">
  -
  -<p>
  -The Bootstrap service uses the Boostrap extension point elements to, indirectly,
  -activate the Startup service.  In theory, other kinds of startup tasks could also
  -be activated via the Bootstrap service.
  -
  -<source><![CDATA[
  -package com.webct.platform.framework.initshut.service;
  -
  -import java.util.List;
  -
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.hivemind.Messages;
  -
  -/**
  - * Bootstraps the startup process by executing all the
  - * Runnable objects contributed to the 
<code>vista.framework.initshut.Bootstrap</code>
  - * configuration.  Can also be configured for the
  - * <code>vista.framework.initshut.Teardown</code> configuration.
  - */
  -public class BootstrapImpl implements Runnable
  -{
  -    private Log _log;
  -    private Messages _messages;
  -    private List _runnables;
  -    private String _failureKey = "bootstrap-failure";
  -
  -    public void run()
  -    {
  -        int count = _runnables.size();
  -
  -        for (int i = 0; i < count; i++)
  -        {
  -            Runnable r = (Runnable)_runnables.get(i);
  -
  -            run(r);
  -        }
  -    }
  -
  -    private void run(Runnable r)
  -    {
  -        try
  -        {
  -            r.run();
  -        }
  -        catch (Exception ex)
  -        {
  -            _log.error(_messages.format(_failureKey, r, ex.getMessage()), ex);
  -        }
  -    }
  -
  -    public void setFailureKey(String string)
  -    {
  -        _failureKey = string;
  -    }
  -
  -    public void setLog(Log log)
  -    {
  -        _log = log;
  -    }
  -
  -    public void setMessages(Messages messages)
  -    {
  -        _messages = messages;
  -    }
  -
  -    public void setRunnables(List list)
  -    {
  -        _runnables = list;
  -    }
  -
  -}    ]]>
  -</source>    
  -</p>
  -     
  -</subsection>
   
   <subsection name="Startup extension point">
   
  @@ -415,6 +242,15 @@
   }
   </source>
   </p>
  +
  +<p>
  +Shortly, we'll see how the servlet invokes the Startup service.      
  +</p>
  +
  +<p>
  +The Shutdown extension point and service are effectively clones of the Startup 
extension point and schema.
  +</p>
  +
   </subsection>
   
   <subsection name="Task class">
  @@ -506,7 +342,8 @@
   import org.apache.commons.logging.Log;
   
   /**
  - * Implementation for the <code>vista.runtime.Startup</code> service.
  + * Implementation for the <code>vista.framework.initshut.Startup</code> 
  + * and <code>Shutdown</code> services.
    * Reads the corresponding configuration, sorts the elements,
    * and executes each. 
    */
  @@ -619,7 +456,6 @@
   </p>
   
   <source>
  -
   package com.webct.platform.framework.initshut.service;
   
   import java.lang.reflect.InvocationTargetException;
  @@ -700,6 +536,14 @@
   
   }
   </source>
  +
  +<p>
  +The class implements
  +<a href="apidocs/org/apache/commons/hivemind/Locatable.html">Locatable</a>, which 
is used
  +in method <code>isNull()</code> when reporting errors; the location will be the 
location
  +of the &lt;invoke-static&gt; element the StaticTask instance was created from.
  +</p>
  +
   </subsection>
   
   </section>
  @@ -780,23 +624,23 @@
   
                HiveMind.setDefault(registry);
   
  -             Runnable bootstrap =
  -                 
(Runnable)registry.getService("vista.framework.initshut.Bootstrap", Runnable.class);
  +             Runnable startup =
  +                 (Runnable)registry.getService("vista.framework.initshut.Startup", 
Runnable.class);
   
  -             LOG.info("*** Executing vista.framework.initshut.Bootstrap service 
***");
  +             LOG.info("*** Executing vista.framework.initshut.Startup service ***");
   
  -             bootstrap.run();
  +             startup.run();
            }
            catch (Exception ex)
            {
                LOG.error(
  -                 "Unable to execute vista.framework.initshut.Bootstrap service: " + 
ex.getMessage());
  +                 "Unable to execute vista.framework.initshut.Startup service: " + 
ex.getMessage());
            }
        }
   ]]></source>
        
   <p>
  -After building the registry, the servlet uses the Boostrap service to indirectly
  +After building the registry, the servlet uses the Startup service to indirectly
   execute all the startup tasks; the idea of the extra layer is to insulate the
   servlet from any potential changes to the Startup service. The servlet calls the 
Boostrap service,
   and the Bootstrap service calls the Startup service.
  @@ -885,7 +729,7 @@
        * Called by J2EE Container shutdown calss for Vista shutdown processing.
        * 
        * <p>
  -     * Gets the <code>vista.framework.initshut.Teardown</code> service and executes 
it.
  +     * Gets the <code>vista.framework.initshut.Shutdown</code> service and executes 
it.
        * 
        */
       
  @@ -901,7 +745,7 @@
           }
   
           Runnable r =
  -            (Runnable)registry.getService("vista.framework.initshut.Teardown", 
Runnable.class);
  +            (Runnable)registry.getService("vista.framework.initshut.Shutdown", 
Runnable.class);
   
           r.run();
   
  
  
  

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

Reply via email to