Author: mcconnell Date: Wed Jun 9 05:18:14 2004 New Revision: 20938 Added: avalon/trunk/runtime/meta/test/playground/ avalon/trunk/runtime/meta/test/playground/build.properties (contents, props changed) avalon/trunk/runtime/meta/test/playground/build.xml (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/ avalon/trunk/runtime/meta/test/playground/src/main/ avalon/trunk/runtime/meta/test/playground/src/main/org/ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/ComplexComponent.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/ComplexService.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/DemoManager.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/Demonstratable.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/Exploitable.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/ExploitationManager.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/NullService.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/SimpleComponent.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/SimpleComponent.xconfig (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/SimpleService.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/TerminalComponent.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicComponent.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicComponent.xconfig (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicComponent.xprofile (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicContext.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicContextImp.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicService.java (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicService.xservice (contents, props changed) avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/package.html (contents, props changed) Log: add playground package
Added: avalon/trunk/runtime/meta/test/playground/build.properties ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/build.properties Wed Jun 9 05:18:14 2004 @@ -0,0 +1,2 @@ +project.name = avalon-test-playground +project.home = ../../../../central/system Added: avalon/trunk/runtime/meta/test/playground/build.xml ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/build.xml Wed Jun 9 05:18:14 2004 @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<project name="avalon-test-playground" default="dist" basedir="." + xmlns:x="antlib:org.apache.avalon.tools" + xmlns:m="plugin:avalon/meta/avalon-meta-tools"> + + <property file="build.properties"/> + <import file="${project.home}/build/standard.xml"/> + + <target name="build" depends="standard.build"> + <m:meta destDir="${basedir}/target/classes"> + <fileset dir="${basedir}/src/main"> + <include name="**/*.java"/> + </fileset> + </m:meta> + </target> + +</project> Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/ComplexComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/ComplexComponent.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,166 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground; + +import org.apache.avalon.framework.activity.Disposable; +import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.activity.Startable; +import org.apache.avalon.framework.logger.Logger; +import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.service.ServiceManager; +import org.apache.avalon.framework.service.Serviceable; + +import org.apache.avalon.test.playground.basic.BasicService; + +/** + * This is a demonstration component that declares no interface but + * has dependecies on two services. These include SimpleService and + * BasicService. + * + * @avalon.component name="complex" lifestyle="singleton" + * @avalon.service type="org.apache.avalon.test.playground.ComplexService" + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public class ComplexComponent + implements ComplexService, Startable, Disposable +{ + //----------------------------------------------------------------- + // immutable + //----------------------------------------------------------------- + + private final Logger m_logger; + private final ServiceManager m_manager; + private final SimpleService m_simple; + private final BasicService m_basic; + + //----------------------------------------------------------------- + // mutable + //----------------------------------------------------------------- + + private Thread m_thread; + protected boolean m_continue = false; + + //----------------------------------------------------------------- + // constructor + //----------------------------------------------------------------- + + /** + * @avalon.logger name="internal" + * @avalon.dependency key="simple" + * type="org.apache.avalon.test.playground.basic.BasicService" + * @avalon.dependency key="basic" + * type="org.apache.avalon.test.playground.SimpleService" + */ + public ComplexComponent( Logger logger, ServiceManager manager ) throws ServiceException + { + m_logger = logger; + m_manager = manager; + + // + // lookup the primary service + // + + m_simple = (SimpleService) m_manager.lookup( "simple" ); + m_basic = (BasicService) m_manager.lookup( "basic" ); + + Logger child = getLogger().getChildLogger( "internal" ); + if( child.isInfoEnabled() ) + { + child.debug( "ready" ); + } + } + + //======================================================================= + // Startable + //======================================================================= + + /** + * Start the component. + * @exception Exception if an error eoccurs + */ + public void start() throws Exception + { + getLogger().info( "starting" ); + m_continue = true; + m_thread = new Thread( + new Runnable() + { + public void run() + { + while( m_continue ) + { + try + { + Thread.sleep( 100 ); + } catch( Throwable e ) + { + // ignore it + } + } + } + } + ); + m_thread.start(); + getLogger().info( "started" ); + } + + /** + * Stop the component. + */ + public void stop() + { + getLogger().info( "stopping" ); + m_continue = false; + try + { + m_thread.join(); + } catch( Throwable e ) + { + // timeout + } + } + + + //----------------------------------------------------------------------- + // Disposable + //----------------------------------------------------------------------- + + /** + * Dispose of the component. + */ + public void dispose() + { + if( getLogger().isInfoEnabled() ) + { + getLogger().info( "dispose" ); + } + + m_manager.release( m_simple ); + m_manager.release( m_basic ); + } + + //----------------------------------------------------------------------- + // internals + //----------------------------------------------------------------------- + + private Logger getLogger() + { + return m_logger; + } + +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/ComplexService.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/ComplexService.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,27 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground; + +/** + * The <code>ComplexService</code> does do anything. + * + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public interface ComplexService +{ +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/DemoManager.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/DemoManager.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,138 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground; + +import org.apache.avalon.framework.activity.Disposable; +import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.logger.AbstractLogEnabled; + +import org.apache.avalon.lifecycle.Accessor; +import org.apache.avalon.lifecycle.Creator; + +/** + * Definition of an extension type that logs messages related to + * all lifestyle stages. + * + * @avalon.component lifestyle="singleton" name="demo-manager" + * @avalon.extension id="urn:avalon.test.playground:demonstratable" + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public class DemoManager extends AbstractLogEnabled + implements Creator, Accessor, Initializable, Disposable +{ + + //======================================================================= + // Initializable + //======================================================================= + + /** + * Initialization of the component. Simply demonstrates that this is + * a real componet that can implement any lifcycle stage in the role of + * classic component. + */ + public void initialize() + { + getLogger().debug( "initialize" ); + } + + //======================================================================= + // Creator + //======================================================================= + + /** + * Invoked by a container to handle a create stage action. + * @param target the object to handle + * @param context the context supplied to the extension by container + * corresponding to its extension context criteria + * @exception Exception if an error occurs + */ + public void create( Object target, Context context ) throws Exception + { + if( target instanceof Demonstratable ) + { + ((Demonstratable) target).demo( "create id: " + + System.identityHashCode( this ) + + ", " + Thread.currentThread() ); + } + } + + /** + * Invoked by a container to handle a destroy stage action. + * @param target the object to handle + * @param context the context supplied to the extension by container + * corresponding to its extension context criteria + */ + public void destroy( Object target, Context context ) + { + if( target instanceof Demonstratable ) + { + ((Demonstratable) target).demo( "destroy id: " + + System.identityHashCode( this ) + + ", " + Thread.currentThread() ); + } + } + + /** + * Invoked by a container to handle a access stage action. + * @param target the object to handle + * @param context the context supplied to the extension by container + * corresponding to its extension context criteria + * @exception Exception if an error occurs + */ + public void access( Object target, Context context ) throws Exception + { + if( target instanceof Demonstratable ) + { + ((Demonstratable) target).demo( "access id: " + + System.identityHashCode( this ) + + ", " + Thread.currentThread() ); + } + } + + /** + * Invoked by a container to handle a release stage action. + * @param target the object to handle + * @param context the context supplied to the extension by container + * corresponding to its extension context criteria + */ + public void release( Object target, Context context ) + { + if( target instanceof Demonstratable ) + { + ((Demonstratable) target).demo( "release id: " + + System.identityHashCode( this ) + + ", " + Thread.currentThread() ); + } + } + + //======================================================================= + // Disposable + //======================================================================= + + /** + * Disposal of the component. + */ + public void dispose() + { + if( getLogger().isDebugEnabled() ) + { + getLogger().debug( "dispose" ); + } + } +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/Demonstratable.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/Demonstratable.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,31 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground; + +/** + * A stage interface. + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public interface Demonstratable +{ + /** + * Do something or other. + * @param stage the stage being applied (as a string) + */ + void demo( String stage ); +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/Exploitable.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/Exploitable.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,37 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground; + +/** + * Another example extension stage interface. + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public interface Exploitable +{ + /** + * Method invoked by the extension handler for this type during + * the create stage. + */ + void incarnate(); + + /** + * Method invoked by the extension handler for this type during + * the destroy stage. + */ + void etherialize(); +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/ExploitationManager.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/ExploitationManager.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,91 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground; + +import org.apache.avalon.framework.activity.Disposable; +import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.logger.AbstractLogEnabled; +import org.apache.avalon.lifecycle.Creator; + +/** + * Definition of an extension handler that handles the Expoitable + * extension stage interface. + * + * @avalon.component name="exploitation" lifestyle="thread" + * @avalon.extension id="urn:avalon.test.playground:exploitable" + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public class ExploitationManager extends AbstractLogEnabled implements Creator, Initializable, Disposable +{ + + //======================================================================= + // Initializable + //======================================================================= + + /** + * Initialization of the handler. + */ + public void initialize() + { + getLogger().debug( "initialize" ); + } + + //======================================================================= + // Disposable + //======================================================================= + + /** + * Disposal of the handler. + */ + public void dispose() + { + getLogger().debug( "dispose" ); + } + + //======================================================================= + // Extension + //======================================================================= + + /** + * Handle the creation stage. + * @param object the object to handle + * @param context the extension stage context + * @exception Exception if a stage execution error occurs + */ + public void create( Object object, Context context ) throws Exception + { + if( object instanceof Exploitable ) + { + ((Exploitable) object).incarnate(); + } + } + + /** + * Handle the destroy stage. + * @param object the object to handle + * @param context the extension stage context + */ + public void destroy( Object object, Context context ) + { + if( object instanceof Exploitable ) + { + ((Exploitable) object).etherialize(); + } + } +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/NullService.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/NullService.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,27 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground; + +/** + * The <code>NullService</code> does nothing. + * + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public interface NullService +{ +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/SimpleComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/SimpleComponent.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,206 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground; + +import org.apache.avalon.framework.activity.Disposable; +import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.activity.Startable; +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.logger.AbstractLogEnabled; +import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.service.ServiceManager; +import org.apache.avalon.framework.service.Serviceable; + +import org.apache.avalon.test.playground.basic.BasicService; + +/** + * This is a minimal demonstration component that a dependency on + * BasicService and provides SimpleService. + * + * @avalon.component name="simple" lifestyle="singleton" + * @avalon.stage id="urn:avalon.test.playground:exploitable" + * @avalon.stage id="urn:avalon.test.playground:demonstratable" + * @avalon.service type="org.apache.avalon.test.playground.SimpleService" + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public class SimpleComponent extends AbstractLogEnabled + implements Configurable, Serviceable, Initializable, Startable, SimpleService, + Exploitable, Demonstratable, Disposable +{ + + private String m_message; + private BasicService m_basic; + private Thread m_thread; + protected boolean m_continuation = false; + + //======================================================================= + // Configurable + //======================================================================= + + /** + * Configurate the component. + * @param config the configuration + */ + public void configure( Configuration config ) + { + getLogger().info( "configure" ); + m_message = config.getChild( "message" ).getValue( null ); + } + + //======================================================================= + // Serviceable + //======================================================================= + + /** + * Service the component. + * @param manager the service manager holding the depedent services + * @avalon.dependency type="org.apache.avalon.test.playground.basic.BasicService" + * version="1.1" key="basic" + * @exception ServiceException if a service error occurs + */ + public void service( ServiceManager manager ) throws ServiceException + { + getLogger().info( "service" ); + m_basic = (BasicService) manager.lookup( "basic" ); + manager.release( m_basic ); + } + + //======================================================================= + // Exploitable + //======================================================================= + + /** + * The create stage interface implementation for the Exloitable extension. + */ + public void incarnate() + { + getLogger().info( "incarnation stage" ); + } + + /** + * The destroy stage interface implementation for the Exloitable extension. + */ + public void etherialize() + { + getLogger().info( "etherialize stage" ); + } + + + //======================================================================= + // Demonstratable + //======================================================================= + + /** + * Prints out the supplied message. + * @param message the message to print + */ + public void demo( String message ) + { + getLogger().info( "handling demonstratable stage: " + message ); + } + + //======================================================================= + // Initializable + //======================================================================= + + /** + * Initialization of the component. + */ + public void initialize() + { + getLogger().info( "initialize" ); + getLogger().debug( "context: " + Thread.currentThread().getContextClassLoader() ); + doObjective(); + } + + //======================================================================= + // Startable + //======================================================================= + + /** + * Starts the component. + * @exception Exception if an error occurs + */ + public void start() throws Exception + { + getLogger().debug( "starting" ); + m_continuation = true; + m_thread = new Thread( + new Runnable() + { + public void run() + { + while( m_continuation ) + { + try + { + Thread.sleep( 100 ); + } catch( Throwable e ) + { + // ignore it + } + } + } + } + ); + m_thread.start(); + getLogger().debug( "started" ); + } + + /** + * Stops the component. + */ + public void stop() + { + getLogger().info( "stopping" ); + m_continuation = false; + try + { + m_thread.join(); + } catch( Throwable e ) + { + // timeout + } + } + + //======================================================================= + // Disposable + //======================================================================= + + /** + * Dispose of the component. + */ + public void dispose() + { + getLogger().info( "dispose" ); + } + + //======================================================================= + // PrimaryService + //======================================================================= + + /** + * Prints out the message derived from the configuration. + */ + public void doObjective() + { + getLogger().info( "handling service operation: " + m_message ); + } + +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/SimpleComponent.xconfig ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/SimpleComponent.xconfig Wed Jun 9 05:18:14 2004 @@ -0,0 +1,20 @@ +<?xml version="1.0"?> + +<!-- +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. + [EMAIL PROTECTED] Avalon Development Team [EMAIL PROTECTED] 1.0 12/03/2001 +--> + +<!-- +The .xconfig file contains the default configuration for the component. +--> + +<configuration> + <message>Hello.</message> +</configuration> + Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/SimpleService.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/SimpleService.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,33 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground; + +/** + * The <code>SimpleService</code> executes an objective. + * + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ + +public interface SimpleService +{ + + /** + * Execute the prime objective of this services. + */ + void doObjective(); +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/TerminalComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/TerminalComponent.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,57 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground; + +import org.apache.avalon.framework.activity.Disposable; +import org.apache.avalon.framework.logger.AbstractLogEnabled; + +import org.apache.avalon.test.playground.basic.BasicService; + +/** + * This is a minimal demonstration component that provides BasicService + * and has no dependencies + * + * @avalon.component name="terminal" + * @avalon.service type="org.apache.avalon.test.playground.basic.BasicService" + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public class TerminalComponent extends AbstractLogEnabled + implements BasicService, Disposable +{ + + //======================================================================= + // BasicService + //======================================================================= + + /** + * Does something trivial. + */ + public void doPrimeObjective() + { + getLogger().info( "hello from TerminalComponent" ); + } + + /** + * Disposal of the componet. + */ + public void dispose() + { + getLogger().debug( "dispose" ); + } + +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicComponent.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,141 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground.basic; + +import java.io.File; + +import org.apache.avalon.framework.activity.Disposable; +import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.activity.Startable; +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.Contextualizable; +import org.apache.avalon.framework.logger.AbstractLogEnabled; + +import org.apache.avalon.test.playground.NullService; + +/** + * This is a minimal demonstration component that implements the + * <code>BasicService</code> interface and has no dependencies. + * + * @avalon.component name="basic" lifestyle="singleton" + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public class BasicComponent extends AbstractLogEnabled + implements Contextualizable, Configurable, Initializable, Startable, Disposable, BasicService, NullService +{ + + private String m_location; + private String m_message; + private File m_home; + private boolean m_started = false; + + //======================================================================= + // Contextualizable + //======================================================================= + + /** + * Supply of the the component context to the component type. + * @param context the context value + * @avalon.entry key="location" + * @avalon.entry key="home" type="java.io.File" + * @avalon.context strategy="org.apache.avalon.framework.context.Contextualizable" + */ + public void contextualize( Context context ) + { + BasicContext c = (BasicContext) context; + m_location = c.getLocation(); + m_home = c.getWorkingDirectory(); + } + + //======================================================================= + // Configurable + //======================================================================= + + /** + * Supply of the the component configuration to the type. + * @param config the configuration value + */ + public void configure( Configuration config ) + { + getLogger().info( "configure" ); + m_message = config.getChild( "message" ).getValue( null ); + } + + //======================================================================= + // Initializable + //======================================================================= + + /** + * Initialization of the component type by its container. + */ + public void initialize() + { + getLogger().info( "initialize" ); + getLogger().debug( "location: " + m_location ); + getLogger().debug( "home: " + m_home ); + getLogger().debug( "message: " + m_message ); + } + + //======================================================================= + // Startable + //======================================================================= + + /** + * Start the component. + */ + public void start() + { + if( !m_started ) + { + getLogger().info( "starting" ); + doPrimeObjective(); + m_started = true; + } + } + + /** + * Stop the component. + */ + public void stop() + { + getLogger().info( "stopping" ); + } + + /** + * Dispose of the component. + */ + public void dispose() + { + getLogger().info( "dispose" ); + } + + //======================================================================= + // BasicService + //======================================================================= + + /** + * Service interface implementation. + */ + public void doPrimeObjective() + { + getLogger().info( m_message + " from '" + m_location + "'." ); + } + +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicComponent.xconfig ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicComponent.xconfig Wed Jun 9 05:18:14 2004 @@ -0,0 +1,20 @@ +<?xml version="1.0"?> + +<!-- +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. + [EMAIL PROTECTED] Avalon Development Team [EMAIL PROTECTED] 1.0 12/03/2001 +--> + +<!-- +The .xconfig file contains the default configuration for the component. +--> + +<configuration> + <message>Hello</message> +</configuration> + Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicComponent.xprofile ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicComponent.xprofile Wed Jun 9 05:18:14 2004 @@ -0,0 +1,34 @@ +<?xml version="1.0"?> + +<!-- +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. + [EMAIL PROTECTED] Avalon Development Team [EMAIL PROTECTED] 1.0 12/03/2001 +--> + +<profiles> + + <!-- + A packaged profile is equivalent to a component declaration inside a container, + except that it is provided by a component type. A PACKAGED profiles take priority + over an IMPLICIT profile. An EXPLICIT profile declared inside a container definition + will take priority over PACKAGED profiles. + --> + + <profile name="basic"> + <context class="org.apache.avalon.test.playground.basic.BasicContextImp"> + <entry key="home"> + <import key="urn:avalon:home"/> + </entry> + <entry key="location"> + <constructor>Paris</constructor> + </entry> + </context> + </profile> + +</profiles> + Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicContext.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicContext.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,42 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground.basic; + +import java.io.File; + +import org.apache.avalon.framework.context.Context; + +/** + * Simple non-standard Context interface to demonstration context + * management at the level of different context types. + * + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public interface BasicContext extends Context +{ + /** + * @return a string containing a location value + */ + String getLocation(); + + /** + * @return a file representing the working directory + */ + File getWorkingDirectory(); + +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicContextImp.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicContextImp.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,75 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground.basic; + +import java.io.File; + +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.DefaultContext; + +/** + * This is example of a custom context class. It is used in the demonsteation + * of a context management fraework to show how a context class can be + * supplied to a component declaring a context interface criteria. + * + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public class BasicContextImp extends DefaultContext implements BasicContext +{ + + /** + * Creation of a new custom context instance. + * @param map the context name/value map + * @param parent a possibly parent context + */ + public BasicContextImp( Context context ) + { + super( context ); + } + + /** + * @return the location + */ + public String getLocation() + { + try + { + return (String) super.get( "location" ); + } + catch( Throwable e ) + { + return "Unknown"; + } + } + + /** + * @return the working directory + */ + public File getWorkingDirectory() + { + try + { + return (File) super.get( "home" ); + } + catch( Throwable e ) + { + throw new RuntimeException( "context object does not provide required home entry." ); + } + } + +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicService.java ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicService.java Wed Jun 9 05:18:14 2004 @@ -0,0 +1,36 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.test.playground.basic; + +/** + * The <code>BasicService</code> executes a prime objective. + * + * @avalon.service version="1.1" + * @avalon.attribute key="urn:avalon:service.name" value="basic" + * @avalon.attribute key="urn:avalon:service.description" + * value="A demonstration service used within the scope of the Avalon playground package for educational and unit testing purpose" + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + */ +public interface BasicService +{ + + /** + * Execute the prime objective of this services. + */ + void doPrimeObjective(); +} Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicService.xservice ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/basic/BasicService.xservice Wed Jun 9 05:18:14 2004 @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<!DOCTYPE type + PUBLIC "-//AVALON/Component Type DTD Version 1.0//EN" + "http://avalon.apache.org/dtds/meta/service.dtd" > + +<!-- +Copyright (C) The Apache Software Foundation. All rights reserved. +This software is published under the terms of the Apache Software License +version 1.1, a copy of which has been included with this distribution in +the LICENSE.txt file. + [EMAIL PROTECTED] Avalon Development Team [EMAIL PROTECTED] 1.0 12/03/2001 +--> + +<service> + <version>1.1</version> + <attributes> + <attribute key="urn:avalon:service.name" value="basic"/> + <attribute key="urn:avalon:service.description"> + A demonstration service used within the scope of the + Avalon playground package for educational and unit + testing purposes. + </attribute> + </attributes> +</service> + Added: avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/package.html ============================================================================== --- (empty file) +++ avalon/trunk/runtime/meta/test/playground/src/main/org/apache/avalon/test/playground/package.html Wed Jun 9 05:18:14 2004 @@ -0,0 +1,7 @@ + +<body> +<p> +Demonstration components. +</p> + +</body> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]