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-platform/tutorials/contextualization/src/java/tutorial DemoContextualizationHandler.java StandardComponent.java StandardContextImp.java ContextualizationHandler.java ContextualizationHandler.xinfo StandardComponent.xinfo StandardContext.xservice StandardService.xservice
Date Mon, 18 Aug 2003 19:38:37 GMT
mcconnell    2003/08/18 12:38:37

  Modified:    merlin/merlin-platform/tutorials/contextualization/src/java/tutorial
                        StandardComponent.java StandardContextImp.java
  Added:       merlin/merlin-platform/tutorials/contextualization
                        .cvsignore README.TXT maven.xml project.xml
               merlin/merlin-platform/tutorials/contextualization/conf
                        block.xml
               merlin/merlin-platform/tutorials/contextualization/src/java/tutorial
                        DemoContextualizationHandler.java
  Removed:     merlin/merlin-platform/tutorials/contextualization build.xml
               merlin/merlin-platform/tutorials/contextualization/src/config
                        block.xml
               merlin/merlin-platform/tutorials/contextualization/src/java/tutorial
                        ContextualizationHandler.java
                        ContextualizationHandler.xinfo
                        StandardComponent.xinfo StandardContext.xservice
                        StandardService.xservice
  Log:
  Migrate from ant to maven, update to maven 10 semantics, and sync. with Merlin 3.0.
  
  Revision  Changes    Path
  1.1                  avalon-sandbox/merlin/merlin-platform/tutorials/contextualization/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  maven.log
  velocity.log
  build
  target
  tutorial.jar
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-platform/tutorials/contextualization/README.TXT
  
  Index: README.TXT
  ===================================================================
  
  Typesafe context casting
  ------------------------
  
  This tutorial covers the declaration of custom contextualization strategy.
  
  $ maven
  $ merlin -execute target\classes
  
  
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-platform/tutorials/contextualization/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project default="jar:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util">
  
    <preGoal name="java:compile">
      <attainGoal name="avalon:meta"/>
    </preGoal>
  
  </project>
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-platform/tutorials/contextualization/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <project>
  
    <groupId>merlin</groupId>
    <id>merlin-tutorial-context-strategy</id>
    <name>Merlin Context Strategy Tutorial</name>
    <package>tutorial</package>
  
    <currentVersion>1.0</currentVersion>
    <inceptionYear>2003</inceptionYear>
    <shortDescription>Merlin Context Strategy Tutorial.</shortDescription>
  
    <dependencies>
      <dependency>
        <groupId>avalon-framework</groupId>
        <artifactId>avalon-framework-api</artifactId>
        <version>SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>avalon-framework</groupId>
        <artifactId>avalon-framework-impl</artifactId>
        <version>SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>avalon-activation</groupId>
        <artifactId>avalon-activation-spi</artifactId>
        <version>SNAPSHOT</version>
      </dependency>
    </dependencies>
    
    <build>
  
      <sourceDirectory>${basedir}/src/java</sourceDirectory>
  
      <resources>
        <resource>
          <directory>${basedir}/conf</directory>
          <targetPath>BLOCK-INF</targetPath>
          <includes>
            <include>block.xml</include>
          </includes>
        </resource>
      </resources>
  
      <jars></jars>
  
    </build>
  
  </project>
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-platform/tutorials/contextualization/conf/block.xml
  
  Index: block.xml
  ===================================================================
  
  <!--
  Demonstration of an component providing a custom contextualization phase.
  -->
  
  <container name="tutorial">
  
     <classloader>
       <classpath>
         <repository>
           <resource id="avalon-framework:avalon-framework-impl" version="SNAPSHOT"/>
           <resource id="avalon-activation:avalon-activation-spi" version="SNAPSHOT"/>
         </repository>
       </classpath>
     </classloader>
  
     <component name="standard" class="tutorial.StandardComponent"/>
  
  </container>
  
  
  
  1.2       +13 -4     avalon-sandbox/merlin/merlin-platform/tutorials/contextualization/src/java/tutorial/StandardComponent.java
  
  Index: StandardComponent.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/contextualization/src/java/tutorial/StandardComponent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StandardComponent.java	10 Jun 2003 02:12:21 -0000	1.1
  +++ StandardComponent.java	18 Aug 2003 19:38:37 -0000	1.2
  @@ -66,6 +66,8 @@
    * This is a minimal demonstration component that implements the
    * <code>BasicService</code> interface and has no dependencies.
    *
  + * @avalon.component name="standard"
  + * @avalon.service type="tutorial.StandardService"
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    */
   public class StandardComponent extends AbstractLogEnabled
  @@ -81,10 +83,17 @@
       // Contextualizable
       //=======================================================================
   
  -    /**
  -     * Supply of the the component context to the component type.
  -     * @param context the context value
  -     */
  +   /**
  +    * Supply of the the component context to the component type.
  +    *
  +    * @param context the context value
  +    *
  +    * @avalon.context strategy="tutorial.Contextualizable"
  +    * @avalon.entry key="urn:avalon:name" type="java.lang.String"
  +    * @avalon.entry key="urn:avalon:partition" type="java.lang.String"
  +    * @avalon.entry key="urn:avalon:home" type="java.io.File"
  +    * @avalon.entry key="urn:avalon:temp" type="java.io.File"
  +    */
       public void contextualize( StandardContext context )
       {
           m_home = context.getHomeDirectory();
  
  
  
  1.2       +3 -2      avalon-sandbox/merlin/merlin-platform/tutorials/contextualization/src/java/tutorial/StandardContextImp.java
  
  Index: StandardContextImp.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/contextualization/src/java/tutorial/StandardContextImp.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StandardContextImp.java	10 Jun 2003 02:12:22 -0000	1.1
  +++ StandardContextImp.java	18 Aug 2003 19:38:37 -0000	1.2
  @@ -60,6 +60,7 @@
   
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.DefaultContext;
  +import org.apache.avalon.framework.context.Context;
   
   /**
    * This is example of a custom context class.  It is used in the demonsteation
  @@ -80,9 +81,9 @@
        * @param map the context name/value map
        * @param parent a possibly parent context
        */
  -    public StandardContextImp( Map map ) throws ContextException
  +    public StandardContextImp( Context context ) throws ContextException
       {
  -        super( map );
  +        super( context );
       }
   
       //-----------------------------------------------------------------
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-platform/tutorials/contextualization/src/java/tutorial/DemoContextualizationHandler.java
  
  Index: DemoContextualizationHandler.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation. All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software
   *    itself, if and wherever such third-party acknowledgments
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package tutorial;
  
  import java.lang.reflect.Constructor;
  import java.util.Map;
  
  import org.apache.avalon.activation.lifecycle.ContextualizationHandler;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Context;
  
  /**
   * Definition of an extension handler that handles the Expoitable
   * extension stage interface.
   *
   * @avalon.component name="demo"
   * @avalon.extension id="tutorial.Contextualizable"
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   */
  public class DemoContextualizationHandler implements ContextualizationHandler
  {
      //=======================================================================
      // Extension
      //=======================================================================
  
      /**
       * Handle the contextualization stage of a component lifecycle.
       * @param object the object to contextualize
       * @param context the component context argument
       * @exception ContextException if a contextualization error occurs
       */
      public void contextualize(
        Object object, Context context )
        throws ContextException
      {
  
          //
          // based on the supplied context directives, the container supplied 
          // map of base context entries and a classloader, build and apply
          // a context object to the supplied target object
          //
  
          if( object instanceof Contextualizable )
          {
              StandardContext standard = new StandardContextImp( context );
              ( (Contextualizable)object ).contextualize( standard );
          }
          else
          {
              final String error =
                "Target object does not implement the "
                + Contextualizable.class.getName() + " interface.";
              throw new ContextException( error );
          }
      }
  }
  
  
  

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


Mime
View raw message