avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin/merlin-smp/xdocs/starting/examples/afs/simple index.xml navigation.xml
Date Sun, 06 Apr 2003 19:31:25 GMT
mcconnell    2003/04/06 12:31:25

  Added:       merlin/merlin-smp/xdocs/starting/examples index.xml
                        navigation.xml
               merlin/merlin-smp/xdocs/starting/examples/afs index.xml
                        navigation.xml
               merlin/merlin-smp/xdocs/starting/examples/afs/simple
                        index.xml navigation.xml
  Log:
  Addition of xdocs for examples.
  
  Revision  Changes    Path
  1.1                  avalon-sandbox/merlin/merlin-smp/xdocs/starting/examples/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
    <header>
      <title>Getting Started</title>
      <authors>
        <person name="Stephen McConnell" email="mcconnell@apache.org"/>
      </authors>
    </header>
    <body>
      <section name="Getting Started">
        <subsection name="Examples">
          <table>
            <tr><th>Topic</th><th>Summary</th></tr>
            <tr>
              <td><a href="afs/index.html">Apache Financial Services</a></td>
              <td>
                A set of demonstrations lossely related to financial services domain.  
                The aim of the demonstration suite is to provide multiple 
                examples of component-oriented development.
              </td>
            </tr>
          </table>
        </subsection>
      </section>
    </body>
  
  </document>
  
  
  
  
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/xdocs/starting/examples/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <project>
   <title>Merlin</title>
  
   <body>
  
      <links>
        <item name="Avalon" href="http://avalon.apache.org/"/>
        <item name="Excalibur" href="http://avalon.apache.org/excalibur"/>
      </links>
  
      <menu name="About Merlin">
        <item name="Overview" href="/about/index.html"/>
        <item name="Getting Started" href="/starting/index.html">
          <item name="Installation" href="/starting/installation.html"/>
          <item name="Using Merlin" href="/starting/hello/index.html"/>
          <item name="Advanced Features" href="/starting/advanced/index.html"/>
          <item name="Examples" href="/starting/examples/index.html">
            <item name="Apache Financial Services" href="/starting/examples/afs/index.html"/>
          </item>
        </item>
        <item name="Merlin System" href="/merlin/index.html"/>
        <item name="Meta Model" href="/meta/index.html"/>
        <item name="Tools" href="/tools/index.html"/>
      </menu>
  
      <menu name="Extensions">
        <item name="JNDI" href="/extensions/jndi/index.html"/>
      </menu>
  
   </body>
  
  </project>
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/xdocs/starting/examples/afs/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
    <header>
      <title>Getting Started</title>
      <authors>
        <person name="Stephen McConnell" email="mcconnell@apache.org"/>
      </authors>
    </header>
    <body>
      <section name="Examples">
        <subsection name="Apache Financial Services">
          <p>
            A set of demonstrations of a financial services using 
            a component centric approach.
          </p>
        </subsection>
        <subsection name="Index">
          <table>
            <tr><th>Topic</th><th>Summary</th></tr>
            <tr>
              <td><a href="simple/index.html">Simple Bank</a></td>
              <td>
                The Simple Bank implementation aims to establish a minimal 
                implementation - unsecure, simplistic, but funtional. The 
                example demonstrates a bank component and non-component artifacts
                (such as an account) together with test cases that demonstrate 
                account creation, depositing and withdrawl of funds, serialization
                of the state of the bank, and account closure.
              </td>
            </tr>
          </table>
        </subsection>
      </section>
    </body>
  
  </document>
  
  
  
  
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/xdocs/starting/examples/afs/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <project>
   <title>Merlin</title>
  
   <body>
  
      <links>
        <item name="Avalon" href="http://avalon.apache.org/"/>
        <item name="Excalibur" href="http://avalon.apache.org/excalibur"/>
      </links>
  
      <menu name="About Merlin">
        <item name="Overview" href="/about/index.html"/>
        <item name="Getting Started" href="/starting/index.html">
          <item name="Installation" href="/starting/installation.html"/>
          <item name="Using Merlin" href="/starting/hello/index.html"/>
          <item name="Advanced Features" href="/starting/advanced/index.html"/>
          <item name="Examples" href="/starting/examples/index.html">
            <item name="Apache Financial Services" href="/starting/examples/afs/index.html">
              <item name="Simple Bank" href="/starting/examples/afs/simple/index.html"/>
            </item>
          </item>
        </item>
        <item name="Merlin System" href="/merlin/index.html"/>
        <item name="Meta Model" href="/meta/index.html"/>
        <item name="Tools" href="/tools/index.html"/>
      </menu>
  
      <menu name="Extensions">
        <item name="JNDI" href="/extensions/jndi/index.html"/>
      </menu>
  
   </body>
  
  </project>
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/xdocs/starting/examples/afs/simple/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
    <header>
      <title>Apache Financial Services</title>
      <authors>
        <person name="Stephen McConnell" email="mcconnell@apache.org"/>
      </authors>
    </header>
    <body>
      <section name="Apache Financial Services">
        <subsection name="Simple Bank">
          <p>
            The Simple Bank implementation aims to establish a minimal 
            implementation - unsecure, very simplistic, but funtional.  For 
            the Simple Bank implememntation a services a further demonstrations
            are planned that will demonstrate more complex applications of 
            component based systems within the Merlin environment.
          </p>
        </subsection>
        <subsection name="Block Directive">
          <p>
            Bank has no service dependencies (after all, its a rather simple 
            implementation).  The block.xml simply establishes the Bank instance
            ready to handle account creation and removal requests.
          </p>
  <source><![CDATA[
  <block name="banking">
     <container>
       <component name="bank" class="org.apache.bank.impl.BankProvider" activation="startup"/>
    </container>
  </block>
  ]]></source>
        </subsection>
        <subsection name="Bank Service Interfaces">
          <p>
            The Bank interface services as a factory for accounts.  Using the 
            Bank, clients can create and destroy accounts.
          </p>
          <p><i>Bank.java</i></p>
  <source><![CDATA[
  package org.apache.bank;
  
  public interface Bank
  {
     /**
      * Create, register and return a new account.
      * @param name the name of the account holder
      * @return Account the account
      */
      Account createAccount( String name );
  
     /**
      * Returns an account based on a supplied account number.
      * @param id the account number
      * @return Account the bank account
      */
      Account getAccount( int id ) throws NoSuchAccountException;
  
     /**
      * Close an account.
      * @param id the account number
      */
      void closeAccount( int id ) throws PolicyException, NoSuchAccountException;
  
     /**
      * Get the number of accounts managed by the bank.
      * @return the number of accounts
      */
      int accounts();
  
  }
  ]]></source>
          <p>
            The Account interface encapsulates the services that a client can
            perform against an account - deposit of funds, withdrawls, and 
            account balance queries.
          </p>
  
          <p><i>Account.java</i></p>
  <source><![CDATA[
  package org.apache.bank;
  
  public interface Account
  {
     /**
      * Get the account name.
      * @return the account name
      */
      String getName();
  
     /**
      * Get the account number.
      * @return the account number
      */
      int getID();
  
     /**
      * Get the account balance.
      * @return the account balance
      */
      float getBalance();
  
     /**
      * Deposit funds into the account.
      * @param amount the amount of funds to deposit
      */
      void deposit( float amount );
  
     /**
      * Withdraw funds from the account.
      * @param amount the amount of funds to withdraw
      */
      void withdraw( float amount ) throws InsufficientFundsException;
  
  }
  ]]></source>
        </subsection>
        <subsection name="Bank Implementation">
          <p>
            BankProvider is a simple component with dependecies on the supplied runtime
            context.  It uses the supplied context to retrieve a working directory
            from which it can internalize and externalize a serializable set of 
            accounts. With an established set of accounts, the Bank can handle 
            requests for new account creation and account removal. 
          </p>
          <p><i>Bank.java</i></p>
  <source><![CDATA[
  package org.apache.bank.impl;
  
  import java.io.File;
  import java.io.InputStream;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.io.OutputStream;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.activity.Disposable;
  
  import org.apache.bank.Bank;
  import org.apache.bank.Account;
  import org.apache.bank.PolicyException;
  import org.apache.bank.NoSuchAccountException;
  
  
  public class BankProvider extends AbstractLogEnabled 
    implements Contextualizable, Initializable, Disposable, Bank
  {
      private File m_home = null;
  
     /**
      * The persistant account registry.
      */
      private Accounts m_accounts;
  
     /**
      * Supply of the runtime context to the component by the container.  The 
      * component uses the supplied home directory to store accounts.
      * @param context the runtime context
      * @exception ContextException if the container does not supply the 
      *    home directory under the "urn:avalon:home" key.
      */
      public void contextualize( Context context ) throws ContextException
      {
          m_home = (File) context.get( "urn:avalon:home" );
          getLogger().info( "setting home directory: " + m_home );
      }
  
     /**
      * Initialization of the component by the container.
      * @exception if an initialization error occurs
      */
      public void initialize() throws Exception
      {
          File file = new File( m_home, "accounts.ser" );
          getLogger().info( "initialization" );
          if( file.exists() )
          {
              getLogger().info( "loading store: " + file );
              InputStream stream = new FileInputStream( file );
              final ObjectInputStream ois = new ObjectInputStream( stream );
              m_accounts = (Accounts) ois.readObject();
              getLogger().info( "accounts established: " + m_accounts.accounts() );
          }
          else
          {
              getLogger().info( "creating new account registry" );
              m_accounts = new Accounts();
          }
      }
  
     /**
      * Disposal of the bank by the container.
      */
      public void dispose()
      {
          getLogger().info( "initiating bank disposal" );
          try
          {
              File file = new File( m_home, "accounts.ser" );
              File parent = file.getParentFile();
              parent.mkdirs();
              file.createNewFile();
              FileOutputStream stream = new FileOutputStream( file );
              final ObjectOutputStream output = new ObjectOutputStream( stream );
              output.writeObject( m_accounts );
              output.flush();
              getLogger().info( "accounts saved to " + file );
          }
          catch( Throwable e )
          {
              final String error = 
               "Unable to write accounts to file.";
              getLogger().error( error, e );
          }
      }
  
     /**
      * Get the number of accounts managed by the bank.
      * @return the number of accounts
      */
      public int accounts()
      {
          return m_accounts.accounts();
      }
  
     /**
      * Create, register and return a new account.
      * @param name the name of the account holder
      * @return Account the account
      */
      public Account createAccount( String name )
      {
          Account account = m_accounts.createAccount( name );
          getLogger().info( 
            "created new account for: " + name 
            + " with id: " + account.getID() );
          return account;
      }
  
     /**
      * Close an account.
      * @param id the account number
      */
      public void closeAccount( int id ) throws PolicyException, NoSuchAccountException
      {
          getLogger().info( "closing account: " + id );
          m_accounts.closeAccount( id );
      }
  
     /**
      * Returns an account based on a supplied account number.
      * @param id the account number
      * @return Account the bank account
      */
      public Account getAccount( int id ) throws NoSuchAccountException
      {
          Account account = m_accounts.getAccount( id );
          getLogger().info( 
            "retrieving account: " + id  
            + " for " + account.getName() );
          return account;
      }
  }
  ]]></source>
        </subsection>
      </section>
    </body>
  
  </document>
  
  
  
  
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/xdocs/starting/examples/afs/simple/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <project>
   <title>Merlin</title>
  
   <body>
  
      <links>
        <item name="Avalon" href="http://avalon.apache.org/"/>
        <item name="Excalibur" href="http://avalon.apache.org/excalibur"/>
      </links>
  
      <menu name="About Merlin">
        <item name="Overview" href="/about/index.html"/>
        <item name="Getting Started" href="/starting/index.html">
          <item name="Installation" href="/starting/installation.html"/>
          <item name="Using Merlin" href="/starting/hello/index.html"/>
          <item name="Advanced Features" href="/starting/advanced/index.html"/>
          <item name="Examples" href="/starting/examples/index.html">
            <item name="Apache Financial Services" href="/starting/examples/afs/index.html">
              <item name="Simple Bank" href="/starting/examples/afs/simple/index.html"/>
            </item>
          </item>
        </item>
        <item name="Merlin System" href="/merlin/index.html"/>
        <item name="Meta Model" href="/meta/index.html"/>
        <item name="Tools" href="/tools/index.html"/>
      </menu>
  
      <menu name="Extensions">
        <item name="JNDI" href="/extensions/jndi/index.html"/>
      </menu>
  
   </body>
  
  </project>
  
  
  

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


Mime
View raw message