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/src/test/org/apache/avalon/playground Contextualizable.java ContextualizationHandler.java ContextualizationHandler.xinfo StandardContext.xservice StandardContextImp.java StandardComponent.java StandardComponent.xinfo StandardComponent.xprofile StandardContext.java StandardService.java StandardComponent.xconfig StandardContextInterface.java
Date Thu, 19 Dec 2002 10:50:17 GMT
mcconnell    2002/12/19 02:50:17

  Modified:    merlin/src/java/org/apache/avalon/merlin Main.java
               merlin/src/java/org/apache/avalon/merlin/container
                        ContainerLoader.java DefaultContainer.java
                        DefaultContainer.xinfo
               merlin/src/java/org/apache/avalon/merlin/kernel
                        DefaultKernel.java DefaultKernel.xinfo Kernel.java
               merlin/src/test/config block.xml
               merlin/src/test/org/apache/avalon/merlin/kernel
                        KernelTestCase.java
               merlin/src/test/org/apache/avalon/playground
                        StandardComponent.java StandardComponent.xinfo
                        StandardComponent.xprofile StandardContext.java
                        StandardService.java
  Added:       merlin/src/test/org/apache/avalon/playground
                        Contextualizable.java ContextualizationHandler.java
                        ContextualizationHandler.xinfo
                        StandardContext.xservice StandardContextImp.java
  Removed:     merlin/src/test/org/apache/avalon/playground
                        StandardComponent.xconfig
                        StandardContextInterface.java
  Log:
  Updated to handle assembly changes and incorporation of plug-in context strategy.
  
  Revision  Changes    Path
  1.4       +1 -1      avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/Main.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Main.java	17 Dec 2002 04:41:56 -0000	1.3
  +++ Main.java	19 Dec 2002 10:50:16 -0000	1.4
  @@ -94,7 +94,7 @@
   
           File base = getWorkingDirectory();
           DefaultContext context = new DefaultContext();
  -        context.put( "urn:urn:avalon:home", base );
  +        context.put( "urn:assembly:home", base );
           context.makeReadOnly();
   
           File file = getConfigurationFile( base, args );
  
  
  
  1.5       +12 -5     avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/ContainerLoader.java
  
  Index: ContainerLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/ContainerLoader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContainerLoader.java	17 Dec 2002 09:59:48 -0000	1.4
  +++ ContainerLoader.java	19 Dec 2002 10:50:16 -0000	1.5
  @@ -192,7 +192,14 @@
                   childName = childConfig.getAttribute( "name", "untitled" );
                   childLogger = logger.getChildLogger( childName );
                   childEngine = childEngine = createChildEngine( engine, home, childConfig,
childLogger );
  -                childPartition = partition + "/" + name;
  +                if( partition.endsWith( "/" ) )
  +                {
  +                    childPartition = partition + "/" + name;
  +                }
  +                else
  +                {
  +                    childPartition = partition + name;
  +                }
                   childRegistry = registry.createChild( name );
               }
   
  @@ -217,11 +224,11 @@
           map.put("urn:merlin:container.registry", registry );
           if( partition != null )
           {
  -            map.put("urn:merlin:container.partition", partition );
  +            map.put("urn:avalon:partition.name", partition );
           }
           else
           {
  -            map.put("urn:merlin:container.partition", "" );
  +            map.put("urn:avalon:partition.name", "" );
           }
           ApplianceContext context = new ApplianceContext( descriptor );
           context.setDeploymentContext( map );
  @@ -340,7 +347,7 @@
               engine.enableLogging( logger.getChildLogger( "engine" ) );
               engine.configure( config );
               DefaultContext context = new DefaultContext();
  -            context.put( "urn:avalon:home", home );
  +            context.put( "urn:assembly:home", home );
               context.put( "urn:assembly:engine.extensions", extensions );
               context.put( "urn:assembly:engine.classpath", classpath );
               context.makeReadOnly();
  
  
  
  1.4       +11 -4     avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/DefaultContainer.java
  
  Index: DefaultContainer.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/DefaultContainer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultContainer.java	17 Dec 2002 09:59:48 -0000	1.3
  +++ DefaultContainer.java	19 Dec 2002 10:50:16 -0000	1.4
  @@ -144,7 +144,7 @@
           m_engine = (EngineClassLoader) context.get( "urn:assembly:engine.classloader" );
           m_containers = (List) context.get( "urn:merlin:container.containers" );
           m_descriptor = (ContainerDescriptor) context.get( "urn:merlin:container.descriptor"
);
  -        m_partition = (String) context.get( "urn:merlin:container.partition" );
  +        m_partition = (String) context.get( "urn:avalon:partition.name" );
           m_registry = (Registry) context.get( "urn:merlin:container.registry" );
       }
   
  @@ -165,11 +165,18 @@
   
           if( m_partition != null )
           {
  -            m_path = m_partition + "/" + m_descriptor.getName();
  +            if( m_partition.endsWith("/") )
  +            {
  +                m_path = m_partition + "/" + m_descriptor.getName();
  +            }
  +            else
  +            {
  +                m_path = m_partition + m_descriptor.getName();
  +            }
           }
           else
           {
  -            m_path = "/" + m_descriptor.getName();
  +            m_path = m_descriptor.getName();
           }
   
           if( getLogger().isDebugEnabled() )
  
  
  
  1.4       +1 -1      avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/DefaultContainer.xinfo
  
  Index: DefaultContainer.xinfo
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/DefaultContainer.xinfo,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultContainer.xinfo	17 Dec 2002 09:59:48 -0000	1.3
  +++ DefaultContainer.xinfo	19 Dec 2002 10:50:17 -0000	1.4
  @@ -29,7 +29,7 @@
         type="org.apache.avalon.merlin.container.ContainerDescriptor"/>
       <entry key="urn:merlin:container.registry"
         type="org.apache.avalon.merlin.service.Registry"/>
  -    <entry key="urn:merlin:container.partition"/>
  +    <entry key="urn:avalon:partition.name"/>
     </context>
   
   </type>
  
  
  
  1.13      +6 -6      avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/DefaultKernel.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultKernel.java	17 Dec 2002 09:59:48 -0000	1.12
  +++ DefaultKernel.java	19 Dec 2002 10:50:17 -0000	1.13
  @@ -192,16 +192,16 @@
       *     <td><strong>key</strong></td><td><strong>type</strong></td><td><strong>description</strong></td>
       *   </tr>
       *   <tr>
  -    *     <td>urn:urn:avalon:home</td>
  +    *     <td>urn:assembly:home</td>
       *     <td>{@link java.io.File}</td>
  -    *     <td>The application home directory.</td> 
  +    *     <td>The kernel home directory.</td> 
       *   </tr>
       * </table>
       * @param context the runtime context
       */
       public void contextualize( Context context ) throws ContextException
       {
  -        m_home = (File) context.get( "urn:urn:avalon:home" );
  +        m_home = (File) context.get( "urn:assembly:home" );
       }
   
       //==============================================================
  @@ -507,7 +507,7 @@
                   m_config.getChild( "logging" ), root );
   
               DefaultContext context = new DefaultContext();
  -            context.put( "urn:avalon:home", m_home );
  +            context.put( "urn:assembly:home", m_home );
               context.put( "urn:assembly:logging.descriptor", descriptor );
               context.makeReadOnly();
   
  @@ -596,7 +596,7 @@
           if( m_system == null )
           {
               DefaultContext context = new DefaultContext();
  -            context.put( "urn:avalon:home", m_home );
  +            context.put( "urn:assembly:home", m_home );
               context.put( "urn:merlin:domain", m_registry.getBase().getHost() );
               context.makeReadOnly();
               m_system = context;
  
  
  
  1.2       +1 -1      avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/DefaultKernel.xinfo
  
  Index: DefaultKernel.xinfo
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/DefaultKernel.xinfo,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultKernel.xinfo	3 Dec 2002 07:08:03 -0000	1.1
  +++ DefaultKernel.xinfo	19 Dec 2002 10:50:17 -0000	1.2
  @@ -21,7 +21,7 @@
     </info>
   
     <context>
  -    <entry key="urn:avalon:home" type="java.io.File" optional="false"/>
  +    <entry key="urn:assembly:home" type="java.io.File" optional="false"/>
     </context>
   
     <services>
  
  
  
  1.2       +2 -2      avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/Kernel.java
  
  Index: Kernel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/Kernel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Kernel.java	3 Dec 2002 07:08:03 -0000	1.1
  +++ Kernel.java	19 Dec 2002 10:50:17 -0000	1.2
  @@ -68,7 +68,7 @@
       /**
        * The context key for the working directory.
        */
  -    public static final String DIR_KEY = "urn:avalon:home";
  +    public static final String DIR_KEY = "urn:assembly:home";
   
       /**
        * The context key for the path to the configuration.
  
  
  
  1.7       +2 -5      avalon-sandbox/merlin/src/test/config/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/test/config/block.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- block.xml	17 Dec 2002 09:59:48 -0000	1.6
  +++ block.xml	19 Dec 2002 10:50:17 -0000	1.7
  @@ -10,11 +10,8 @@
      </services>
   
      <container>
  -     <component name="default" class="org.apache.avalon.playground.StandardComponent"
activation="startup">
  -       <context class="org.apache.avalon.playground.StandardContext">
  -         <entry key="location">New York</entry>
  -         <import name="urn:avalon:home" key="home" />
  -       </context>
  +     <component name="standard" class="org.apache.avalon.playground.StandardComponent"
activation="startup">
  +       <context class="org.apache.avalon.playground.StandardContextImp"/>
        </component>
        <container name="test"/>
      </container>
  
  
  
  1.4       +4 -2      avalon-sandbox/merlin/src/test/org/apache/avalon/merlin/kernel/KernelTestCase.java
  
  Index: KernelTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/test/org/apache/avalon/merlin/kernel/KernelTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- KernelTestCase.java	12 Dec 2002 00:37:13 -0000	1.3
  +++ KernelTestCase.java	19 Dec 2002 10:50:17 -0000	1.4
  @@ -60,7 +60,7 @@
   
           File base = getWorkingDirectory();
           DefaultContext context = new DefaultContext();
  -        context.put( "urn:urn:avalon:home", base );
  +        context.put( "urn:assembly:home", base );
           context.makeReadOnly();
   
           File file = getConfigurationFile( base, args );
  @@ -78,7 +78,7 @@
           }
           catch( Throwable e )
           {
  -            final String error = "Problem loading kernel configuration form file: " + file;
  +            final String error = "Problem loading kernel configuration from file: " + file;
               throw new RuntimeException( error );
           }
   
  @@ -88,6 +88,8 @@
               m_kernel.contextualize( context );
               m_kernel.initialize();
               m_kernel.start();
  +            m_kernel.stop();
  +            m_kernel.dispose();
           }
           catch( Throwable e )
           {
  
  
  
  1.3       +21 -31    avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.java
  
  Index: StandardComponent.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardComponent.java	17 Dec 2002 04:40:39 -0000	1.2
  +++ StandardComponent.java	19 Dec 2002 10:50:17 -0000	1.3
  @@ -61,8 +61,6 @@
   import org.apache.avalon.framework.activity.Startable;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   
   /**
  @@ -72,12 +70,15 @@
    * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
    */
   public class StandardComponent extends AbstractLogEnabled
  -    implements Contextualizable, Configurable, Initializable, Startable, Disposable, StandardService
  +    implements Contextualizable, Initializable, Startable, Disposable, StandardService
   {
   
  -    private String m_location;
  -    private String m_message;
       private File m_home;
  +    private File m_work;
  +    private String m_name;
  +    private String m_partition;
  +
  +    private String m_message;
   
       //=======================================================================
       // Contextualizable
  @@ -87,26 +88,13 @@
        * Supply of the the component context to the component type.
        * @param context the context value
        */
  -    public void contextualize( Context context )
  -    {
  -        StandardContextInterface c = (StandardContextInterface)context;
  -        m_location = c.getLocation();
  -        m_home = c.getWorkingDirectory();
  -    }
  -
  -    //=======================================================================
  -    // Configurable
  -    //=======================================================================
  -
  -    /**
  -     * Supply of the the component configuration to the type.
  -     * @param config the configuration value
  -     */
  -    public void configure( Configuration config )
  +    public void contextualize( StandardContext context )
       {
  -        getLogger().debug( "configure" );
  -        m_message = config.getChild( "message" ).getValue( null );
  -    }
  +        m_home = context.getHomeDirectory();
  +        m_work = context.getWorkingDirectory();
  +        m_name = context.getName();
  +        m_partition = context.getPartitionName();
  +   }
   
       //=======================================================================
       // Initializable
  @@ -117,10 +105,11 @@
        */
       public void initialize()
       {
  -        getLogger().debug( "initialize" );
  -        getLogger().debug( "location: " + m_location );
  -        getLogger().debug( "home: " + m_home );
  -        getLogger().debug( "message: " + m_message );
  +        m_message = 
  +          "\n  home: " + m_home
  +          + "\n  work: " + m_work
  +          + "\n  name: " + m_name
  +          + "\n  partition: " + m_partition;
       }
   
       //=======================================================================
  @@ -132,7 +121,8 @@
        */
       public void start()
       {
  -        doPrimeObjective();
  +        getLogger().debug( "starting" );
  +        printMessage();
       }
   
       /**
  @@ -158,9 +148,9 @@
       /**
        * Service interface implementation.
        */
  -    public void doPrimeObjective()
  +    public void printMessage()
       {
  -        getLogger().info( m_message + " from '" + m_location + "'." );
  +        getLogger().info( m_message );
       }
   
   }
  
  
  
  1.4       +15 -4     avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.xinfo
  
  Index: StandardComponent.xinfo
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.xinfo,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardComponent.xinfo	17 Dec 2002 09:59:48 -0000	1.3
  +++ StandardComponent.xinfo	19 Dec 2002 10:50:17 -0000	1.4
  @@ -19,9 +19,21 @@
       <name>standard</name>
     </info>
   
  -  <context type="org.apache.avalon.playground.StandardContextInterface">
  -    <entry key="location"/>
  -    <entry key="home" type="java.io.File"/>
  +  <!--
  +  Declaration of the contextualization service, context type and 
  +  entries.  The provider value is a component implementing the 
  +  Contextualizer interface.  The type value is a interface that 
  +  the component implementation can narrow a supplied context value
  +  to.
  +  -->
  +
  +  <context type="org.apache.avalon.playground.StandardContext">
  +
  +    <attributes>
  +      <attribute key="urn:assembly:lifecycle.context.extension"
  +          value="org.apache.avalon.playground.Contextualizable"/>
  +    </attributes>
  +
     </context>
   
     <services>
  @@ -29,4 +41,3 @@
     </services>
   
   </type>
  -
  
  
  
  1.2       +1 -4      avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.xprofile
  
  Index: StandardComponent.xprofile
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.xprofile,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StandardComponent.xprofile	11 Dec 2002 01:32:02 -0000	1.1
  +++ StandardComponent.xprofile	19 Dec 2002 10:50:17 -0000	1.2
  @@ -20,10 +20,7 @@
      -->
    
      <component name="standard">
  -     <context class="org.apache.avalon.playground.StandardContext">
  -       <import name="urn:avalon:home" key="home" />
  -       <entry key="location">Paris</entry>
  -     </context>
  +     <context class="org.apache.avalon.playground.StandardContextImp"/>
      </component>
   
   </profiles>
  
  
  
  1.2       +20 -37    avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StandardContext.java	11 Dec 2002 01:32:02 -0000	1.1
  +++ StandardContext.java	19 Dec 2002 10:50:17 -0000	1.2
  @@ -56,58 +56,41 @@
   package org.apache.avalon.playground;
   
   import java.io.File;
  -import java.util.Map;
   import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.DefaultContext;
   
   /**
  - * This is example of a custom context class.  It is used in the demonsteation
  - * of a context management fraework to show how a context class can be
  - * supplied to a component declaring a context interface criteria.
  + * Simple non-standard Context interface to demonstration context
  + * management at the level of different context types.
    *
    * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
    */
  -public class StandardContext extends DefaultContext implements StandardContextInterface
  +public interface StandardContext extends Context
   {
  +    public static final String NAME_KEY = "urn:avalon:name";
  +    public static final String PARTITION_KEY = "urn:avalon:partition.name";
  +    public static final String WORKING_KEY = "urn:avalon:work";
  +    public static final String HOME_KEY = "urn:avalon:home";
   
       /**
  -     * Creation of a new custom context instance.
  -     * @param map the context name/value map
  -     * @param parent a possibly parent context
  +     * Return the name assigned to the component
  +     * @return the name
        */
  -    public StandardContext( Map map, Context parent )
  -    {
  -        super( map, parent );
  -    }
  +    String getName();
   
       /**
  -     * @return the location
  +     * Return the partition name assigned to the component
  +     * @return the partition name
        */
  -    public String getLocation()
  -    {
  -        try
  -        {
  -            return (String)super.get( "location" );
  -        }
  -        catch( Throwable e )
  -        {
  -            return "Unknown";
  -        }
  -    }
  +    String getPartitionName();
   
       /**
  -     * @return the working directory
  +     * @return a file representing the home directory
        */
  -    public File getWorkingDirectory()
  -    {
  -        try
  -        {
  -            return (File)super.get( "home" );
  -        }
  -        catch( Throwable e )
  -        {
  -            throw new RuntimeException( "context object does not provide required home
entry." );
  -        }
  -    }
  +    File getHomeDirectory();
  +
  +    /**
  +     * @return a file representing the working directory
  +     */
  +    File getWorkingDirectory();
   
   }
  
  
  
  1.2       +1 -1      avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardService.java
  
  Index: StandardService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StandardService.java	11 Dec 2002 01:32:02 -0000	1.1
  +++ StandardService.java	19 Dec 2002 10:50:17 -0000	1.2
  @@ -66,5 +66,5 @@
       /**
        * Execute the prime objective of this services.
        */
  -    void doPrimeObjective();
  +    void printMessage();
   }
  
  
  
  1.1                  avalon-sandbox/merlin/src/test/org/apache/avalon/playground/Contextualizable.java
  
  Index: Contextualizable.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 org.apache.avalon.playground;
  
  import org.apache.avalon.framework.context.ContextException;
  
  /**
   * Definition of an alterbnative contexulization interface.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   */
  public interface Contextualizable
  {
      //=======================================================================
      // Contextualization (custom variant)
      //=======================================================================
  
      /**
       * Contextuyalization of the component.
       * @param context the containement context
       * @exception ContextException if a contextualization error occurs
       */
      void contextualize( StandardContext context ) 
        throws ContextException;
  }
  
  
  
  1.1                  avalon-sandbox/merlin/src/test/org/apache/avalon/playground/ContextualizationHandler.java
  
  Index: ContextualizationHandler.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 org.apache.avalon.playground;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  
  import org.apache.avalon.assembly.appliance.Appliance;
  import org.apache.avalon.assembly.lifecycle.context.Contextualization;
  
  /**
   * Definition of an extension handler that handles the Expoitable
   * extension stage interface.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   */
  public class ContextualizationHandler implements Contextualization
  {
      //=======================================================================
      // Extension
      //=======================================================================
  
      /**
       * Handle the contextualization stage of a component lifecycle.
       * @param object the object to contextualize
       * @param context the deployment context
       * @exception ContextException if a contextualization error occurs
       */
      public void contextualize( 
        Object object, Context context ) 
        throws ContextException
      {
          if( object instanceof Contextualizable )
          {
              if( context instanceof StandardContext )
              {
                  ( (Contextualizable)object ).contextualize( (StandardContext) context );
              }
              else
              {
                  final String error = 
                    "Supplied context does not implement the StandardContext interface.";
                  throw new ContextException( error );
              }
          }
          else
          {
              final String error =
                "Target object does not implement the "
                + Contextualizable.class.getName() + " interface.";
              throw new ContextException( error );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/merlin/src/test/org/apache/avalon/playground/ContextualizationHandler.xinfo
  
  Index: ContextualizationHandler.xinfo
  ===================================================================
  <?xml version="1.0"?>
  <!DOCTYPE type
        PUBLIC "-//AVALON/Component Type DTD Version 1.0//EN"
               "http://jakarta.apache.org/avalon/dtds/meta/type_1_1.dtd" >
  
  <!--  
  Copyright (C) The Apache Software Foundation. All rights reserved.
  This software is published under the terms of the Apache Software License
  version 1.1, a copy of which has been included with this distribution in
  the LICENSE.txt file.
  
  @author  Avalon Development Team
  @version 1.0 12/03/2001
  -->
  
  <!--
  Definition of the extension type phase support.
  -->
  
  <type>
  
    <info>
      <name>context</name>
    </info>
  
    <!--
    Declaration of the lifecycle support phases that this manager provides. 
    -->
    <extensions>
      <extension type="org.apache.avalon.playground.Contextualizable" />
    </extensions>
  
  </type>
  
  
  
  
  1.1                  avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardContext.xservice
  
  Index: StandardContext.xservice
  ===================================================================
  <?xml version="1.0"?>
  <!DOCTYPE type
        PUBLIC "-//AVALON/Component Type DTD Version 1.0//EN"
               "http://jakarta.apache.org/avalon/dtds/meta/type_1_1.dtd" >
  
  <!--  
  Copyright (C) The Apache Software Foundation. All rights reserved.
  This software is published under the terms of the Apache Software License
  version 1.1, a copy of which has been included with this distribution in
  the LICENSE.txt file.
  
  @author  Avalon Development Team
  @version 1.0 12/03/2001
  -->
  
  <service>
    <version>1.0</version>
    <entries>
      <entry key="urn:avalon:name"/>
      <entry key="urn:avalon:partition.name"/>
      <entry key="urn:avalon:home" type="java.io.File"/>
      <entry key="urn:avalon:work" type="java.io.File"/>
    </entries>
  </service>
  
  
  
  
  1.1                  avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardContextImp.java
  
  Index: StandardContextImp.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 org.apache.avalon.playground;
  
  import java.io.File;
  import java.util.Map;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.DefaultContext;
  
  /**
   * This is example of a custom context class.  It is used in the demonsteation
   * of a context management fraework to show how a context class can be
   * supplied to a component declaring a context interface criteria.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   */
  public class StandardContextImp extends DefaultContext implements StandardContext
  {
  
      //-----------------------------------------------------------------
      // constructor
      //-----------------------------------------------------------------
  
      /**
       * Creation of a new custom context instance.
       * @param map the context name/value map
       * @param parent a possibly parent context
       */
      public StandardContextImp( Map map, Context parent ) throws ContextException
      {
          super( map, parent );
      }
  
      //-----------------------------------------------------------------
      // StandardContext
      //-----------------------------------------------------------------
  
      /**
       * Return the name assigned to the component
       * @return the name
       */
      public String getName()
      {
          try
          {
              return (String)super.get( StandardContext.NAME_KEY );
          }
          catch( Throwable e )
          {
              throw new IllegalStateException( StandardContext.NAME_KEY );
          }
      }
  
      /**
       * Return the partition name assigned to the component
       * @return the partition name
       * @exception IllegalStateException if the partition name is undefined
       */
      public String getPartitionName()
      {
          try
          {
              return (String)super.get( StandardContext.PARTITION_KEY );
          }
          catch( Throwable e )
          {
              throw new IllegalStateException( StandardContext.PARTITION_KEY );
          }
      }
  
      /**
       * Returns the home directory for this component.
       * @return the home directory
       */
      public File getHomeDirectory()
      {
          try
          {
              return (File)super.get( StandardContext.HOME_KEY );
          }
          catch( Throwable e )
          {
              throw new IllegalStateException( StandardContext.HOME_KEY );
          }
      }
  
      /**
       * @return the working directory
       */
      public File getWorkingDirectory()
      {
          try
          {
              return (File)super.get( StandardContext.WORKING_KEY );
          }
          catch( Throwable e )
          {
              throw new IllegalStateException( StandardContext.WORKING_KEY );
          }
      }
  }
  
  
  

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


Mime
View raw message