mpoeschl    02/03/15 03:55:59

  Modified:    xdocs    project.xml
  Added:       xdocs    components-howto.xml
  Removed:     notes    ComponentLoader.txt
  Log:
  add a little Componets howto (incl. the ComponentLoader notes)
  as this stuff is used by turbine 2.2b1 it should be documented
  
  Revision  Changes    Path
  1.7       +4 -0      jakarta-turbine-stratum/xdocs/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/xdocs/project.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- project.xml       22 Feb 2002 12:25:37 -0000      1.6
  +++ project.xml       15 Mar 2002 11:55:59 -0000      1.7
  @@ -10,6 +10,10 @@
         <item name="Building"             href="/building.html"/>
       </menu>
   
  +    <menu name="Documentation">
  +      <item name="Components"           href="/components-howto.html"/>
  +    </menu>
  +
       <menu name="JCS Documentation">
         <item name="Overview"             href="/JavaCachingSystem.html"/>
         <item name="JCS and JCACHE"       href="/JCSandJCACHE.html"/>
  
  
  
  1.1                  jakarta-turbine-stratum/xdocs/components-howto.xml
  
  Index: components-howto.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
   <properties>
    <title>Components Howto</title>
    <author email="[EMAIL PROTECTED]">Martin Poeschl</author>
   </properties>
  
  <body>
  
  <section name="Components Howto">
  
  <p>
  <b>
  NOTE: This stuff is in its infancy and will more than likely change. Read the
  <a href="#Notes">Notes</a> for more information about future plans!
  </b>
  </p>
  
  <p>
  This document describes how components (like Torque and Fulcrum) are used with
  Turbine. It also descibes how to write new Components and how to use existing
  Components in your project.
  </p>
  
  </section>
  
  <section name="Components">
  
  <p>
  Components are Classes implementing the lifecycle interfaces
  (org.apache.stratum.lifecycle). In the current version Components must implement
  the Configurable and Initializable interfaces. (<b>NOTE: this may change in
  future versions!</b>)
  </p>
  
  <p>
  Here's the code used to make Fulcrum's BaseServiceBroker a Component:
  </p>
  
  <source><![CDATA[
  package org.apache.fulcrum;
  
  import org.apache.stratum.lifecycle.Configurable;
  import org.apache.stratum.lifecycle.Initializable;
  import org.apache.stratum.configuration.Configuration;
  
  /**
   * A implementation of a <code>ServiceBroker</code> which implements the
   * lifecycle interfaces.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Poeschl</a>
   * @version $Id: components-howto.xml,v 1.1 2002/03/15 11:55:59 mpoeschl Exp $
   */
  public class Fulcrum extends BaseServiceBroker
          implements Configurable, Initializable
  {
      /**
       * initialize fulcrum
       */
      public void initialize() throws Exception
      {
          super.init();
      }
  
      /**
       * configure fulcrum
       */
      public void configure(Configuration configuration)
      {
          super.setConfiguration(configuration);
      }
  }
  
  ]]></source>
  </section>
  
  <section name="ComponentLoader">
  <p>
  The ComponentLoader loads components and initializes them by calling their
  lifecycle methods.
  </p>
  
  <p>
  Here's how Turbine 2.2 uses the ComponentLoader during the initialization:
  </p>
  
  <source><![CDATA[
  // Initialize components like torque and fulcrum
  ComponentLoader loader = new ComponentLoader(
          TurbineResources.getConfiguration());
  loader.load();
  
  ]]></source>
  
  <p>
  Configuration:
  </p>
  
  <source><![CDATA[
  # -------------------------------------------------------------------
  #
  #  C O M P O N E N T S
  #
  # -------------------------------------------------------------------
  # Components implementing the lifecycle interfaces can be loaded,
  # configured and initialized by Turbine
  # -------------------------------------------------------------------
  
  component.name = torque
  component.torque.classname = org.apache.torque.Torque
  component.torque.config = ${webappRoot}/WEB-INF/conf/Torque.properties
  
  component.name = fulcrum
  component.fulcrum.classname = org.apache.fulcrum.Fulcrum
  component.fulcrum.config = ${webappRoot}/WEB-INF/conf/Fulcrum.properties
  
  ]]></source>
  
  </section>
  
  <section name="Notes">
  
  <p>
  <pre>
  The ComponentLoader is used by Turbine and Fulcrum and Torque.  It's
  job is to load components (some of which might also be services) and
  call their lifecycle methods.
  
  One goal for the ComponentLoader is to enable someone to extend any
  arbitrary class, implement the lifecycle interfaces, and use it as a
  component in the Turbine family.
  
  This trick will be useful for migrating some of Fulcrum's services
  into components.  It may also enable turbine users to migrate their
  Turbine 2.1 services to components.
  
  At the moment, the component loader is only used by Turbine to load
  Torque and Fulcrum.  The components are assumed to be self-sustaining,
  and assumed to provide some static methods for interfacing with the
  components.  The ComponentLoader does not currently store any
  references to components once they have been loaded.
  
  FIXME: Still need a better definition to distinguish a service from a
         component, including examples to illustrate the differences.
  
  Components vs. Services Services are a kind of component.  Many of
  them seem to revolve around interactive network interfaces.  Some
  examples include xmlrpc and ftp.  Some items are too fundamental to
  any application to be either components or services.  Examples include
  pooling, caching, database access, security.  These examples are
  currently services but should be changed to components: upload
  service, ??.
  
  
  Other 2.1->Fulcrum migration plans:
  
  jason can swap all the imports with the transformer in maven and then
  people will probably have to poke around for a couple minutes.
  
  
  Longer-term plans:
  
  let the ComponentLoader reload components without stopping the server.
  It will have its own classloader eventually (probably borrowing the
  webapp classloader code from catalina).  We can look for a
  configuration.xml in a standard place in the component's jar or look
  at the manifest and use that to configure the component.
  
  We'll probably provide some kind of key->value map to store references
  to the components, or treat them similarly to the way pull tools are
  handled -- where request scope tools are loaded for each request.
  Something similar might work for components as well.  Another option
  is to provide a reference to a pool of a particular kind of component.
  </pre>
  </p>
  </section>
  </body>
  </document>
  
  
  

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

Reply via email to