From a371839efdf087709c3ed7ff84aac7d510c252e6 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Thu, 21 Feb 2002 09:35:51 +0000 Subject: [PATCH] Add an adaptor so that the TaskContext will still apear as an Avalon COntext to the Configurer git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271476 13f79535-47bb-0310-9956-ffa450edef68 --- .../configurer/TaskContextAdapter.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/TaskContextAdapter.java diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/TaskContextAdapter.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/TaskContextAdapter.java new file mode 100644 index 000000000..43bffb623 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/TaskContextAdapter.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) The Apache Software Foundation. All rights reserved. + * + * This software is published under the terms of the Apache Software License + * version 1.1, a copy of which has been included with this distribution in + * the LICENSE.txt file. + */ +package org.apache.myrmidon.interfaces.configurer; + +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.ContextException; +import org.apache.myrmidon.api.TaskContext; + +/** + * This class adpats the TaskContext API to the Avalon Context API. + * + * @author Peter Donald + * @version $Revision$ $Date$ + */ +public class TaskContextAdapter + implements Context +{ + private final TaskContext m_context; + + public TaskContextAdapter( final TaskContext context ) + { + m_context = context; + } + + public Object get( Object key ) + throws ContextException + { + final Object value = m_context.getProperty( key.toString() ); + if( null != value ) + { + return value; + } + else + { + throw new ContextException( "Missing key " + key ); + } + } +}