Return-Path: Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 82246 invoked by uid 500); 4 Apr 2003 12:14:30 -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 82235 invoked by uid 500); 4 Apr 2003 12:14:30 -0000 Received: (qmail 82232 invoked from network); 4 Apr 2003 12:14:30 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 4 Apr 2003 12:14:30 -0000 Received: (qmail 53074 invoked by uid 1438); 4 Apr 2003 12:14:29 -0000 Date: 4 Apr 2003 12:14:29 -0000 Message-ID: <20030404121429.53073.qmail@icarus.apache.org> From: mcconnell@apache.org To: avalon-sandbox-cvs@apache.org Subject: cvs commit: avalon-sandbox/merlin/merlin-smp/src/tutorial/005/src/java/tutorial DemoContext.java DemoContextProvider.java HelloComponent.java HelloComponent.xinfo X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mcconnell 2003/04/04 04:14:29 Added: merlin/merlin-smp/src/tutorial/005 .cvsignore build.xml merlin/merlin-smp/src/tutorial/005/src/config block.xml merlin/merlin-smp/src/tutorial/005/src/java/tutorial DemoContext.java DemoContextProvider.java HelloComponent.java HelloComponent.xinfo Log: Tutorial content for lesson 005. Revision Changes Path 1.1 avalon-sandbox/merlin/merlin-smp/src/tutorial/005/.cvsignore Index: .cvsignore =================================================================== build logs tutorial.jar 1.1 avalon-sandbox/merlin/merlin-smp/src/tutorial/005/build.xml Index: build.xml =================================================================== 1.1 avalon-sandbox/merlin/merlin-smp/src/tutorial/005/src/config/block.xml Index: block.xml =================================================================== 1.1 avalon-sandbox/merlin/merlin-smp/src/tutorial/005/src/java/tutorial/DemoContext.java Index: DemoContext.java =================================================================== 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(); } 1.1 avalon-sandbox/merlin/merlin-smp/src/tutorial/005/src/java/tutorial/DemoContextProvider.java Index: DemoContextProvider.java =================================================================== package tutorial; import java.util.Map; import java.io.File; 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( Map entries ) { super( entries ); } /** * 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:work" ); } catch( ContextException ce ) { // should not happen throw new RuntimeException( ce.toString() ); } } } 1.1 avalon-sandbox/merlin/merlin-smp/src/tutorial/005/src/java/tutorial/HelloComponent.java Index: HelloComponent.java =================================================================== 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; public class HelloComponent extends AbstractLogEnabled implements Contextualizable { /** * Contextualization of the component using a context * class that implements a domain specific context interface. */ public void contextualize( Context context ) throws ContextException { DemoContext c = (DemoContext) context; getLogger().info( "name: " + c.getName() ); getLogger().info( "partition: " + c.getPartition() ); getLogger().info( "home: " + c.getHomeDirectory() ); getLogger().info( "temp: " + c.getWorkingDirectory() ); } } 1.1 avalon-sandbox/merlin/merlin-smp/src/tutorial/005/src/java/tutorial/HelloComponent.xinfo Index: HelloComponent.xinfo =================================================================== hello 1.0 --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org