avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon/merlin/platform/tutorials/configuration/injection/src/java/tutorial HelloComponent.java HelloComponent.xconfig
Date Thu, 11 Mar 2004 13:21:17 GMT
mcconnell    2004/03/11 05:21:17

  Added:       merlin/platform/tutorials/configuration/injection .cvsignore
                        README.TXT project.xml
                        HelloComponent.java HelloComponent.xconfig
  Add example of configuration via injection.
  Revision  Changes    Path
  1.1                  avalon/merlin/platform/tutorials/configuration/injection/.cvsignore
  Index: .cvsignore
  1.1                  avalon/merlin/platform/tutorials/configuration/injection/README.TXT
  Configuration Management (constructor injection)
  This tutorial demonstrates the injection of a configuration
  via a component constructor.
  Build using:
    $ maven jar
    $ merlin target\classes -execute
  1.1                  avalon/merlin/platform/tutorials/configuration/injection/project.xml
  Index: project.xml
  <?xml version="1.0" encoding="UTF-8"?>
    <name>Injected Configuration Tutorial</name>
  1.1                  avalon/merlin/platform/tutorials/configuration/injection/conf/block.xml
  Index: block.xml
  <container name="tutorial">
           <resource id="avalon-framework:avalon-framework-impl" version="4.1.5"/>
     <component name="hello" class="tutorial.HelloComponent" activation="startup">
         <source>explicit configuration within block</source>
  1.1                  avalon/merlin/platform/tutorials/configuration/injection/src/java/tutorial/HelloComponent.java
  Index: HelloComponent.java
   * Copyright 2004 The Apache Software Foundation
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *     http://www.apache.org/licenses/LICENSE-2.0
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
  package tutorial;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
   * A configurable component using constructor based injection of 
   * a configuration.
   * @avalon.component version="1.0" name="simple" lifestyle="singleton"
  public class HelloComponent
      * Configuration of the component by the container.  The 
      * implementation get a child element named 'source' and 
      * assigns the value of the element to a local variable.
      * @param config the component configuration
      * @exception ConfigurationException if a configuration error occurs
      public HelloComponent( Logger logger, Configuration config ) throws ConfigurationException
          logger.info( "instantiation" );
          final String source = config.getChild( "source" ).getValue( "unknown" );
          final String message = "source: " + source;
          logger.info( message );
  1.1                  avalon/merlin/platform/tutorials/configuration/injection/src/java/tutorial/HelloComponent.xconfig
  Index: HelloComponent.xconfig
  <?xml version="1.0"?>
  This is an example of a configuration packaged with a component
  type.  Configuration declarations of this kind are normally used
  to establish default configuration values required by an 
  implementation.  The Merlin container will use this information
  to construct a cascading configuration where this configuration
  is placed as the configuration of last resort.
    <source>packaged default</source>

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

View raw message