leosimons 2003/01/28 13:19:19 Modified: fortress/examples/bin runextended.bat runextended.sh runswing.bat runswing.sh runviewer.bat runviewer.sh fortress/examples build.xml fortress/examples/conf web.xml fortress/src/java/org/apache/avalon/fortress/impl AbstractContainer.java fortress/src/test/org/apache/avalon/fortress/test ContainerProfile.java HandlersTestCase.java fortress/src/test/org/apache/avalon/fortress/test/util ConfigurableRoleManagerTestCase.java FortressRoleManagerTestCase.java fortress/src/xdocs servlet.xml Added: fortress/examples/src/java/org/apache/avalon/fortress/examples/components Translator.java TranslatorImpl.java TranslatorImpl.xinfo fortress/examples/src/java/org/apache/avalon/fortress/examples/extended ExtendedContainer.java ExtendedContainer.roles ExtendedContainer.xconf ExtendedContainer.xlog Main.java fortress/examples/src/java/org/apache/avalon/fortress/examples/extended/components ExtendedComponent.java ExtendedComponentImpl.java fortress/examples/src/java/org/apache/avalon/fortress/examples/extended/extensions Extensions.java SecurityManageable.java fortress/examples/src/java/org/apache/avalon/fortress/examples/servlet ServletContainer.java ServletContainer.roles ServletContainer.xconf ServletContainer.xlog servlet.java fortress/examples/src/java/org/apache/avalon/fortress/examples/swing Main.java SwingContainer.instruments SwingContainer.java SwingContainer.roles SwingContainer.xconf SwingContainer.xinfo SwingContainer.xlog fortress/examples/src/java/org/apache/avalon/fortress/examples/viewer ComponentViewer.java ComponentViewer.roles ComponentViewer.xconf ComponentViewer.xlog Main.java Removed: fortress/examples/src/java/org/apache/excalibur/fortress/examples/components Translator.java TranslatorImpl.java TranslatorImpl.xinfo fortress/examples/src/java/org/apache/excalibur/fortress/examples/extended ExtendedContainer.java ExtendedContainer.roles Log: Complete refactoring of fortress. Test run ok, as do the examples. Gump will tell of any problems :D Main thing to remove now is the "ng" directory. Revision Changes Path 1.2 +1 -1 jakarta-avalon-excalibur/fortress/examples/bin/runextended.bat Index: runextended.bat =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/bin/runextended.bat,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- runextended.bat 9 Jan 2003 01:55:14 -0000 1.1 +++ runextended.bat 28 Jan 2003 21:19:16 -0000 1.2 @@ -58,6 +58,6 @@ set CP=%CP%%_LIBJARS% rem Run the example application -%EXAMPLE_JAVACMD% -Djava.compiler="NONE" -classpath "%CP%" org.apache.excalibur.fortress.examples.extended.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 +%EXAMPLE_JAVACMD% -Djava.compiler="NONE" -classpath "%CP%" org.apache.avalon.fortress.examples.extended.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 :end 1.3 +1 -1 jakarta-avalon-excalibur/fortress/examples/bin/runextended.sh Index: runextended.sh =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/bin/runextended.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- runextended.sh 16 Jan 2003 21:29:35 -0000 1.2 +++ runextended.sh 28 Jan 2003 21:19:16 -0000 1.3 @@ -41,5 +41,5 @@ echo $CP # Run the example application -$JAVACMD -classpath "$CP" org.apache.excalibur.fortress.examples.extended.Main $@ +$JAVACMD -classpath "$CP" org.apache.avalon.fortress.examples.extended.Main $@ 1.3 +1 -1 jakarta-avalon-excalibur/fortress/examples/bin/runswing.bat Index: runswing.bat =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/bin/runswing.bat,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- runswing.bat 4 Aug 2002 01:19:07 -0000 1.2 +++ runswing.bat 28 Jan 2003 21:19:16 -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.excalibur.fortress.examples.swing.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 +%EXAMPLE_JAVACMD% -Djava.compiler="NONE" -classpath "%CP%" org.apache.avalon.fortress.examples.swing.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 :end 1.3 +1 -1 jakarta-avalon-excalibur/fortress/examples/bin/runswing.sh Index: runswing.sh =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/bin/runswing.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- runswing.sh 16 Jan 2003 21:29:35 -0000 1.2 +++ runswing.sh 28 Jan 2003 21:19:16 -0000 1.3 @@ -41,5 +41,5 @@ echo $CP # Run the example application -$JAVACMD -classpath "$CP" org.apache.excalibur.fortress.examples.swing.Main $@ +$JAVACMD -classpath "$CP" org.apache.avalon.fortress.examples.swing.Main $@ 1.2 +1 -1 jakarta-avalon-excalibur/fortress/examples/bin/runviewer.bat Index: runviewer.bat =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/bin/runviewer.bat,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- runviewer.bat 9 Jan 2003 01:55:14 -0000 1.1 +++ runviewer.bat 28 Jan 2003 21:19:16 -0000 1.2 @@ -58,6 +58,6 @@ set CP=%CP%%_LIBJARS% rem Run the example application -%EXAMPLE_JAVACMD% -Djava.compiler="NONE" -classpath "%CP%" org.apache.excalibur.fortress.examples.viewer.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 +%EXAMPLE_JAVACMD% -Djava.compiler="NONE" -classpath "%CP%" org.apache.avalon.fortress.examples.viewer.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 :end 1.3 +1 -1 jakarta-avalon-excalibur/fortress/examples/bin/runviewer.sh Index: runviewer.sh =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/bin/runviewer.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- runviewer.sh 16 Jan 2003 21:29:35 -0000 1.2 +++ runviewer.sh 28 Jan 2003 21:19:16 -0000 1.3 @@ -41,5 +41,5 @@ echo $CP # Run the example application -$JAVACMD -classpath "$CP" org.apache.excalibur.fortress.examples.viewer.Main $@ +$JAVACMD -classpath "$CP" org.apache.avalon.fortress.examples.viewer.Main $@ 1.14 +3 -3 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- build.xml 21 Jan 2003 13:30:50 -0000 1.13 +++ build.xml 28 Jan 2003 21:19:17 -0000 1.14 @@ -202,7 +202,7 @@ basedir="${build.classes.dir}" includes="**/*.*"> <manifest> - <attribute name="Main-Class" value="org.apache.excalibur.fortress.examples.viewer.Main"/> + <attribute name="Main-Class" value="org.apache.avalon.fortress.examples.viewer.Main"/> <attribute name="Class-Path" value="logkit.jar avalon-framework.jar excalibur-fortress-complete-1.0.jar util.concurrent-1.3.1.jar commons-collections-2.1.jar"/> </manifest> </jar> @@ -211,7 +211,7 @@ basedir="${build.classes.dir}" includes="**/*.*"> <manifest> - <attribute name="Main-Class" value="org.apache.excalibur.fortress.examples.swing.Main"/> + <attribute name="Main-Class" value="org.apache.avalon.fortress.examples.swing.Main"/> <attribute name="Class-Path" value="logkit.jar avalon-framework.jar excalibur-fortress-complete-1.0.jar util.concurrent-1.3.1.jar commons-collections-2.1.jar"/> </manifest> </jar> @@ -220,7 +220,7 @@ basedir="${build.classes.dir}" includes="**/*.*"> <manifest> - <attribute name="Main-Class" value="org.apache.excalibur.fortress.examples.extended.Main"/> + <attribute name="Main-Class" value="org.apache.avalon.fortress.examples.extended.Main"/> <attribute name="Class-Path" value="logkit.jar avalon-framework.jar excalibur-fortress-complete-1.0.jar util.concurrent-1.3.1.jar commons-collections-2.1.jar"/> </manifest> </jar> 1.2 +2 -2 jakarta-avalon-excalibur/fortress/examples/conf/web.xml Index: web.xml =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/conf/web.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- web.xml 4 Jul 2002 10:23:59 -0000 1.1 +++ web.xml 28 Jan 2003 21:19:17 -0000 1.2 @@ -15,7 +15,7 @@ <servlet> <servlet-name>ServletContainer</servlet-name> - <servlet-class>org.apache.excalibur.fortress.examples.servlet.servlet</servlet-class> + <servlet-class>org.apache.avalon.fortress.examples.servlet.servlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> 1.4 +2 -2 jakarta-avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/AbstractContainer.java Index: AbstractContainer.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/AbstractContainer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AbstractContainer.java 27 Jan 2003 21:11:43 -0000 1.3 +++ AbstractContainer.java 28 Jan 2003 21:19:17 -0000 1.4 @@ -526,7 +526,7 @@ * not vital to operation, it should be possible to recover gracefully */ public void initialize() - throws CompositeException + throws CompositeException, Exception { // go over all components final Iterator i = m_components.iterator(); 1.2 +4 -4 jakarta-avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/test/ContainerProfile.java Index: ContainerProfile.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/test/ContainerProfile.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ContainerProfile.java 27 Jan 2003 17:04:47 -0000 1.1 +++ ContainerProfile.java 28 Jan 2003 21:19:17 -0000 1.2 @@ -141,9 +141,9 @@ config.setContextDirectory( "./" ); config.setWorkDirectory( "./tmp" ); config.setContainerClass( DefaultContainer.class ); - config.setContainerConfiguration( "resource://org/apache/excalibur/fortress/test/ContainerProfile.xconf" ); - config.setLoggerManagerConfiguration( "resource://org/apache/excalibur/fortress/test/ContainerProfile.xlog" ); - config.setRoleManagerConfiguration( "resource://org/apache/excalibur/fortress/test/ContainerProfile.roles" ); + config.setContainerConfiguration( "resource://org/apache/avalon/fortress/test/ContainerProfile.xconf" ); + config.setLoggerManagerConfiguration( "resource://org/apache/avalon/fortress/test/ContainerProfile.xlog" ); + config.setRoleManagerConfiguration( "resource://org/apache/avalon/fortress/test/ContainerProfile.roles" ); final ContainerManager cm = new DefaultContainerManager( config.getContext(), new NullLogger() ); 1.2 +2 -2 jakarta-avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/test/HandlersTestCase.java Index: HandlersTestCase.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/test/HandlersTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HandlersTestCase.java 27 Jan 2003 17:04:47 -0000 1.1 +++ HandlersTestCase.java 28 Jan 2003 21:19:17 -0000 1.2 @@ -175,7 +175,7 @@ final FortressConfig config = new FortressConfig(); config.setContextDirectory( "./" ); config.setWorkDirectory( "./" ); - final String BASE = "resource://org/apache/excalibur/fortress/test/data/"; + final String BASE = "resource://org/apache/avalon/fortress/test/data/"; config.setContainerConfiguration( BASE + "test1.xconf" ); config.setLoggerManagerConfiguration( BASE + "test1.xlog" ); config.setRoleManagerConfiguration( BASE + "test1.roles" ); 1.2 +5 -5 jakarta-avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/test/util/ConfigurableRoleManagerTestCase.java Index: ConfigurableRoleManagerTestCase.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/test/util/ConfigurableRoleManagerTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ConfigurableRoleManagerTestCase.java 27 Jan 2003 17:04:49 -0000 1.1 +++ ConfigurableRoleManagerTestCase.java 28 Jan 2003 21:19:17 -0000 1.2 @@ -77,23 +77,23 @@ ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() ); roles.enableLogging( new ConsoleLogger( ConsoleLogger.LEVEL_INFO ) ); roles.configure( builder.build( this.getClass().getClassLoader() - .getResourceAsStream( "org/apache/excalibur/fortress/test/ContainerProfile.roles" ) ) ); + .getResourceAsStream( "org/apache/avalon/fortress/test/ContainerProfile.roles" ) ) ); checkRole( roles, "datasource", "org.apache.avalon.excalibur.datasource.DataSourceComponent", "org.apache.avalon.excalibur.datasource.JdbcDataSource", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); checkRole( roles, "monitor", "org.apache.avalon.excalibur.monitor.Monitor", "org.apache.avalon.excalibur.monitor.ActiveMonitor", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); checkRole( roles, "parser", "org.apache.excalibur.xml.dom.DOMParser", "org.apache.excalibur.xml.impl.JaxpParser", - "org.apache.excalibur.fortress.handler.PoolableComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.PoolableComponentHandler" ); } } 1.2 +13 -13 jakarta-avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/test/util/FortressRoleManagerTestCase.java Index: FortressRoleManagerTestCase.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/test/util/FortressRoleManagerTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FortressRoleManagerTestCase.java 27 Jan 2003 17:04:49 -0000 1.1 +++ FortressRoleManagerTestCase.java 28 Jan 2003 21:19:17 -0000 1.2 @@ -86,65 +86,65 @@ "cache", "org.apache.excalibur.cache.Cache", "org.apache.excalibur.cache.impl.DefaultCache", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); checkRole( roles, "lru-cache", "org.apache.excalibur.cache.Cache", "org.apache.excalibur.cache.impl.LRUCache", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); checkRole( roles, "jdbc-datasource", "org.apache.avalon.excalibur.datasource.DataSourceComponent", "org.apache.avalon.excalibur.datasource.JdbcDataSource", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); checkRole( roles, "j2ee-datasource", "org.apache.avalon.excalibur.datasource.DataSourceComponent", "org.apache.avalon.excalibur.datasource.J2eeDataSource", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); if( isInformixClassExists() ) { checkRole( roles, "informix-datasource", "org.apache.avalon.excalibur.datasource.DataSourceComponent", "org.apache.avalon.excalibur.datasource.InformixDataSource", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); } checkRole( roles, "monitor", "org.apache.avalon.excalibur.monitor.Monitor", "org.apache.avalon.excalibur.monitor.ActiveMonitor", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); checkRole( roles, "passive-monitor", "org.apache.avalon.excalibur.monitor.Monitor", "org.apache.avalon.excalibur.monitor.PassiveMonitor", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); checkRole( roles, "xalan-xpath", "org.apache.excalibur.xml.xpath.XPathProcessor", "org.apache.excalibur.xml.xpath.XPathProcessorImpl", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); checkRole( roles, "jaxpath", "org.apache.excalibur.xml.xpath.XPathProcessor", "org.apache.excalibur.xml.xpath.JaxenProcessorImpl", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); checkRole( roles, "resolver", "org.apache.excalibur.source.SourceResolver", "org.apache.excalibur.source.impl.SourceResolverImpl", - "org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" ); checkRole( roles, "parser", "org.apache.excalibur.xml.dom.DOMParser", "org.apache.excalibur.xml.impl.JaxpParser", - "org.apache.excalibur.fortress.handler.PerThreadComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.PerThreadComponentHandler" ); checkRole( roles, "xerces-parser", "org.apache.excalibur.xml.dom.DOMParser", "org.apache.excalibur.xml.impl.XercesParser", - "org.apache.excalibur.fortress.handler.FactoryComponentHandler" ); + "org.apache.avalon.fortress.impl.handler.FactoryComponentHandler" ); } } 1.2 +1 -1 jakarta-avalon-excalibur/fortress/src/xdocs/servlet.xml Index: servlet.xml =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/src/xdocs/servlet.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- servlet.xml 24 Jan 2003 04:34:18 -0000 1.1 +++ servlet.xml 28 Jan 2003 21:19:17 -0000 1.2 @@ -45,7 +45,7 @@ try { final FortressConfig config = new FortressConfig(); - config.setContainerClass( "org.apache.excalibur.fortress.examples.servlet.ServletContainer" ); + config.setContainerClass( "org.apache.avalon.fortress.examples.servlet.ServletContainer" ); config.setContextDirectory( "./" ); config.setWorkDirectory( "./" ); config.setContainerConfiguration( "resource://org/apache/excalibur/fortress/examples/servlet/ServletContainer.xconf" ); 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/components/Translator.java Index: Translator.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.components; /** * Translator component. This component provides simple translations of given * keys, identified by language name. * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/28 21:19:18 $ */ public interface Translator { /** * 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/avalon/fortress/examples/components/TranslatorImpl.java Index: TranslatorImpl.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.components; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable; import org.apache.excalibur.instrument.CounterInstrument; /** * 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> * <translations> * <entry key="hello-world"> * <value language="Deutsch">Hallo Welt</value> * <value language="English">Hello World</value> * </entry> * </translations> * </pre> * </p> * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/28 21:19:18 $ */ public class TranslatorImpl extends org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable implements org.apache.avalon.fortress.examples.components.Translator, org.apache.avalon.framework.configuration.Configurable { // Instrument to count the number of translations performed private org.apache.excalibur.instrument.CounterInstrument m_translationsInstrument; // internal store of translation mappings private java.util.Map m_keys = new java.util.HashMap(); /** * Create a new TranslatorImpl. */ public TranslatorImpl() { addInstrument( m_translationsInstrument = new org.apache.excalibur.instrument.CounterInstrument( "translations" ) ); } /** * 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 org.apache.avalon.framework.configuration.ConfigurationException if an error occurs */ public void configure( org.apache.avalon.framework.configuration.Configuration config ) throws org.apache.avalon.framework.configuration.ConfigurationException { if( config != null ) { org.apache.avalon.framework.configuration.Configuration[] entries = config.getChild( "dictionary" ).getChildren( "translation" ); for( int i = 0; i < entries.length; ++i ) { String key = entries[ i ].getAttribute( "key" ); org.apache.avalon.framework.configuration.Configuration[] values = entries[ i ].getChildren( "value" ); java.util.Map translations = new java.util.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 ) { java.util.Map translations = (java.util.Map)m_keys.get( key ); java.util.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 ) { // Notify the Instrument Manager m_translationsInstrument.increment(); java.util.Map translationMap = (java.util.Map)m_keys.get( key ); return (String)translationMap.get( language ); } } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/components/TranslatorImpl.xinfo Index: TranslatorImpl.xinfo =================================================================== <?xml version="1.0"?> <!DOCTYPE component-info PUBLIC "-//AVALON/Component Info DTD Version 1.0//EN" "http://jakarta.apache.org/avalon/componentinfo_1_0.dtd" > <component-info> <component> <name>translator</name> </component> <services> <service> <service-ref type="org.apache.avalon.fortress.examples.components.Translator"/> </service> </services> </component-info> 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/extended/ExtendedContainer.java Index: ExtendedContainer.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.extended; import org.apache.avalon.fortress.impl.DefaultContainer; import org.apache.avalon.fortress.examples.extended.components.ExtendedComponent; import org.apache.avalon.fortress.examples.extended.extensions.Extensions; public final class ExtendedContainer extends org.apache.avalon.fortress.impl.DefaultContainer { public void initialize() throws Exception { super.initialize(); m_extManager.addAccessorExtension( new org.apache.avalon.fortress.examples.extended.extensions.Extensions() ); } public void doLookups() throws Exception { getLogger().info( "Starting lookup of custom component" ); for( int i = 0; i < 10; ++i ) { org.apache.avalon.fortress.examples.extended.components.ExtendedComponent comp = (org.apache.avalon.fortress.examples.extended.components.ExtendedComponent)m_serviceManager.lookup( org.apache.avalon.fortress.examples.extended.components.ExtendedComponent.ROLE ); m_serviceManager.release( comp ); } getLogger().info( "Finished lookups of custom component" ); } } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/extended/ExtendedContainer.roles Index: ExtendedContainer.roles =================================================================== <test> <role name="org.apache.avalon.fortress.examples.extended.components.ExtendedComponent"> <component shorthand="extended-component" class="org.apache.avalon.fortress.examples.extended.components.ExtendedComponentImpl" handler="org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler"/> </role> </test> 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/extended/ExtendedContainer.xconf Index: ExtendedContainer.xconf =================================================================== <test> <component id="extended-component" class="org.apache.avalon.fortress.examples.extended.components.ExtendedComponentImpl" logger="extended-component"> </component> </test> 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/extended/ExtendedContainer.xlog Index: ExtendedContainer.xlog =================================================================== <logkit> <factories> <factory type="file" class="org.apache.avalon.excalibur.logger.factory.FileTargetFactory"/> </factories> <targets> <file id="root"> <filename>fortress-extensions.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/avalon/fortress/examples/extended/Main.java Index: Main.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.extended; import org.apache.avalon.framework.container.ContainerUtil; import org.apache.avalon.fortress.ContainerManager; import org.apache.avalon.fortress.impl.DefaultContainerManager; import org.apache.avalon.fortress.util.FortressConfig; /** * Fortress container example with custom extensions * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version $Id: Main.java,v 1.1 2003/01/28 21:19:18 leosimons Exp $ */ public final class Main { // container reference private static org.apache.avalon.fortress.examples.extended.ExtendedContainer m_container; /** * @param args a <code>String[]</code> array of command line arguments * @exception java.lang.Exception if an error occurs */ public static final void main( String[] args ) throws Exception { org.apache.avalon.fortress.util.FortressConfig config = new org.apache.avalon.fortress.util.FortressConfig(); config.setContainerClass( "org.apache.avalon.fortress.examples.extended.ExtendedContainer" ); config.setContextDirectory( "./" ); config.setWorkDirectory( "./" ); config.setContainerConfiguration( "resource://org/apache/avalon/fortress/examples/extended/ExtendedContainer.xconf" ); config.setLoggerManagerConfiguration( "resource://org/apache/avalon/fortress/examples/extended/ExtendedContainer.xlog" ); config.setRoleManagerConfiguration( "resource://org/apache/avalon/fortress/examples/extended/ExtendedContainer.roles" ); final org.apache.avalon.fortress.ContainerManager cm = new org.apache.avalon.fortress.impl.DefaultContainerManager( config.getContext() ); org.apache.avalon.framework.container.ContainerUtil.initialize( cm ); m_container = (org.apache.avalon.fortress.examples.extended.ExtendedContainer)cm.getContainer(); m_container.doLookups(); org.apache.avalon.framework.container.ContainerUtil.dispose( cm ); } } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/extended/components/ExtendedComponent.java Index: ExtendedComponent.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.extended.components; /** * Simple <code>TestComponent</code> component for testing custom extensions * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/28 21:19:18 $ */ public interface ExtendedComponent { /** * Component <code>ROLE</code> */ String ROLE = ExtendedComponent.class.getName(); } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/extended/components/ExtendedComponentImpl.java Index: ExtendedComponentImpl.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.extended.components; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.fortress.examples.extended.extensions.SecurityManageable; /** * <code>TestComponentImpl</code>, demonstrating the use of a custom * lifecycle stage <code>SecurityManageable</code>. This code does * a simple access check for several files on the file system and logs * the results accordingly. * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/28 21:19:18 $ */ public class ExtendedComponentImpl extends org.apache.avalon.framework.logger.AbstractLogEnabled implements org.apache.avalon.fortress.examples.extended.components.ExtendedComponent, org.apache.avalon.fortress.examples.extended.extensions.SecurityManageable { /** * Pass a SecurityManager object to the component * * @param manager a <code>SecurityManager</code> value */ public void secure( final SecurityManager manager ) throws SecurityException { getLogger().debug( "Received SecurityManager instance: " + manager ); final String[] files = {"/tmp", "/vmlinuz", "/usr/lib/libc.a"}; for( int i = 0; i < files.length; ++i ) { try { manager.checkRead( files[ i ] ); getLogger().info( "Thread can read " + files[ i ] ); } catch( SecurityException e ) { getLogger().info( "Thread can not read " + files[ i ] ); } } } } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/extended/extensions/Extensions.java Index: Extensions.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.extended.extensions; import org.apache.avalon.framework.context.Context; import org.apache.excalibur.container.lifecycle.AbstractAccessor; /** * Some custom extensions for this container's components. * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/28 21:19:18 $ */ public class Extensions extends org.apache.excalibur.container.lifecycle.AbstractAccessor { /** * Access, called when the given component is being * accessed (ie. via lookup() or select()). * * @param component a <code>Component</code> instance * @param context a <code>Context</code> instance * @exception java.lang.Exception if an error occurs */ public void access( Object component, org.apache.avalon.framework.context.Context context ) throws Exception { if( component instanceof SecurityManageable ) { // pass in a simple security manager for testing, a real // system might want to pass in specialized/custom security managers ( (SecurityManageable)component ).secure( new SecurityManager() ); } } } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/extended/extensions/SecurityManageable.java Index: SecurityManageable.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.extended.extensions; /** * Simple custom lifecycle extension interface for supplying a component * with a security manager. * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/28 21:19:18 $ */ public interface SecurityManageable { /** * Pass a SecurityManager object to the component * * @param manager a <code>SecurityManager</code> value */ void secure( SecurityManager manager ) throws SecurityException; } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/servlet/ServletContainer.java Index: ServletContainer.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import org.apache.avalon.fortress.impl.DefaultContainer; import org.apache.avalon.fortress.examples.components.Translator; /** * Fortress based servlet example. Presents a simple page to the user * displaying the possible languages they can see the text 'hello world' * written in. * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/28 21:19:18 $ */ public final class ServletContainer extends org.apache.avalon.fortress.impl.DefaultContainer { public static final String KEY = "hello-world"; private org.apache.avalon.fortress.examples.components.Translator m_translator; /** * Initializes this component. * * @exception java.lang.Exception if an error occurs */ public void initialize() throws Exception { super.initialize(); m_translator = (org.apache.avalon.fortress.examples.components.Translator)m_serviceManager.lookup( org.apache.avalon.fortress.examples.components.Translator.ROLE ); } /** * Simple method to handle requests sent to the container from the * controlling servlet. This container simply displays a page containing * a list of possible languages the user can see the text 'hello world' * written in. * * @param request a <code>ServletRequest</code> instance * @param response a <code>ServletResponse</code> instance * @exception ServletException if a servlet error occurs * @exception java.io.IOException if an IO error occurs */ public void handleRequest( ServletRequest request, ServletResponse response ) throws ServletException, java.io.IOException { java.io.PrintWriter out = response.getWriter(); String selected = request.getParameter( "language" ); String[] languages = m_translator.getSupportedLanguages( KEY ); out.println( "<html>" ); out.println( "<head><title>Hello World!</title></head>" ); out.println( "<body>" ); out.println( "<hr>" ); out.println( "<h1>" ); if( selected == null ) { out.println( "Please select your language" ); } else { out.println( m_translator.getTranslation( KEY, selected ) ); } out.println( "</h1>" ); out.println( "<hr>" ); out.println( "Available languages:" ); out.println( "<form action='' name='languagelist'>" ); out.println( "<select size='1' name='language'>" ); for( int i = 0; i < languages.length; ++i ) { String lang = languages[ i ]; out.print( "<option value='" + lang + "'" ); // preselect chosen language if( lang.equals( selected ) ) { out.print( " selected" ); } out.println( ">" + lang + "</option>" ); } out.println( "</select>" ); out.println( "<input value='OK' type='submit'>" ); out.println( "</form>" ); out.println( "</body>" ); out.println( "</html>" ); out.close(); } /** * Release resources */ public void dispose() { if( m_translator != null ) m_serviceManager.release( m_translator ); super.dispose(); } } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/servlet/ServletContainer.roles Index: ServletContainer.roles =================================================================== <fortress-roles> <role name="org.apache.avalon.fortress.examples.components.Translator"> <component shorthand="translator" class="org.apache.avalon.fortress.examples.components.TranslatorImpl" handler="org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler"/> </role> </fortress-roles> 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/servlet/ServletContainer.xconf Index: ServletContainer.xconf =================================================================== <?xml version="1.0" encoding="iso-8859-1" ?> <!-- Example Fortress configuration file. This file contains sample component configurations for the Fortress 'servlet' 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/avalon/fortress/examples/servlet/ServletContainer.xlog Index: ServletContainer.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/avalon/fortress/examples/servlet/servlet.java Index: servlet.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import org.apache.avalon.framework.container.ContainerUtil; import org.apache.avalon.fortress.ContainerManager; import org.apache.avalon.fortress.impl.DefaultContainerManager; import org.apache.avalon.fortress.util.FortressConfig; /** * Servlet based Fortress container example. * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version $Id: servlet.java,v 1.1 2003/01/28 21:19:18 leosimons Exp $ */ public final class servlet extends HttpServlet { private ServletContainer m_container; private org.apache.avalon.fortress.ContainerManager m_containerManager; /** * Initializes Servlet and creates a <code>ServletContainer</code> instance * * @exception ServletException if an error occurs */ public void init() throws ServletException { super.init(); try { final org.apache.avalon.fortress.util.FortressConfig config = new org.apache.avalon.fortress.util.FortressConfig(); config.setContainerClass( "org.apache.avalon.fortress.examples.servlet.ServletContainer" ); config.setContextDirectory( "./" ); config.setWorkDirectory( "./" ); config.setContainerConfiguration( "resource://org/apache/avalon/fortress/examples/servlet/ServletContainer.xconf" ); config.setLoggerManagerConfiguration( "resource://org/avalon/excalibur/fortress/examples/servlet/ServletContainer.xlog" ); config.setRoleManagerConfiguration( "resource://org/avalon/excalibur/fortress/examples/servlet/ServletContainer.roles" ); m_containerManager = new org.apache.avalon.fortress.impl.DefaultContainerManager( config.getContext() ); org.apache.avalon.framework.container.ContainerUtil.initialize(m_containerManager); m_container = (ServletContainer)m_containerManager.getContainer(); } catch( Exception e ) { throw new ServletException( "Error during initialization", e ); } } /** * Pass all servlet requests through to container to be handled. In a more * complex system, there could be multiple containers that handle different * requests, or a main controlling container with subcontainers for different * requests. * * @param request a <code>ServletRequest</code> instance * @param response a <code>ServletResponse</code> instance * @exception java.io.IOException if an IO error occurs * @exception ServletException if a servlet error occurs */ public void service( ServletRequest request, ServletResponse response ) throws java.io.IOException, ServletException { m_container.handleRequest( request, response ); } /** * Disposes of container manager and container instance. */ public void destroy() { org.apache.avalon.framework.container.ContainerUtil.dispose(m_containerManager); } } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/swing/Main.java Index: Main.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.swing; import org.apache.avalon.framework.container.ContainerUtil; import org.apache.avalon.fortress.ContainerManager; import org.apache.avalon.fortress.impl.DefaultContainerManager; import org.apache.avalon.fortress.util.FortressConfig; /** * Fortress container example. * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version $Id: Main.java,v 1.1 2003/01/28 21:19:18 leosimons Exp $ */ public final class Main { /** * Start the show. Creates a <code>SwingContainer</code>. * * @param args a <code>String[]</code> array of command line arguments * @exception java.lang.Exception if an error occurs */ public static void main( String[] args ) throws Exception { // Set up all the preferences for Fortress final org.apache.avalon.fortress.util.FortressConfig config = new org.apache.avalon.fortress.util.FortressConfig(); config.setContainerClass( "org.apache.avalon.fortress.examples.swing.SwingContainer" ); config.setContextDirectory( "./" ); config.setWorkDirectory( "./" ); config.setContainerConfiguration( "resource://org/apache/avalon/fortress/examples/swing/SwingContainer.xconf" ); config.setLoggerManagerConfiguration( "resource://org/apache/avalon/fortress/examples/swing/SwingContainer.xlog" ); config.setRoleManagerConfiguration( "resource://org/apache/avalon/fortress/examples/swing/SwingContainer.roles" ); config.setInstrumentManagerConfiguration( "resource://org/apache/avalon/fortress/examples/swing/SwingContainer.instruments" ); // Get the root container initialized org.apache.avalon.fortress.ContainerManager cm = new DefaultContainerManager( config.getContext() ); org.apache.avalon.framework.container.ContainerUtil.initialize( cm ); /* Special containers such as Swing applications run in a different * thread in the background. This is only one method of handling * a Swing based container. Another alternative is to have the root * JFrame/JWindow/JDialog at this level, and hand a reference of the * container or its ServiceManager to the Swing class. That will allow * you to defer proper shutdown of Fortress resources when your * application is closed. */ ((SwingContainer)cm.getContainer()).run(); // Properly clean up when we are done org.apache.avalon.framework.container.ContainerUtil.dispose( cm ); } } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/swing/SwingContainer.instruments Index: SwingContainer.instruments =================================================================== <instrument logger="system.instrument"> <name>SwingContainer</name> <description>Fortress SwingContainer Example</description> <connectors> <connector class="altrmi" port="15555"/> </connectors> <state-file interval="60000" use-compact-samples="true"> SwingContainer.sampledata </state-file> <instrumentables> <instrumentable name="instrument-manager" description="Instrument Manager"> <instrument name="active-thread-count" description="Active Thread Count"> <sample type="max" interval="1000" size="600" description="Maximum each second."/> </instrument> <instrument name="total-memory" description="Total Memory"> <sample type="max" interval="1000" size="600" description="Maximum each second."/> </instrument> <instrument name="free-memory" description="Free Memory"> <sample type="min" interval="1000" size="600" description="Minimum each second."/> </instrument> <instrument name="memory" description="In-Use Memory"> <sample type="max" interval="1000" size="600" description="Maximum each second."/> </instrument> </instrumentable> </instrumentables> </instrument> 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/swing/SwingContainer.java Index: SwingContainer.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.swing; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import org.apache.avalon.framework.activity.Startable; import org.apache.avalon.fortress.impl.DefaultContainer; import org.apache.avalon.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:[EMAIL PROTECTED]">Marcus Crafter</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/28 21:19:18 $ */ public final class SwingContainer extends org.apache.avalon.fortress.impl.DefaultContainer implements org.apache.avalon.framework.activity.Startable, java.awt.event.ActionListener, Runnable { // Component references private org.apache.avalon.fortress.examples.components.Translator m_translator; // GUI references private javax.swing.JFrame m_frame; private javax.swing.JLabel m_label; // Dictionary key private String m_key = "hello-world"; /** * Initializes this component. Creates simple Swing GUI containing * available translations for the key 'hello-world'. * * @exception java.lang.Exception if an error occurs */ public void initialize() throws Exception { super.initialize(); // obtain translator component m_translator = (org.apache.avalon.fortress.examples.components.Translator)m_serviceManager.lookup( org.apache.avalon.fortress.examples.components.Translator.ROLE ); // create combo box javax.swing.JComboBox cb = new javax.swing.JComboBox( m_translator.getSupportedLanguages( m_key ) ); cb.addActionListener( this ); // create label m_label = new javax.swing.JLabel( "Select your language" ); m_label.setPreferredSize( new java.awt.Dimension( 150, 30 ) ); // create panel holding box and label javax.swing.JPanel panel = new javax.swing.JPanel(); panel.add( cb ); panel.add( m_label ); // create main frame m_frame = new javax.swing.JFrame( "Hello World!" ); m_frame.setDefaultCloseOperation( javax.swing.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" ); } } public void run() { while ( m_frame.isVisible() ) { try { Thread.sleep(1000); } catch( InterruptedException ie ) { m_frame.setVisible(false); } } } /** * 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( java.awt.event.ActionEvent evt ) { javax.swing.JComboBox cb = (javax.swing.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() { if( m_translator != null ) m_serviceManager.release( m_translator ); m_frame.dispose(); super.dispose(); } } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/swing/SwingContainer.roles Index: SwingContainer.roles =================================================================== <fortress-roles logger="system.roles"> <role name="org.apache.avalon.fortress.examples.components.Translator"> <component shorthand="translator" class="org.apache.avalon.fortress.examples.components.TranslatorImpl" handler="org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler"/> </role> </fortress-roles> 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/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/avalon/fortress/examples/swing/SwingContainer.xinfo Index: SwingContainer.xinfo =================================================================== <?xml version="1.0"?> <!DOCTYPE component-info PUBLIC "-//AVALON/Component Info DTD Version 1.0//EN" "http://jakarta.apache.org/avalon/componentinfo_1_0.dtd" > <component-info> <component> <name>fortress-swing</name> </component> <context> <!-- Required context. --> <entry key="container.logManager" type="org.apache.avalon.excalibur.logger.LoggerManager"/> <entry key="container.poolManager" type="org.apache.excalibur.mpool.PoolManager"/> <entry key="container.roleManager" type="org.apache.avalon.fortress.impl.role.RoleManager"/> <!-- Optional context. --> <entry key="container.classloader" type="java.lang.ClassLoader" option="true"/> <entry key="container.extensionManager" type="org.apache.avalon.fortress.impl.LifecycleExtensionManager" optional="true"/> <entry key="container.commandQueue" type="org.apache.excalibur.event.Queue" optional="true"/> <entry key="context-root" type="java.lang.String" optional="true"/> <entry key="container.workDir" type="java.lang.String" optional="true"/> </context> <dependencies> <dependency> <service-ref type="org.apache.avalon.fortress.examples.components.Translator"/> </dependency> </dependencies> <services> <service> <service-ref type="org.apache.avalon.fortress.Container"/> </service> </services> </component-info> 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/swing/SwingContainer.xlog Index: SwingContainer.xlog =================================================================== <logkit logger="system.logkit" log-level="INFO"> <factories> <factory type="stream" class="org.apache.avalon.excalibur.logger.factory.StreamTargetFactory"/> </factories> <targets> <stream id="console"> <stream>System.out</stream> <format type="extended"> %7.7{priority} %23.23{time:yyyy-MM-dd HH:mm:ss.SSS} [%24.24{category}] (%{context}): %{message}\n%{throwable} </format> </stream> </targets> <categories> <!-- Log output from the default logger --> <category name="" log-level="DEBUG"> <log-target id-ref="console"/> </category> <!-- Log output from the fortress system --> <category name="system" log-level="INFO"> <log-target id-ref="console"/> </category> </categories> </logkit> 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/viewer/ComponentViewer.java Index: ComponentViewer.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.avalon.fortress.examples.viewer; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Iterator; import java.util.Set; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import org.apache.avalon.framework.activity.Startable; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.fortress.impl.DefaultContainer; /** * Simple Fortress container containing a Swing based viewer for performing * lookups on registered components. * * <p> * The intention of the viewer is to allow you to perform a lookup of a component * manually, (currently) so you can check the see the effect of lazy vs startup * initialization. * </p> * * <p> * REVISIT: add a text component which tracks the log file to make it easier to * see a component being initialized upon first lookup. * </p> * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/28 21:19:19 $ */ public final class ComponentViewer extends org.apache.avalon.fortress.impl.DefaultContainer implements org.apache.avalon.framework.activity.Startable, java.awt.event.ActionListener, Runnable { // GUI references private javax.swing.JFrame m_frame; private javax.swing.JComboBox m_components; /** * Initializes this component. Creates simple Swing GUI containing * available translations for the key 'hello-world'. * * @exception java.lang.Exception if an error occurs */ public void initialize() throws Exception { super.initialize(); // create main frame m_frame = new javax.swing.JFrame( "Component Viewer" ); m_frame.setDefaultCloseOperation( javax.swing.JFrame.EXIT_ON_CLOSE ); m_components = new javax.swing.JComboBox( getRoles() ); javax.swing.JButton button = new javax.swing.JButton( "Lookup!" ); button.addActionListener( this ); /* // can we output the log data into this text area somehow ? JTextArea logData = new JTextArea(); logData.setEditable( false ); */ javax.swing.JPanel selectionPanel = new javax.swing.JPanel(); selectionPanel.add( m_components ); selectionPanel.add( button ); javax.swing.JPanel mainPanel = new javax.swing.JPanel(); mainPanel.setLayout( new javax.swing.BoxLayout( mainPanel, javax.swing.BoxLayout.Y_AXIS ) ); mainPanel.add( selectionPanel ); m_frame.setContentPane( mainPanel ); m_frame.pack(); // all done if( getLogger().isDebugEnabled() ) { getLogger().debug( "Initialized" ); } } /** * Helper method to obtain a list of all Roles registered with this container * * @return an array of roles */ private Object[] getRoles() { java.util.Set keys = m_mapper.keySet(); Object[] roles = new Object[ keys.size() ]; int j = 0; for( java.util.Iterator i = keys.iterator(); i.hasNext(); ) { roles[ j++ ] = i.next(); } return roles; } /** * 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" ); } } /** * Handles the <i>lookup</i> event. Finds out which component * was selected and performs a lookup and release on this component. * * @param evt an <code>ActionEvent</code> value */ public void actionPerformed( java.awt.event.ActionEvent evt ) { String selected = (String)m_components.getSelectedItem(); if( getLogger().isDebugEnabled() ) { getLogger().debug( "Looking up component " + selected ); } Object component = null; try { component = m_serviceManager.lookup( selected ); } catch( org.apache.avalon.framework.service.ServiceException e ) { if( getLogger().isWarnEnabled() ) { getLogger().warn( "Error looking up component: " + e.getKey(), e ); } } finally { if( component != null ) m_serviceManager.release( component ); } } public void run() { while (m_frame.isVisible()) { try { Thread.sleep(1000); } catch (InterruptedException ie) { m_frame.setVisible(false); } } } } 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/viewer/ComponentViewer.roles Index: ComponentViewer.roles =================================================================== <fortress-roles> <role name="org.apache.avalon.fortress.examples.components.Translator"> <component shorthand="translator" class="org.apache.avalon.fortress.examples.components.TranslatorImpl" handler="org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler"/> </role> </fortress-roles> 1.1 jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/avalon/fortress/examples/viewer/ComponentViewer.xconf Index: ComponentViewer.xconf =================================================================== <?xml version="1.0" encoding="iso-8859-1" ?> <!-- Example Fortress configuration file --> <fortress-example> <!-- Simple translation component. This component maintains translations for a given key in different languages. --> <translator id="translator" logger="translator" activation="request"> <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/avalon/fortress/examples/viewer/ComponentViewer.xlog Index: ComponentViewer.xlog =================================================================== <logkit> <factories> <factory type="file" class="org.apache.avalon.excalibur.logger.factory.FileTargetFactory"/> </factories> <targets> <file id="root"> <filename>fortress-viewer.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/avalon/fortress/examples/viewer/Main.java Index: Main.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) @year@ The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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", "Excalibur" 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 [EMAIL PROTECTED] 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 (INCLU- DING, 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.fortress.examples.viewer; import org.apache.avalon.framework.CascadingException; import org.apache.avalon.framework.container.ContainerUtil; import org.apache.avalon.fortress.ContainerManager; import org.apache.avalon.fortress.impl.DefaultContainerManager; import org.apache.avalon.fortress.util.FortressConfig; /** * Fortress container example allowing you to perform lookups on components * via a simple swing gui. * * @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a> * @version $Id: Main.java,v 1.1 2003/01/28 21:19:19 leosimons Exp $ */ public final class Main { /** * @param args a <code>String[]</code> array of command line arguments * @exception java.lang.Exception if an error occurs */ public static final void main( String[] args ) throws Exception { org.apache.avalon.fortress.ContainerManager cm = null; try { final org.apache.avalon.fortress.util.FortressConfig config = new org.apache.avalon.fortress.util.FortressConfig(); config.setContainerClass( "org.apache.avalon.fortress.examples.viewer.ComponentViewer" ); config.setContextDirectory( "./" ); config.setWorkDirectory( "./" ); config.setContainerConfiguration( "resource://org/apache/avalon/fortress/examples/viewer/ComponentViewer.xconf" ); config.setLoggerManagerConfiguration( "resource://org/apache/avalon/fortress/examples/viewer/ComponentViewer.xlog" ); config.setRoleManagerConfiguration( "resource://org/apache/avalon/fortress/examples/viewer/ComponentViewer.roles" ); cm = new DefaultContainerManager( config.getContext() ); org.apache.avalon.framework.container.ContainerUtil.initialize( cm ); ((org.apache.avalon.fortress.examples.viewer.ComponentViewer)cm.getContainer()).run(); } catch( org.apache.avalon.framework.CascadingException e ) { e.printStackTrace(); Throwable t = e.getCause(); while( t != null ) { t.printStackTrace(); if( t instanceof org.apache.avalon.framework.CascadingException ) t = ( (org.apache.avalon.framework.CascadingException)t ).getCause(); else t = null; } } finally { org.apache.avalon.framework.container.ContainerUtil.dispose( cm ); } } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>