mcconnell 2002/12/10 17:32:03
Added: merlin/src/test/org/apache/avalon/playground
StandardComponent.java StandardComponent.xconfig
StandardComponent.xinfo StandardComponent.xprofile
StandardContext.java StandardContextInterface.java
StandardService.java StandardService.xservice
Removed: merlin/src/test/org/apache/avalon/playground
BasicComponent.java BasicComponent.xconfig
BasicComponent.xinfo BasicComponent.xprofile
BasicContext.java BasicContextInterface.java
BasicService.java BasicService.xservice
Log:
Replaced BasicComponent family with StandardComponent family so that it is possible
to test multiple block loading using demos from assembly package.
Revision Changes Path
1.1
avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.java
Index: StandardComponent.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [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 (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.avalon.playground;
import java.io.File;
import 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;
/**
* This is a minimal demonstration component that implements the
* <code>BasicService</code> interface and has no dependencies.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
*/
public class StandardComponent extends AbstractLogEnabled
implements Contextualizable, Configurable, Initializable, Startable, Disposable,
StandardService
{
private String m_location;
private String m_message;
private File m_home;
//=======================================================================
// Contextualizable
//=======================================================================
/**
* Supply of the the component context to the component type.
* @param context the context value
*/
public void contextualize( Context context )
{
StandardContextInterface c = (StandardContextInterface)context;
m_location = c.getLocation();
m_home = c.getWorkingDirectory();
}
//=======================================================================
// Configurable
//=======================================================================
/**
* Supply of the the component configuration to the type.
* @param config the configuration value
*/
public void configure( Configuration config )
{
getLogger().debug( "configure" );
m_message = config.getChild( "message" ).getValue( null );
}
//=======================================================================
// Initializable
//=======================================================================
/**
* Initialization of the component type by its container.
*/
public void initialize()
{
getLogger().debug( "initialize" );
getLogger().debug( "location: " + m_location );
getLogger().debug( "home: " + m_home );
getLogger().debug( "message: " + m_message );
}
//=======================================================================
// Startable
//=======================================================================
/**
* Start the component.
*/
public void start()
{
doPrimeObjective();
}
/**
* Stop the component.
*/
public void stop()
{
getLogger().info( "stopping" );
}
/**
* Dispose of the component.
*/
public void dispose()
{
getLogger().debug( "dispose" );
}
//=======================================================================
// BasicService
//=======================================================================
/**
* Service interface implementation.
*/
public void doPrimeObjective()
{
getLogger().info( m_message + " from '" + m_location + "'." );
}
}
1.1
avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.xconfig
Index: StandardComponent.xconfig
===================================================================
<?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.
@author Avalon Development Team
@version 1.0 12/03/2001
-->
<!--
The .xconfig file contains the default configuration for the component.
-->
<configuration>
<message>Hello</message>
</configuration>
1.1
avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.xinfo
Index: StandardComponent.xinfo
===================================================================
<?xml version="1.0"?>
<!DOCTYPE type
PUBLIC "-//AVALON/Component Type DTD Version 1.0//EN"
"http://jakarta.apache.org/avalon/dtds/meta/type_1_1.dtd" >
<!--
Copyright (C) The Apache Software Foundation. All rights reserved.
This software is published under the terms of the Apache Software License
version 1.1, a copy of which has been included with this distribution in
the LICENSE.txt file.
@author Avalon Development Team
@version 1.0 12/03/2001
-->
<type>
<info>
<name>basic</name>
<!--
<attributes>
<attribute key="urn:assembly:appliance.factory-service"
value="org.apache.avalon.merlin.block.BlockFactory"/>
<attribute key="urn:assembly:appliance.factory-version"
value="1.0"/>
</attributes>
-->
</info>
<context type="org.apache.avalon.playground.StandardContextInterface">
<entry key="location"/>
<entry key="home" type="java.io.File"/>
</context>
<services>
<service>
<reference type="org.apache.avalon.playground.StandardService" version="1.1"/>
</service>
</services>
</type>
1.1
avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardComponent.xprofile
Index: StandardComponent.xprofile
===================================================================
<?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.
@author Avalon Development Team
@version 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.
-->
<component name="standard">
<context class="org.apache.avalon.playground.StandardContext">
<import name="urn:avalon:home" key="home" />
<entry key="location">Paris</entry>
</context>
</component>
</profiles>
1.1
avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardContext.java
Index: StandardContext.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [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 (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.avalon.playground;
import java.io.File;
import java.util.Map;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.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:[EMAIL PROTECTED]">Avalon Development Team</a>
*/
public class StandardContext extends DefaultContext implements
StandardContextInterface
{
/**
* Creation of a new custom context instance.
* @param map the context name/value map
* @param parent a possibly parent context
*/
public StandardContext( Map map, Context parent )
{
super( map, parent );
}
/**
* @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." );
}
}
}
1.1
avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardContextInterface.java
Index: StandardContextInterface.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [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 (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.avalon.playground;
import java.io.File;
import 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:[EMAIL PROTECTED]">Avalon Development Team</a>
*/
public interface StandardContextInterface extends Context
{
/**
* @return a string containing a location value
*/
String getLocation();
/**
* @return a file representing the working directory
*/
File getWorkingDirectory();
}
1.1
avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardService.java
Index: StandardService.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [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 (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.avalon.playground;
/**
* The <code>BasicService</code> executes a prime objective.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
*/
public interface StandardService
{
/**
* Execute the prime objective of this services.
*/
void doPrimeObjective();
}
1.1
avalon-sandbox/merlin/src/test/org/apache/avalon/playground/StandardService.xservice
Index: StandardService.xservice
===================================================================
<?xml version="1.0"?>
<!DOCTYPE type
PUBLIC "-//AVALON/Component Type DTD Version 1.0//EN"
"http://jakarta.apache.org/avalon/dtds/meta/type_1_1.dtd" >
<!--
Copyright (C) The Apache Software Foundation. All rights reserved.
This software is published under the terms of the Apache Software License
version 1.1, a copy of which has been included with this distribution in
the LICENSE.txt file.
@author Avalon Development Team
@version 1.0 12/03/2001
-->
<service>
<version>1.1</version>
<attributes>
<attribute key="urn:avalon:service.name" value="standard"/>
<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>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>