Return-Path: Delivered-To: apmail-avalon-cvs-archive@www.apache.org Received: (qmail 34780 invoked from network); 2 Sep 2004 02:50:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 2 Sep 2004 02:50:04 -0000 Received: (qmail 4584 invoked by uid 500); 2 Sep 2004 02:50:03 -0000 Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 4518 invoked by uid 500); 2 Sep 2004 02:50:02 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 4498 invoked by uid 99); 2 Sep 2004 02:50:02 -0000 X-ASF-Spam-Status: No, hits=-2.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 01 Sep 2004 19:49:59 -0700 Received: (qmail 34692 invoked by uid 65534); 2 Sep 2004 02:49:58 -0000 Date: 2 Sep 2004 02:49:58 -0000 Message-ID: <20040902024958.34690.qmail@minotaur.apache.org> From: oberhack@apache.org To: cvs@avalon.apache.org Subject: svn commit: rev 37352 - in avalon/trunk/central/laboratory/studio/eclipse/core: config lib/avalon-framework src/org/apache/metro/studio/eclipse/core templates/configuration templates/context templates/context/alias templates/context/casting templates/context/custom templates/context/plus templates/context/standard templates/context/strategy templates/hello test/org/apache/metro/studio/eclipse/core/templateengine/test X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: oberhack Date: Wed Sep 1 19:49:57 2004 New Revision: 37352 Added: avalon/trunk/central/laboratory/studio/eclipse/core/lib/avalon-framework/avalon-framework-api-4.2.0.jar (contents, props changed) avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/ avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/HelloComponent.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/HelloComponent.xconfig avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/block.xml avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/categories.xml avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/config.xml avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/alias/ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/alias/HelloComponent.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/alias/block.xml avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/DemoContext.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/DemoContextProvider.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/HelloComponent.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/block.xml avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/custom/ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/custom/HelloComponent.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/custom/NumberCruncher.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/custom/block.xml avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/DemoContext.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/DemoContextProvider.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/HelloComponent.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/block.xml avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/standard/ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/standard/HelloComponent.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/standard/block.xml avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/Contextualizable.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/DemoContextualizationHandler.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardComponent.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardContext.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardContextImp.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardService.java avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/block.xml avalon/trunk/central/laboratory/studio/eclipse/core/templates/hello/HelloComponent.xinfo Modified: avalon/trunk/central/laboratory/studio/eclipse/core/config/resources.test_cfg avalon/trunk/central/laboratory/studio/eclipse/core/src/org/apache/metro/studio/eclipse/core/MetroStudioCore.java avalon/trunk/central/laboratory/studio/eclipse/core/test/org/apache/metro/studio/eclipse/core/templateengine/test/ResourceTemplateManagerTest.java Log: Modified: avalon/trunk/central/laboratory/studio/eclipse/core/config/resources.test_cfg ============================================================================== --- avalon/trunk/central/laboratory/studio/eclipse/core/config/resources.test_cfg (original) +++ avalon/trunk/central/laboratory/studio/eclipse/core/config/resources.test_cfg Wed Sep 1 19:49:57 2004 @@ -1,11 +1,43 @@ + Custom Context Tutorial + + StandardBlock + Custom Context Tutorial + This tutorial presents information about the management of the runtime context supplied to your component. + + + + src + /D:/Avalon/studio/eclipse/core/templates/context/custom/HelloComponent.java + tutorial + + + src + /D:/Avalon/studio/eclipse/core/templates/context/custom/NumberCruncher.java + tutorial + + + src/BLOCK-INF + /D:/Avalon/studio/eclipse/core/templates/context/custom/block.xml + + + + + + avalon-framework-api + 4.2.0 + + + + + HelloWorld Tutorial StandardBlock HelloWorld Tutorial - this is the hello world help + This tutorial takes you through the creation of a very simple component, the declaration of a component type descriptor, and the declaration of a block containing the component. @@ -18,11 +50,233 @@ /D:/Avalon/studio/eclipse/core/templates/hello/block.xml + + src + /D:/Avalon/studio/eclipse/core/templates/hello/HelloComponent.xinfo + tutorial + + + + + avalon-framework-api + 4.2.0 + + + + + + Plus Context Tutorial + + StandardBlock + Plus Context Tutorial + This tutorial covers usage of context entries using a constructor supplied custom context + + + + src + /D:/Avalon/studio/eclipse/core/templates/context/plus/HelloComponent.java + tutorial + + + src + /D:/Avalon/studio/eclipse/core/templates/context/plus/DemoContext.java + tutorial + + + src + /D:/Avalon/studio/eclipse/core/templates/context/plus/DemoContextProvider.java + tutorial + + + src/BLOCK-INF + /D:/Avalon/studio/eclipse/core/templates/context/plus/block.xml + + + + + + avalon-framework-api + 4.2.0 + + + + + + Configuration Tutorial + + StandardBlock + Configuration Tutorial + This example is the HelloComponent extended to include a configuration constructor argument and updates to log the source of the configuration based on runtime information. + + + + src + /D:/Avalon/studio/eclipse/core/templates/configuration/HelloComponent.java + tutorial + + + src/BLOCK-INF + /D:/Avalon/studio/eclipse/core/templates/configuration/block.xml + + + + src/BLOCK-INF + /D:/Avalon/studio/eclipse/core/templates/configuration/categories.xml + + + + src/BLOCK-INF + /D:/Avalon/studio/eclipse/core/templates/configuration/config.xml + + + + src + /D:/Avalon/studio/eclipse/core/templates/configuration/HelloComponent.xconfig + tutorial + + + + + avalon-framework-api + 4.2.0 + + + + + + Strategy Context Tutorial + + StandardBlock + Strategy Context Tutorial + This tutorial covers the declaration of custom contextualization strategy. + + + + src + /D:/Avalon/studio/eclipse/core/templates/context/strategy/StandardComponent.java + tutorial + + + src + /D:/Avalon/studio/eclipse/core/templates/context/strategy/StandardService.java + tutorial + + + src + /D:/Avalon/studio/eclipse/core/templates/context/strategy/StandardContext.java + tutorial + + + src + /D:/Avalon/studio/eclipse/core/templates/context/strategy/StandardContextImp.java + tutorial + + + src + /D:/Avalon/studio/eclipse/core/templates/context/strategy/Contextualizable.java + tutorial + + + src + /D:/Avalon/studio/eclipse/core/templates/context/strategy/DemoContextualizationHandler.java + tutorial + + + src/BLOCK-INF + /D:/Avalon/studio/eclipse/core/templates/context/strategy/block.xml + + + + + + avalon-framework-api + 4.2.0 + + + + + + Casting Context Tutorial + + StandardBlock + Casting Context Tutorial + This tutorial covers the declaration of context casting criteria and the creation of a typed context. + + + + src + /D:/Avalon/studio/eclipse/core/templates/context/casting/HelloComponent.java + tutorial + + + src + /D:/Avalon/studio/eclipse/core/templates/context/casting/DemoContext.java + tutorial + + + src + /D:/Avalon/studio/eclipse/core/templates/context/casting/DemoContextProvider.java + tutorial + + + src/BLOCK-INF + /D:/Avalon/studio/eclipse/core/templates/context/casting/block.xml + + + + + + avalon-framework-api + 4.2.0 + + + + + + Alias Context Tutorial + + StandardBlock + Alias Context Tutorial + This tutorial covers usage of standard context entries using a constructor supplied context (as opposed to the classic Contextualization delivery mecahanism). + + + + src + /D:/Avalon/studio/eclipse/core/templates/context/alias/HelloComponent.java + tutorial.application + + + impl/BLOCK-INF + /D:/Avalon/studio/eclipse/core/templates/context/alias/block.xml + + + + + + + + Standard Context Tutorial + + StandardBlock + Standard Context Tutorial + This tutorial presents information about the management of the runtime context supplied to your component. + + + + src + /D:/Avalon/studio/eclipse/core/templates/context/standard/HelloComponent.java + tutorial + + + src/BLOCK-INF + /D:/Avalon/studio/eclipse/core/templates/context/standard/block.xml + + avalon-framework-api - 4.1.5 + 4.2.0 Added: avalon/trunk/central/laboratory/studio/eclipse/core/lib/avalon-framework/avalon-framework-api-4.2.0.jar ============================================================================== Binary file. No diff available. Modified: avalon/trunk/central/laboratory/studio/eclipse/core/src/org/apache/metro/studio/eclipse/core/MetroStudioCore.java ============================================================================== --- avalon/trunk/central/laboratory/studio/eclipse/core/src/org/apache/metro/studio/eclipse/core/MetroStudioCore.java (original) +++ avalon/trunk/central/laboratory/studio/eclipse/core/src/org/apache/metro/studio/eclipse/core/MetroStudioCore.java Wed Sep 1 19:49:57 2004 @@ -120,7 +120,7 @@ e); log(status); - if (isDebugging) + if (isDebugging && e != null) { System.out.println(message + ": " + e.getMessage()); //$NON-NLS-1$ } Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/HelloComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/HelloComponent.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,60 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package tutorial; + +import org.apache.avalon.framework.logger.AbstractLogEnabled; +import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; + +/** + * A configurable component. + * + * @avalon.component version="1.0" name="simple" + */ +public class HelloComponent extends AbstractLogEnabled + implements Configurable, Initializable +{ + private String m_source = "undefined"; + + /** + * Configuration of the component by the container. The + * implementation get a child element named 'source' and + * assigns the value of the element to a local variable. + * + * @param config the component configuration + * @exception ConfigurationException if a configuration error occurs + */ + public void configure( Configuration config ) throws ConfigurationException + { + getLogger().info( "configuration stage" ); + m_source = config.getChild( "source" ).getValue( "unknown" ); + } + + /** + * Initialization of the component by the container. + * @exception Exception if an initialization error occurs + */ + public void initialize() throws Exception + { + getLogger().info( "initialization stage" ); + final String message = + "source: " + m_source; + getLogger().info( message ); + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/HelloComponent.xconfig ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/HelloComponent.xconfig Wed Sep 1 19:49:57 2004 @@ -0,0 +1,14 @@ + + + + + + packaged default + Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/block.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/block.xml Wed Sep 1 19:49:57 2004 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + explicit configuration within block + + + + Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/categories.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/categories.xml Wed Sep 1 19:49:57 2004 @@ -0,0 +1,8 @@ + + + + + + + + Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/config.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/configuration/config.xml Wed Sep 1 19:49:57 2004 @@ -0,0 +1,10 @@ + + + + + + Custom configuration from target in config.xml. + + + + Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/alias/HelloComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/alias/HelloComponent.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,72 @@ +/* + * 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 tutorial; + +import java.io.File; + +import org.apache.avalon.framework.logger.Logger; +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.ContextException; + +/** + * Component demonstrating access to standard context entries. + * @avalon.component name="demo" lifestyle="singleton" + */ +public class HelloComponent +{ + //------------------------------------------------------ + // immutable state + //------------------------------------------------------ + + private final Logger m_logger; + private final File m_home; + private final File m_temp; + private final String m_name; + private final String m_partition; + + /** + * Creation of a new HelloComponent instance using a + * container supplied logging channel and context. + * The context supplied by the container holds the + * standard context entries for the home and + * working directories, component name and partition. + * + * @avalon.entry key="urn:avalon:name" alias="name" + * @avalon.entry key="urn:avalon:partition" alias="partition" + * @avalon.entry key="urn:avalon:home" type="java.io.File" alias="home" + * @avalon.entry key="urn:avalon:temp" type="java.io.File" alias="temp" + */ + public HelloComponent( Logger logger, Context context ) + throws ContextException + { + m_logger = logger; + + m_home = (File) context.get( "home" ); + m_temp = (File) context.get( "temp" ); + m_name = (String) context.get( "name" ); + m_partition = (String) context.get( "partition" ); + + StringBuffer buffer = new StringBuffer( "standard context entries" ); + buffer.append( "\n name: " + m_name ); + buffer.append( "\n home: " + m_home ); + buffer.append( "\n temp: " + m_temp ); + buffer.append( "\n partition: " + m_partition ); + + m_logger.info( buffer.toString() ); + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/alias/block.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/alias/block.xml Wed Sep 1 19:49:57 2004 @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/DemoContext.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/DemoContext.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,54 @@ +/* + * 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 tutorial; + +import java.io.File; + +import org.apache.avalon.framework.context.Context; + +/** + * An example of an convinience interface that extends the + * standard Avalon Context interface. + */ +public interface DemoContext extends Context +{ + + /** + * Return the component name. + * @return the component name + */ + String getName(); + + /** + * Return the name of the partition assigned to the component. + * @return the partition name + */ + String getPartition(); + + /** + * Return the home directory. + * @return the directory + */ + File getHomeDirectory(); + + /** + * Return the temporary working directory. + * @return the directory + */ + File getWorkingDirectory(); +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/DemoContextProvider.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/DemoContextProvider.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,113 @@ +/* + * 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 tutorial; + +import java.util.Map; +import java.io.File; + +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.DefaultContext; +import org.apache.avalon.framework.context.ContextException; + + +/** + * A demonstration class that that we will instantiate via + * context directives within the component declaration. + */ +public class DemoContextProvider extends DefaultContext implements DemoContext +{ + + /** + * A custom context type implementation must provide + * the following constructor. + * @param entries a map of context entries + */ + public DemoContextProvider( Context context ) + { + super( context ); + } + + /** + * Return the component name. + * @return the component name + */ + public String getName() + { + try + { + return (String) super.get( "urn:avalon:name" ); + } + catch( ContextException ce ) + { + // should not happen + throw new RuntimeException( ce.toString() ); + } + } + + /** + * Return the name of the partition assigned to the component. + * @return the partition name + */ + public String getPartition() + { + try + { + return (String) super.get( "urn:avalon:partition" ); + } + catch( ContextException ce ) + { + // should not happen + throw new RuntimeException( ce.toString() ); + } + } + + /** + * Return the home directory. + * @return the home directory + */ + public File getHomeDirectory() + { + try + { + return (File) super.get( "urn:avalon:home" ); + } + catch( ContextException ce ) + { + // should not happen + throw new RuntimeException( ce.toString() ); + } + } + + + /** + * Return the temporary working directory. + * @return the temp directory + */ + public File getWorkingDirectory() + { + try + { + return (File) super.get( "urn:avalon:temp" ); + } + catch( ContextException ce ) + { + // should not happen + throw new RuntimeException( ce.toString() ); + } + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/HelloComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/HelloComponent.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,55 @@ +/* + * 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 tutorial; + +import org.apache.avalon.framework.logger.AbstractLogEnabled; +import org.apache.avalon.framework.context.Contextualizable; +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.ContextException; + +/** + * Component implementation that demonstrates type safe casting of a supplied + * context object. + * + * @avalon.component name="demo" lifestyle="singleton" + */ +public class HelloComponent extends AbstractLogEnabled + implements Contextualizable +{ + + /** + * Contextualization of the component using a context + * class that implements a domain specific context interface. + * + * @avalon.context type="tutorial.DemoContext" + * @avalon.entry key="urn:avalon:name" + * @avalon.entry key="urn:avalon:partition" + * @avalon.entry key="urn:avalon:home" type="java.io.File" + * @avalon.entry key="urn:avalon:temp" type="java.io.File" + */ + public void contextualize( Context context ) + throws ContextException + { + DemoContext c = (DemoContext) context; + getLogger().info( "listing values resolved from domain specific context" ); + getLogger().info( "supplied context class: " + context.getClass().getName() ); + getLogger().info( "name: " + c.getName() ); + getLogger().info( "partition: " + c.getPartition() ); + getLogger().info( "home: " + c.getHomeDirectory() ); + getLogger().info( "temp: " + c.getWorkingDirectory() ); + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/block.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/casting/block.xml Wed Sep 1 19:49:57 2004 @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/custom/HelloComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/custom/HelloComponent.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,49 @@ +/* + * 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 tutorial; + +import org.apache.avalon.framework.logger.AbstractLogEnabled; +import org.apache.avalon.framework.context.Contextualizable; +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.ContextException; + +/** + * Demonstration of a component that uses a constructed context entry. + * + * @avalon.component name="demo" lifestyle="singleton" + */ +public class HelloComponent extends AbstractLogEnabled + implements Contextualizable +{ + + /** + * Contextualization of the component by the container. + * The context supplied by the container shall contain + * a NumberCruncher instance as declared in the xinfo resource. + * + * @avalon.context + * @avalon.entry key="cruncher" type="tutorial.NumberCruncher" + */ + public void contextualize( Context context ) + throws ContextException + { + NumberCruncher cruncher = + (NumberCruncher) context.get( "cruncher" ); + float value = cruncher.crunch(); + getLogger().info( "result: " + value ); + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/custom/NumberCruncher.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/custom/NumberCruncher.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,43 @@ +/* + * 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 tutorial; + +/** + * A demonstration class that that we will instantiate via + * context directives within the component declaration. + */ +public class NumberCruncher +{ + private final int m_primary; + private final float m_secondary; + + public NumberCruncher( Integer primary, Double secondary ) + { + m_primary = primary.intValue(); + m_secondary = secondary.floatValue(); + } + + /** + * Multiply the supplied constructor arguments together and + * return the value. + */ + public float crunch() + { + return ( m_secondary * m_primary ); + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/custom/block.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/custom/block.xml Wed Sep 1 19:49:57 2004 @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + 7 + 1.5 + + + + + + Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/DemoContext.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/DemoContext.java Wed Sep 1 19:49:57 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 tutorial; + +import java.io.File; + +/** + * An example of an custom context interface. + */ +public interface DemoContext +{ + + /** + * Return the working directory. + * @return the directory + */ + File getWorkingDirectory(); +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/DemoContextProvider.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/DemoContextProvider.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,61 @@ +/* + * 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 tutorial; + +import java.util.Map; +import java.io.File; + +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.DefaultContext; +import org.apache.avalon.framework.context.ContextException; + + +/** + * A demonstration class that that we will instantiate via + * context directives within the component declaration. + */ +public class DemoContextProvider extends DefaultContext implements DemoContext +{ + + /** + * A custom context type implementation must provide + * the following constructor. + * @param entries a map of context entries + */ + public DemoContextProvider( Context context ) + { + super( context ); + } + + /** + * Return the working directory. + * @return the directory + */ + public File getWorkingDirectory() + { + try + { + return (File) super.get( "urn:avalon:home" ); + } + catch( ContextException ce ) + { + // should not happen + throw new RuntimeException( ce.toString() ); + } + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/HelloComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/HelloComponent.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,59 @@ +/* + * 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 tutorial; + +import java.io.File; + +import org.apache.avalon.framework.logger.Logger; +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.ContextException; + +/** + * Component demonstrating access to standard context entries. + * @avalon.component name="demo" lifestyle="singleton" + */ +public class HelloComponent +{ + //------------------------------------------------------ + // immutable state + //------------------------------------------------------ + + private final Logger m_logger; + private final File m_home; + + /** + * Creation of a new HelloComponent instance using a + * container supplied logging channel and custom context. + * The context supplied by the container holds the + * standard context entries requested under the avalon.entry + * tags. The advantages of this approach is the isolation + * of context entry casting and key into a seperate context + * helper class. + * + * @avalon.context type="tutorial.DemoContext" + * @avalon.entry key="urn:avalon:home" type="java.io.File" + */ + public HelloComponent( Logger logger, DemoContext context ) + { + m_logger = logger; + + m_home = context.getWorkingDirectory(); + + m_logger.info( "working directory set to: " + m_home ); + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/block.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/plus/block.xml Wed Sep 1 19:49:57 2004 @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/standard/HelloComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/standard/HelloComponent.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,69 @@ +/* + * 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 tutorial; + +import java.io.File; + +import org.apache.avalon.framework.logger.AbstractLogEnabled; +import org.apache.avalon.framework.context.Contextualizable; +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.ContextException; + +/** + * Component demonstrating access to standard context entries. + * @avalon.component name="demo" lifestyle="singleton" + */ +public class HelloComponent extends AbstractLogEnabled + implements Contextualizable +{ + + private File m_home = null; + private File m_temp = null; + private String m_name = "unknown"; + private String m_partition = "unknown"; + + /** + * Contextualization of the component by the container. + * The context supplied by the container holds the + * Merlin standard context entries for the home and + * working directories, component name and partition. + * + * @avalon.context + * @avalon.entry key="urn:avalon:name" + * @avalon.entry key="urn:avalon:partition" + * @avalon.entry key="urn:avalon:home" type="java.io.File" + * @avalon.entry key="urn:avalon:temp" type="java.io.File" + */ + public void contextualize( Context context ) + throws ContextException + { + m_home = (File) context.get( "urn:avalon:home" ); + m_temp = (File) context.get( "urn:avalon:temp" ); + m_name = (String) context.get( "urn:avalon:name" ); + m_partition = (String) context.get( "urn:avalon:partition" ); + + StringBuffer buffer = new StringBuffer( "standard context entries" ); + buffer.append( "\n name: " + m_name ); + buffer.append( "\n home: " + m_home ); + buffer.append( "\n temp: " + m_temp ); + buffer.append( "\n partition: " + m_partition ); + + getLogger().info( buffer.toString() ); + + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/standard/block.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/standard/block.xml Wed Sep 1 19:49:57 2004 @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/Contextualizable.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/Contextualizable.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,40 @@ +/* + * 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 tutorial; + +import org.apache.avalon.framework.context.ContextException; + +/** + * Definition of an alternative contextualization interface. + * + * @author Avalon Development Team + */ +public interface Contextualizable +{ + //======================================================================= + // Contextualization (custom variant) + //======================================================================= + + /** + * Contextualization of the component. + * @param context the containment context + * @exception ContextException if a contextualization error occurs + */ + void contextualize( StandardContext context ) + throws ContextException; +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/DemoContextualizationHandler.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/DemoContextualizationHandler.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,71 @@ +/* + * 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 tutorial; + +import java.lang.reflect.Constructor; +import java.util.Map; + +import org.apache.avalon.composition.model.ContextualizationHandler; +import org.apache.avalon.framework.context.ContextException; +import org.apache.avalon.framework.context.Context; + +/** + * Definition of an extension handler that handles the Expoitable + * extension stage interface. + * + * @avalon.component name="demo" + * @avalon.extension id="tutorial.Contextualizable" + * @author Avalon Development Team + */ +public class DemoContextualizationHandler implements ContextualizationHandler +{ + //======================================================================= + // Extension + //======================================================================= + + /** + * Handle the contextualization stage of a component lifecycle. + * @param object the object to contextualize + * @param context the component context argument + * @exception ContextException if a contextualization error occurs + */ + public void contextualize( + Object object, Context context ) + throws ContextException + { + + // + // based on the supplied context directives, the container supplied + // map of base context entries and a classloader, build and apply + // a context object to the supplied target object + // + + if( object instanceof Contextualizable ) + { + StandardContext standard = new StandardContextImp( context ); + ( (Contextualizable)object ).contextualize( standard ); + } + else + { + final String error = + "Target object does not implement the " + + Contextualizable.class.getName() + " interface."; + throw new ContextException( error ); + } + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardComponent.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardComponent.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,123 @@ +/* + * 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 tutorial; + +import java.io.File; + +import org.apache.avalon.framework.activity.Disposable; +import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.activity.Executable; +import org.apache.avalon.framework.logger.AbstractLogEnabled; + +/** + * This is a minimal demonstration component that implements the + * BasicService interface and has no dependencies. + * + * @avalon.component name="standard" lifestyle="singleton" + * @avalon.service type="tutorial.StandardService" + * @author Avalon Development Team + */ +public class StandardComponent extends AbstractLogEnabled + implements Contextualizable, Initializable, Executable, Disposable, StandardService +{ + private File m_home; + private File m_work; + private String m_name; + private String m_partition; + private String m_message; + private StandardContext m_context; + + //======================================================================= + // Contextualizable + //======================================================================= + + /** + * Supply of the component context to the component type. + * + * @param context the context value + * + * @avalon.context strategy="tutorial.Contextualizable" + * @avalon.entry key="urn:avalon:name" + * @avalon.entry key="urn:avalon:partition" + * @avalon.entry key="urn:avalon:home" type="java.io.File" + * @avalon.entry key="urn:avalon:temp" type="java.io.File" + */ + public void contextualize( StandardContext context ) + { + m_context = context; + m_home = context.getHomeDirectory(); + m_work = context.getWorkingDirectory(); + m_name = context.getName(); + m_partition = context.getPartitionName(); + } + + //======================================================================= + // Initializable + //======================================================================= + + /** + * Initialization of the component type by its container. + */ + public void initialize() throws Exception + { + m_message = + " strategy: " + Contextualizable.class.getName() + + "\n context: " + m_context.getClass().getName() + + "\n home: " + m_home + + "\n work: " + m_work + + "\n name: " + m_name + + "\n partition: " + m_partition; + } + + //======================================================================= + // Disposable + //======================================================================= + + /** + * Dispose of the component. + */ + public void dispose() + { + getLogger().debug( "dispose" ); + } + + //======================================================================= + // Executable + //======================================================================= + + /** + * Execute the component. + */ + public void execute() + { + printMessage(); + } + + //======================================================================= + // BasicService + //======================================================================= + + /** + * Service interface implementation. + */ + public void printMessage() + { + getLogger().info( "contextualization using a custom strategy\n\n" + + m_message + "\n"); + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardContext.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardContext.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,58 @@ +/* + * 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 tutorial; + +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 Avalon Development Team + */ +public interface StandardContext extends Context +{ + public static final String NAME_KEY = "urn:avalon:name"; + public static final String PARTITION_KEY = "urn:avalon:partition"; + public static final String WORKING_KEY = "urn:avalon:temp"; + public static final String HOME_KEY = "urn:avalon:home"; + + /** + * Return the name assigned to the component + * @return the name + */ + String getName(); + + /** + * Return the partition name assigned to the component + * @return the partition name + */ + String getPartitionName(); + + /** + * @return a file representing the home directory + */ + File getHomeDirectory(); + + /** + * @return a file representing the temporary working directory + */ + File getWorkingDirectory(); + +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardContextImp.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardContextImp.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,118 @@ +/* + * 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 tutorial; + +import java.io.File; +import java.util.Map; + +import org.apache.avalon.framework.context.ContextException; +import org.apache.avalon.framework.context.DefaultContext; +import org.apache.avalon.framework.context.Context; + +/** + * 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 Avalon Development Team + */ +public class StandardContextImp extends DefaultContext implements StandardContext +{ + + //----------------------------------------------------------------- + // constructor + //----------------------------------------------------------------- + + /** + * Creation of a new custom context instance. + * @param map the context name/value map + * @param parent a possibly parent context + */ + public StandardContextImp( Context context ) throws ContextException + { + super( context ); + } + + //----------------------------------------------------------------- + // StandardContext + //----------------------------------------------------------------- + + /** + * Return the name assigned to the component + * @return the name + */ + public String getName() + { + try + { + return (String)super.get( StandardContext.NAME_KEY ); + } + catch( Throwable e ) + { + throw new IllegalStateException( StandardContext.NAME_KEY ); + } + } + + /** + * Return the partition name assigned to the component + * @return the partition name + * @exception IllegalStateException if the partition name is undefined + */ + public String getPartitionName() + { + try + { + return (String)super.get( StandardContext.PARTITION_KEY ); + } + catch( Throwable e ) + { + throw new IllegalStateException( StandardContext.PARTITION_KEY ); + } + } + + /** + * Returns the home directory for this component. + * @return the home directory + */ + public File getHomeDirectory() + { + try + { + return (File)super.get( StandardContext.HOME_KEY ); + } + catch( Throwable e ) + { + throw new IllegalStateException( StandardContext.HOME_KEY ); + } + } + + /** + * @return the working directory + */ + public File getWorkingDirectory() + { + try + { + return (File)super.get( StandardContext.WORKING_KEY ); + } + catch( Throwable e ) + { + throw new IllegalStateException( StandardContext.WORKING_KEY ); + } + } +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardService.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/StandardService.java Wed Sep 1 19:49:57 2004 @@ -0,0 +1,32 @@ +/* + * 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 tutorial; + +/** + * The StandardService prints a message. + * + * @author Avalon Development Team + */ +public interface StandardService +{ + + /** + * Execute the prime objective of this services. + */ + void printMessage(); +} Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/block.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/context/strategy/block.xml Wed Sep 1 19:49:57 2004 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + Added: avalon/trunk/central/laboratory/studio/eclipse/core/templates/hello/HelloComponent.xinfo ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/studio/eclipse/core/templates/hello/HelloComponent.xinfo Wed Sep 1 19:49:57 2004 @@ -0,0 +1,11 @@ + + + + + + hello + 1.0.0 + singleton + hard + + \ No newline at end of file Modified: avalon/trunk/central/laboratory/studio/eclipse/core/test/org/apache/metro/studio/eclipse/core/templateengine/test/ResourceTemplateManagerTest.java ============================================================================== --- avalon/trunk/central/laboratory/studio/eclipse/core/test/org/apache/metro/studio/eclipse/core/templateengine/test/ResourceTemplateManagerTest.java (original) +++ avalon/trunk/central/laboratory/studio/eclipse/core/test/org/apache/metro/studio/eclipse/core/templateengine/test/ResourceTemplateManagerTest.java Wed Sep 1 19:49:57 2004 @@ -71,7 +71,14 @@ rm.importDirectoryTemplates(dm); rm.addResourceTemplate(createHelloWorldResources()); - rm.addResourceTemplate(createCompositionApplicationResources()); + //rm.addResourceTemplate(createCompositionApplicationResources()); + rm.addResourceTemplate(createConfigurationResources()); + rm.addResourceTemplate(createStandardContextResources()); + rm.addResourceTemplate(createCustomContextResources()); + rm.addResourceTemplate(createCastingContextResources()); + rm.addResourceTemplate(createAliasContextResources()); + rm.addResourceTemplate(createPlusContextResources()); + rm.addResourceTemplate(createStrategyContextResources()); try { @@ -102,6 +109,7 @@ public final void testCreateHelloWorldProject() { project = BlockProjectManager.create("HelloWorld Tutorial", "HelloWorld Tutorial"); + assertNotNull("project was not created", project); String testpath; assertEquals("Project was not created", true, (new File(project.getLocation().toString()).exists())); @@ -110,23 +118,22 @@ testpath = "/src/BLOCK-INF/block.xml"; assertEquals("block.xml not created", true, (new File(project.getLocation().toString()+testpath).exists())); - // ProjectManager.delete(project); + BlockProjectManager.delete(project); } - public final void testCreateCompositionApplicationProject() + public final void testCreateStandardContextProject() { - project = BlockProjectManager.create("Composition (Application) Tutorial", "Composition (Application) Tutorial"); + project = BlockProjectManager.create("Standard Context Tutorial", "Standard Context Tutorial"); + assertNotNull("project was not created", project); String testpath; assertEquals("Project was not created", true, (new File(project.getLocation().toString()).exists())); - testpath = "/impl/tutorial/Application/Application.java"; - assertEquals("Composition (Application) Tutorial", true, (new File(project.getLocation().toString()+testpath).exists())); - testpath = "/impl/BLOCK-INF/block.xml"; + testpath = "/src/tutorial/HelloComponent.java"; + assertEquals("Standard Context Tutorial", true, (new File(project.getLocation().toString()+testpath).exists())); + testpath = "/src/BLOCK-INF/block.xml"; assertEquals("block.xml not created", true, (new File(project.getLocation().toString()+testpath).exists())); - testpath = "/impl/BLOCK-INF/debug.xml"; - assertEquals("debug.xml not created", true, (new File(project.getLocation().toString()+testpath).exists())); - // ProjectManager.delete(project); + BlockProjectManager.delete(project); } /** @@ -136,11 +143,11 @@ { ResourceTemplate rt = new ResourceTemplate(); rt.setTemplateId("HelloWorld Tutorial"); - rt.setDescription("this is the hello world help"); + rt.setDescription("This tutorial takes you through the creation of a very simple component, the declaration of a component type descriptor, and the declaration of a block containing the component."); rt.setDirectoryType("StandardBlock"); Library library = new Library(); library.setName("avalon-framework-api"); - library.setVersion("4.1.5"); + library.setVersion("4.2.0"); rt.addLibrary(library); Resource r = new Resource(); @@ -155,6 +162,160 @@ r.setPackageName(""); rt.addResource(r); + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/hello/HelloComponent.xinfo"); + r.setPackageName("tutorial"); + rt.addResource(r); + + return rt; + } + /** + * @return + */ + private ResourceTemplate createConfigurationResources() + { + ResourceTemplate rt = new ResourceTemplate(); + rt.setTemplateId("Configuration Tutorial"); + rt.setDescription("This example is the HelloComponent extended to include a configuration constructor argument and updates to log the source of the configuration based on runtime information."); + rt.setDirectoryType("StandardBlock"); + Library library = new Library(); + library.setName("avalon-framework-api"); + library.setVersion("4.2.0"); + rt.addLibrary(library); + + Resource r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/configuration/HelloComponent.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src/BLOCK-INF"); + r.setSourceFilePathName(baseDir+"templates/configuration/block.xml"); + r.setPackageName(""); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src/BLOCK-INF"); + r.setSourceFilePathName(baseDir+"templates/configuration/categories.xml"); + r.setPackageName(""); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src/BLOCK-INF"); + r.setSourceFilePathName(baseDir+"templates/configuration/config.xml"); + r.setPackageName(""); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/configuration/HelloComponent.xconfig"); + r.setPackageName("tutorial"); + rt.addResource(r); + + return rt; + } + /** + * @return + */ + private ResourceTemplate createCustomContextResources() + { + ResourceTemplate rt = new ResourceTemplate(); + rt.setTemplateId("Custom Context Tutorial"); + rt.setDescription("This tutorial presents information about the management of the runtime context supplied to your component."); + rt.setDirectoryType("StandardBlock"); + Library library = new Library(); + library.setName("avalon-framework-api"); + library.setVersion("4.2.0"); + rt.addLibrary(library); + + Resource r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/custom/HelloComponent.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/custom/NumberCruncher.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src/BLOCK-INF"); + r.setSourceFilePathName(baseDir+"templates/context/custom/block.xml"); + r.setPackageName(""); + rt.addResource(r); + + return rt; + } + /** + * @return + */ + private ResourceTemplate createCastingContextResources() + { + ResourceTemplate rt = new ResourceTemplate(); + rt.setTemplateId("Casting Context Tutorial"); + rt.setDescription("This tutorial covers the declaration of context casting criteria and the creation of a typed context."); + rt.setDirectoryType("StandardBlock"); + Library library = new Library(); + library.setName("avalon-framework-api"); + library.setVersion("4.2.0"); + rt.addLibrary(library); + + Resource r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/casting/HelloComponent.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/casting/DemoContext.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/casting/DemoContextProvider.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src/BLOCK-INF"); + r.setSourceFilePathName(baseDir+"templates/context/casting/block.xml"); + r.setPackageName(""); + rt.addResource(r); + + return rt; + } + /** + * @return + */ + private ResourceTemplate createStandardContextResources() + { + ResourceTemplate rt = new ResourceTemplate(); + rt.setTemplateId("Standard Context Tutorial"); + rt.setDescription("This tutorial presents information about the management of the runtime context supplied to your component."); + rt.setDirectoryType("StandardBlock"); + Library library = new Library(); + library.setName("avalon-framework-api"); + library.setVersion("4.2.0"); + rt.addLibrary(library); + + Resource r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/standard/HelloComponent.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src/BLOCK-INF"); + r.setSourceFilePathName(baseDir+"templates/context/standard/block.xml"); + r.setPackageName(""); + rt.addResource(r); + return rt; } /** @@ -186,5 +347,126 @@ return rt; } + /** + * @return + */ + private ResourceTemplate createAliasContextResources() + { + ResourceTemplate rt = new ResourceTemplate(); + rt.setTemplateId("Alias Context Tutorial"); + rt.setDescription("This tutorial covers usage of standard context entries using a constructor supplied context (as opposed to the classic Contextualization delivery mecahanism)."); + rt.setDirectoryType("StandardBlock"); + + Resource r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/alias/HelloComponent.java"); + r.setPackageName("tutorial.application"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("impl/BLOCK-INF"); + r.setSourceFilePathName(baseDir+"templates/context/alias/block.xml"); + r.setPackageName(""); + rt.addResource(r); + + return rt; + } + /** + * @return + */ + private ResourceTemplate createPlusContextResources() + { + ResourceTemplate rt = new ResourceTemplate(); + rt.setTemplateId("Plus Context Tutorial"); + rt.setDescription("This tutorial covers usage of context entries using a constructor supplied custom context"); + rt.setDirectoryType("StandardBlock"); + Library library = new Library(); + library.setName("avalon-framework-api"); + library.setVersion("4.2.0"); + rt.addLibrary(library); + Resource r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/plus/HelloComponent.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/plus/DemoContext.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/plus/DemoContextProvider.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src/BLOCK-INF"); + r.setSourceFilePathName(baseDir+"templates/context/plus/block.xml"); + r.setPackageName(""); + rt.addResource(r); + + return rt; + } + /** + * @return + */ + private ResourceTemplate createStrategyContextResources() + { + ResourceTemplate rt = new ResourceTemplate(); + rt.setTemplateId("Strategy Context Tutorial"); + rt.setDescription("This tutorial covers the declaration of custom contextualization strategy."); + rt.setDirectoryType("StandardBlock"); + Library library = new Library(); + library.setName("avalon-framework-api"); + library.setVersion("4.2.0"); + rt.addLibrary(library); + + Resource r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/strategy/StandardComponent.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/strategy/StandardService.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/strategy/StandardContext.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/strategy/StandardContextImp.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/strategy/Contextualizable.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src"); + r.setSourceFilePathName(baseDir+"templates/context/strategy/DemoContextualizationHandler.java"); + r.setPackageName("tutorial"); + rt.addResource(r); + + r = new Resource(); + r.setRootSegment("src/BLOCK-INF"); + r.setSourceFilePathName(baseDir+"templates/context/strategy/block.xml"); + r.setPackageName(""); + rt.addResource(r); + + return rt; + } } --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org