avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craft...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/swing SwingContainer.java SwingContainer.roles SwingContainer.xconf SwingContainer.xlog swing.java
Date Thu, 04 Jul 2002 09:43:25 GMT
crafterm    2002/07/04 02:43:25

  Modified:    fortress/examples build.xml
               fortress/examples/bin run.bat run.sh
  Added:       fortress/examples ant.properties
               fortress/examples/src/java/org/apache/excalibur/fortress/examples/components
                        Translator.java TranslatorImpl.java
               fortress/examples/src/java/org/apache/excalibur/fortress/examples/swing
                        SwingContainer.java SwingContainer.roles
                        SwingContainer.xconf SwingContainer.xlog swing.java
  Removed:     fortress/examples/conf components.xml logkit.xml
                        profiler.xml
  Log:
  First draft at a Fortress example application. Feedback more than welcome.
  
  Revision  Changes    Path
  1.2       +82 -15    jakarta-avalon-excalibur/fortress/examples/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	12 Mar 2002 21:36:56 -0000	1.1
  +++ build.xml	4 Jul 2002 09:43:24 -0000	1.2
  @@ -6,28 +6,23 @@
   
   <project name="container" default="main" basedir=".">
   
  -    <!-- ================================================================ -->
  -    <!-- Local user-defined build properties.                             -->
  -    <!-- ================================================================ -->
  -    <!-- The file below should exist on your system. On Windows machines, -->
  -    <!-- user.home is probably the root of the C drive, but you should    -->
  -    <!-- verify this. This file should be a normal Java properties file.  -->
  -    <property file="${user.home}/.ant.properties" />
  +    <property file="ant.properties"/>
  +    <property file="../ant.properties"/>
  +    <property file="${user.home}/.ant.properties"/>
   
  -    <property name="name" value="container"/>
  -    <property name="Name" value="Container"/>
  +    <property name="name" value="fortress-examples"/>
  +    <property name="Name" value="Fortress-Examples"/>
   
       <!-- Directories build by ant -->
       <property name="build.dir"             value="${basedir}/build"/>
       <property name="build.classes.dir"     value="${build.dir}/classes"/>
       <property name="build.javadocs.dir"    value="${build.dir}/javadocs"/>
       <property name="lib.dir"               value="${basedir}/lib"/>
  -    <property name="data.dir"              value="${basedir}/data"/>
   
       <!-- Existing directories -->
       <property name="src.dir"               value="${basedir}/src"/>
       <property name="src.java.dir"          value="${src.dir}/java"/>
  -    <property name="commonlib.dir"         value="${basedir}/../commonlib"/>
  +    <property name="commonlib.dir"         value="${basedir}/lib"/>
   
       <!-- Define paths used by this project -->
       <path id="project.class.path">
  @@ -49,7 +44,67 @@
       <!-- Help on usage                                                       -->
       <!-- =================================================================== -->
       <target name="collect-jars">
  -        <ant antfile="build.xml" dir="${basedir}/.." target="collect-jars" inheritall="false"/>
  +
  +        <!-- Avalon framework jar -->
  +        <copy file="${avalon-framework.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Excalibur source resolver jar -->
  +        <copy file="${excalibur-sourceresolve.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Excalibur Logger jar -->
  +        <copy file="${excalibur-logger.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Excalibur pool jar -->
  +        <copy file="${excalibur-pool.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Excalibur instrument jar -->
  +        <copy file="${excalibur-instrument.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Excalibur instrument manager jar -->
  +        <copy file="${excalibur-instrument-manager.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Excalibur event jar -->
  +        <copy file="${excalibur-event.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Excalibur collections jar -->
  +        <copy file="${excalibur-collections.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Excalibur concurrent jar -->
  +        <copy file="${excalibur-concurrent.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Avalon logger jar -->
  +        <copy file="${logkit.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Fortress jar -->
  +        <copy file="${excalibur-fortress.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- MPool jar -->
  +        <copy file="${excalibur-mpool.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- xml-apis -->
  +        <copy file="${xml-apis.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Xerces jar -->
  +        <copy file="${xerces.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
  +        <!-- Xalan jar -->
  +        <copy file="${xalan.jar}"
  +            todir="${lib.dir}" preservelastmodified="yes"/>
  +
       </target>
   
       <!-- =================================================================== -->
  @@ -72,6 +127,14 @@
               optimize="off">
               <classpath refid="project.class.path" />
           </javac>
  +	
  +        <!-- copy resources to same location as .class files -->
  +        <copy todir="${build.classes.dir}">
  +            <fileset dir="${src.java.dir}">
  +                <exclude name="**/*.java"/>
  +                <exclude name="**/package.html"/>
  +            </fileset>
  +        </copy>
   
           <!-- copy image files to build directory -->
           <copy todir="${build.classes.dir}" >
  @@ -80,6 +143,10 @@
                   <include name="**/*.gif" />
               </fileset>
           </copy>
  +    
  +    </target>
  +    
  +    <target name="install" depends="jar">
       </target>
   
       <!-- =================================================================== -->
  @@ -90,15 +157,14 @@
   
           <jar jarfile="${lib.dir}/${name}.jar"
               basedir="${build.classes.dir}"
  -            includes="**/*.class,**/*.properties,**/*.xml,**/*.jpg,**/*.gif,**/*.roles"
  +            includes="**/*.*"
               />
       </target>
   
       <!-- =================================================================== -->
       <!-- Main target                                                         -->
       <!-- =================================================================== -->
  -    <target name="main" depends="jar" description="build the runnable application">
  -        <mkdir dir="${data.dir}"/>
  +    <target name="main" depends="install" description="build the runnable application">
       </target>
   
       <!-- =================================================================== -->
  @@ -132,6 +198,7 @@
       <!-- =================================================================== -->
       <target name="clean" description="cleans up the directory">
           <delete dir="${build.dir}"/>
  +        <delete dir="${lib.dir}"/>
       </target>
   </project>
   
  
  
  
  1.1                  jakarta-avalon-excalibur/fortress/examples/ant.properties
  
  Index: ant.properties
  ===================================================================
  # -------------------------------------------------------------------
  # B U I L D  P R O P E R T I E S
  # -------------------------------------------------------------------
  
  basepath=${basedir}/..
  
  # --------------------------------------------------
  #                REQUIRED LIBRARIES
  # --------------------------------------------------
  
  # ----- Excalibur collections, version 1.0 or later -----
  excalibur-collections.home=${basepath}/../collections/dist
  excalibur-collections.lib=${excalibur-collections.home}
  excalibur-collections.jar=${excalibur-collections.lib}/excalibur-collections-1.0.jar
  
  # ----- Excalibur event, version 1.0 or later -----
  excalibur-event.home=${basepath}/../event/dist
  excalibur-event.lib=${excalibur-event.home}
  excalibur-event.jar=${excalibur-event.lib}/excalibur-event-1.0a.jar
  
  # ----- Excalibur util, version 1.0 or later -----
  excalibur-util.home=${basepath}/../util/dist
  excalibur-util.lib=${excalibur-util.home}
  excalibur-util.jar=${excalibur-util.lib}/excalibur-util-1.0.jar
  
  # ----- Excalibur Source Resolver, version 1.0 or later -----
  excalibur-sourceresolve.home=${basepath}/../sourceresolve/dist
  excalibur-sourceresolve.lib=${excalibur-sourceresolve.home}
  excalibur-sourceresolve.jar=${excalibur-sourceresolve.lib}/excalibur-sourceresolve-1.0.jar
  
  # ----- Excalibur logger, version 1.0 or later -----
  excalibur-logger.home=${basepath}/../logger/dist
  excalibur-logger.lib=${excalibur-logger.home}
  excalibur-logger.jar=${excalibur-logger.lib}/excalibur-logger-1.0.jar
  
  # ----- Excalibur pool, version 1.0 or later -----
  excalibur-pool.home=${basepath}/../pool/dist
  excalibur-pool.lib=${excalibur-pool.home}
  excalibur-pool.jar=${excalibur-pool.lib}/excalibur-pool-1.0.jar
  
  # ----- Excalibur instrument, version 1.0 or later -----
  excalibur-instrument.home=${basepath}/../instrument/dist
  excalibur-instrument.lib=${excalibur-instrument.home}
  excalibur-instrument.jar=${excalibur-instrument.lib}/excalibur-instrument-0.1.jar
  
  # ----- Excalibur instrument manager, version 1.0 or later -----
  excalibur-instrument-manager.home=${basepath}/../instrument-manager/dist
  excalibur-instrument-manager.lib=${excalibur-instrument-manager.home}
  excalibur-instrument-manager.jar=${excalibur-instrument-manager.lib}/excalibur-instrument-manager-0.1.jar
  
  # ----- Excalibur concurrent, version 1.0 or later -----
  excalibur-concurrent.home=${basepath}/../concurrent/dist
  excalibur-concurrent.lib=${excalibur-concurrent.home}
  excalibur-concurrent.jar=${excalibur-concurrent.lib}/excalibur-concurrent-1.0.jar
  
  # ----- Avalon Framework, version 4.1 or later -----
  avalon-framework.home=${basepath}/../../jakarta-avalon
  avalon-framework.lib=${avalon-framework.home}/build/lib
  avalon-framework.jar=${avalon-framework.lib}/avalon-framework.jar
  
  # ----- Excalibur Fortress, version 1.0 or later -----
  excalibur-fortress.home=${basepath}/build/lib
  excalibur-fortress.lib=${excalibur-fortress.home}
  excalibur-fortress.jar=${excalibur-fortress.lib}/excalibur-fortress-1.0.jar
  
  # ----- Commons collections, version 2.0 or later -----
  commons-collections.home=${basepath}
  commons-collections.lib=${commons-collections.home}/lib
  commons-collections.jar=${commons-collections.lib}/commons-collections-2.0.jar
  
  # ----- Excalibur MPool, version 1.0 or later -----
  excalibur-mpool.jar=${excalibur-fortress.lib}/excalibur-mpool-1.0.jar
  
  # ----- Logkit -----
  logkit.home=${basepath}/../../jakarta-avalon-logkit
  logkit.lib=${logkit.home}/build/lib
  logkit.jar=${logkit.lib}/logkit.jar
  
  # ----- Misc tools -----
  tools.dir=../../../jakarta-avalon/tools
  xml-apis.jar=${tools.dir}/lib/xml-apis.jar
  xalan.jar=${tools.dir}/lib/xalan-2.3.1.jar
  xerces.jar=${tools.dir}/lib/xerces-2.0.1.jar
  
  # --------------------------------------------------
  
  
  
  1.3       +1 -1      jakarta-avalon-excalibur/fortress/examples/bin/run.bat
  
  Index: run.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/bin/run.bat,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- run.bat	3 Apr 2002 13:45:35 -0000	1.2
  +++ run.bat	4 Jul 2002 09:43:24 -0000	1.3
  @@ -58,6 +58,6 @@
   set CP=%CP%%_LIBJARS%
   
   rem Run the example application
  -%EXAMPLE_JAVACMD% -Djava.compiler="NONE" -classpath "%CP%" org.apache.avalon.examples.container.Main
%1 %2 %3 %4 %5 %6 %7 %8 %9
  +%EXAMPLE_JAVACMD% -Djava.compiler="NONE" -classpath "%CP%" org.apache.excalibur.fortress.examples.simple.simple
%1 %2 %3 %4 %5 %6 %7 %8 %9
   
   :end
  
  
  
  1.2       +5 -5      jakarta-avalon-excalibur/fortress/examples/bin/run.sh
  
  Index: run.sh
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/bin/run.sh,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- run.sh	12 Mar 2002 21:36:56 -0000	1.1
  +++ run.sh	4 Jul 2002 09:43:24 -0000	1.2
  @@ -23,19 +23,19 @@
   
   # Main.java has hard coded config values so this script must be run from
   # altprofile/bin (any better ideas ?)
  -EXAMPLE_HOME=../..
  +EXAMPLE_HOME=..
   
   #
   # Build the runtime classpath
   #
  -for i in ${EXAMPLE_HOME}/commonlib/*.jar ; do
  +for i in ${EXAMPLE_HOME}/lib/*.jar ; do
       CP=${CP}:$i
   done
   
  -CP=${CP}:../lib/container.jar
  +CP=${CP}:${EXAMPLE_HOME}/build/classes
   
  -#echo $CP
  +echo $CP
   
   # Run the example application
  -$JAVACMD -classpath $CP org.apache.avalon.examples.container.Main $@
  +$JAVACMD -classpath $CP org.apache.excalibur.fortress.examples.swing.swing $@
   
  
  
  
  1.1                  jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/components/Translator.java
  
  Index: Translator.java
  ===================================================================
  /*
  * 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.
  */
  package org.apache.excalibur.fortress.examples.components;
  
  import org.apache.avalon.framework.component.Component;
  
  /**
   * Translator component. This component provides simple translations of given
   * keys, identified by language name.
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/07/04 09:43:24 $
   */
  public interface Translator extends Component
  {
      /**
       * Role identifying Component
       */
      String ROLE = Translator.class.getName();
  
      /**
       * <code>getSupportedLanguages</code> returns an array of String
       * objects detailing which languages are supported for the given
       * key.
       *
       * @param key a <code>String</code> value identifying a translation
       * @return a <code>String[]</code> array containing available language
       * translations for the given key
       */
      String[] getSupportedLanguages( String key );
  
      /**
       * <code>getTranslation</code> obtains a translation for a given
       * key in a given language. The language parameter must be listed
       * in <code>getSupportedLanguages</code>.
       *
       * @param key a <code>String</code> value identifying a translation
       * @param language a <code>String</code> value identifying the language
       * @return translated text
       */
      String getTranslation( String key, String language );
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/components/TranslatorImpl.java
  
  Index: TranslatorImpl.java
  ===================================================================
  /*
  * 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.
  */
  package org.apache.excalibur.fortress.examples.components;
  
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Set;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  
  /**
   * Simple implementation of the <code>Translator</code> component, which
   * maintains a simple mapping of keys to translated values, created during
   * configuration.
   *
   * <p>
   * Configuration format:
   *
   * <pre>
   * &lt;translations&gt;
   *   &lt;entry key="hello-world"&gt;
   *    &lt;value language="Deutsch"&gt;Hallo Welt&lt;/value&gt;
   *    &lt;value language="English"&gt;Hello World&lt;/value&gt;
   *   &lt;/entry&gt;
   * &lt;/translations&gt;
   * </pre>
   * </p>
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/07/04 09:43:24 $
   */
  public class TranslatorImpl extends AbstractLogEnabled
      implements Translator, Configurable
  {
      // internal store of translation mappings
      private Map m_keys = new HashMap();
  
      /**
       * Configures this component. Reads configuration information
       * from container and appropriately sets up the internal mapping
       * array. Configuration syntax is specified in the class header.
       *
       * @param config <code>Configuration</code> details
       * @exception ConfigurationException if an error occurs
       */
      public void configure( Configuration config )
          throws ConfigurationException
      {
          if ( config != null )
          {
              Configuration[] entries =
                  config.getChild( "dictionary" ).getChildren( "translation" );
  
              for ( int i = 0; i < entries.length; ++i )
              {
                  String key = entries[ i ].getAttribute( "key" );
                  Configuration[] values = entries[ i ].getChildren( "value" );
  
                  Map translations = new HashMap();
  
                  for ( int j = 0; j < values.length; ++j )
                  {
                      translations.put(
                          values[ j ].getAttribute( "language" ),
                          values[ j ].getValue()
                      );
                  }
  
                  m_keys.put( key, translations );
              }
  
              if ( getLogger().isDebugEnabled() )
              {
                  getLogger().debug(
                      "Translator configured with " + m_keys.size() + " translations"
                  );
              }
          }
  
          else
          {
              if ( getLogger().isWarnEnabled() )
              {
                  getLogger().warn( "No configuration specified" );
              }
          }
      }
  
      /**
       * <code>getSupportedLanguages</code> returns an array of String
       * objects detailing which languages are supported for the given
       * key.
       *
       * @param key a <code>String</code> value identifying a translation
       * @return a <code>String[]</code> array containing available language
       * translations for the given key
       */
      public String[] getSupportedLanguages( String key )
      {
          Map translations = ( Map ) m_keys.get( key );
          Set keys = translations.keySet();
          return ( String[] ) keys.toArray( new String[] {} );
      }
  
      /**
       * <code>getTranslation</code> obtains a translation for a given
       * key in a given language. The language parameter must be listed
       * in <code>getSupportedLanguages</code>.
       *
       * @param key a <code>String</code> value identifying a translation
       * @param language a <code>String</code> value identifying the language
       * @return translated text
       */
      public String getTranslation( String key, String language )
      {
          Map translationMap = ( Map ) m_keys.get( key );
          return ( String ) translationMap.get( language );
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/swing/SwingContainer.java
  
  Index: SwingContainer.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.excalibur.fortress.examples.swing;
  
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.Dimension;
  import javax.swing.JFrame;
  import javax.swing.JComboBox;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  
  import org.apache.excalibur.fortress.AbstractContainer;
  import org.apache.excalibur.fortress.examples.components.Translator;
  
  /**
   * Simple Fortress based container containing a Swing implementation of Hello World.
   * This container creates a small Swing based GUI displaying a combobox of available
   * languages from the translator component.
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/07/04 09:43:24 $
   */
  public final class SwingContainer extends AbstractContainer
      implements Startable, ActionListener
  {
      // Component references
      private ComponentManager m_manager;
      private Translator m_translator;
  
      // GUI references
      private JFrame m_frame;
      private JLabel m_label;
  
      // Dictionary key
      private String m_key = "hello-world";
  
      /**
       * Compose this component. Stores reference to component manager
       * and translator component.
       *
       * @param manager a <code>ComponentManager</code> instance
       * @exception ComponentException if an error occurs
       */
      public void compose(ComponentManager manager)
  	    throws ComponentException
      {
          super.compose(manager);
  
          // REVISIT: this shouldn't be in compose ? where's the right place ?
          m_manager = getComponentManager();
          m_translator = ( Translator ) m_manager.lookup( Translator.ROLE );
      }
  
      /**
       * Initializes this component. Creates simple Swing GUI containing
       * available translations for the key 'hello-world'.
       *
       * @exception Exception if an error occurs
       */
      public void initialize()
  	    throws Exception
      {
          super.initialize();
  
  	// REVISIT: this should be done elsewhere
          m_manager = getComponentManager();
          m_translator = ( Translator ) m_manager.lookup( Translator.ROLE );
  
          // create combo box
          JComboBox cb = new JComboBox( m_translator.getSupportedLanguages( m_key ) );
          cb.addActionListener( this );
  
          // create label
          m_label = new JLabel( "Select your language" );
          m_label.setPreferredSize( new Dimension( 150, 30 ) );
  
          // create panel holding box and label
          JPanel panel = new JPanel();
          panel.add( cb );
          panel.add( m_label );
  
          // create main frame
          m_frame = new JFrame( "Hello World!" );
          m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          m_frame.setContentPane( panel );
          m_frame.pack();
  
          // all done
          if ( getLogger().isDebugEnabled() )
          {
              getLogger().debug( "Initialized" );
          }
      }
  
      /**
       * Starts the component, makes GUI visible, ready for use.
       */
      public void start()
      {
          m_frame.setVisible( true );
  
          if ( getLogger().isDebugEnabled() )
          {
              getLogger().debug( "GUI Activated" );
          }
      }
  
      /**
       * Stops component, make GUI invisible, ready for decomissioning.
       */
      public void stop()
      {
          m_frame.setVisible( false );
  
          if ( getLogger().isDebugEnabled() )
          {
              getLogger().debug( "GUI Disactivated" );
          }
      }
  
      /**
       * Method called when the user changes the selected item in the
       * combobox.
       *
       * @param evt an <code>ActionEvent</code> instance
       */
      public void actionPerformed( ActionEvent evt )
      {
          JComboBox cb = ( JComboBox ) evt.getSource();
          String selected = ( String ) cb.getSelectedItem();
  
          m_label.setText( m_translator.getTranslation( m_key, selected ) );
  
          if ( getLogger().isDebugEnabled() )
          {
              getLogger().debug( "Language changed to " + selected );
          }
      }
  
      /**
       * Cleans up references to retrieved components.
       */
      public void dispose()
      {
          super.dispose();
  
          if ( m_translator != null )
              m_manager.release( m_translator );
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/swing/SwingContainer.roles
  
  Index: SwingContainer.roles
  ===================================================================
  <fortress-roles>
  
    <role name="org.apache.excalibur.fortress.examples.components.Translator">
      <component shorthand="translator"
                 class="org.apache.excalibur.fortress.examples.components.TranslatorImpl"
                 handler="org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler"/>
    </role>
  
  </fortress-roles>
  
  
  
  
  1.1                  jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/swing/SwingContainer.xconf
  
  Index: SwingContainer.xconf
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1" ?>
  
  <!-- Example Fortress configuration file.
  
       This file contains sample component configurations for the Fortress 'swing'
       example.
   -->
  <fortress-example>
  
    <!-- Simple translation component. This component maintains translations for a
         given key in different languages.
     -->
    <translator id="translator" logger="translator">
  	<dictionary>
  	  <translation key="hello-world">
  	    <value language="Deutsch">Hallo Welt</value>
  	    <value language="English">Hello World</value>
  	    <value language="Franšais">Bonjour la monde</value>
  	    <value language="Indonesia">Apa kabar Dunia</value>
  	    <value language="Espan§l">Hola Mundo</value>
  	    <value language="Italiano">Ciao Mondo</value>
  	  </translation>
  	</dictionary>
    </translator>
  
  </fortress-example>
  
  
  
  
  1.1                  jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/swing/SwingContainer.xlog
  
  Index: SwingContainer.xlog
  ===================================================================
  <logkit>
      <factories>
        <factory type="file" class="org.apache.avalon.excalibur.logger.factory.FileTargetFactory"/>
      </factories>
  
      <targets>
         <file id="root">
          <filename>fortress-examples.log</filename>
          <format type="extended">
            %7.7{priority} %5.5{time}   [%8.8{category}] (%{context}): %{message}\n%{throwable}
          </format>
         </file>
       </targets>
  
       <categories>
         <category name="" log-level="DEBUG">
           <log-target id-ref="root"/>
         </category>
       </categories>
  
  </logkit>
  
  
  
  1.1                  jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/swing/swing.java
  
  Index: swing.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.excalibur.fortress.examples.swing;
  
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.avalon.framework.logger.LogKitLogger;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.excalibur.fortress.ContainerManager;
  import org.apache.excalibur.fortress.DefaultContainerManager;
  import org.apache.excalibur.fortress.util.ContextBuilder;
  import org.apache.excalibur.fortress.util.ContextManager;
  
  /**
   * Fortress container example.
   *
   * @author <a href="mailto:crafterm@apache.org">Marcus Crafter</a>
   * @version $Id: swing.java,v 1.1 2002/07/04 09:43:24 crafterm Exp $
   */
  public final class swing
  {
      // container reference
      private final SwingContainer m_container;
  
      /**
       * Constructor, creates a <code>SwingContainer</code> instance.
       *
       * @exception Exception if an error occurs
       */
      public swing()
          throws Exception
      {
          ContextBuilder contextBuilder = new ContextBuilder();
          contextBuilder.setContainerClass( "org.apache.excalibur.fortress.examples.swing.SwingContainer"
);
          contextBuilder.setContextDirectory( "./" );
          contextBuilder.setWorkDirectory( "./" );
          contextBuilder.setContainerConfiguration( "resource://org/apache/excalibur/fortress/examples/swing/SwingContainer.xconf"
);
          contextBuilder.setLoggerManagerConfiguration( "resource://org/apache/excalibur/fortress/examples/swing/SwingContainer.xlog"
);
          contextBuilder.setRoleManagerConfiguration( "resource://org/apache/excalibur/fortress/examples/swing/SwingContainer.roles"
);
  
          ContextManager contextManager = new ContextManager( contextBuilder.getContext(),
null );
          contextManager.initialize();
  
          ContainerManager cm = new DefaultContainerManager( contextManager );
          cm.initialize();
  
          m_container = ( SwingContainer ) cm.getContainer();
      }
  
      /**
       * Start the show. Creates a single <code>swing</code> object that has a
       * reference to <code>SwingContainer</code>.
       *
       * @param args a <code>String[]</code> array of command line arguments
       * @exception Exception if an error occurs
       */
      public static final void main( String[] args )
          throws Exception
      {
          swing s = new swing();
      }
  }
  
  
  
  

--
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