From c1459a0550b8f7381fa50fdb2a38bed00f067f46 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Thu, 24 Jan 2002 11:48:40 +0000 Subject: [PATCH] STart to add the ability to retrieve services from the context git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270843 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/myrmidon/api/TaskContext.java | 15 ++++++++++++++- .../components/workspace/DefaultTaskContext.java | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java index e3daec9ac..2b1b6e744 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java @@ -34,12 +34,25 @@ public interface TaskContext String NAME = "myrmidon.task.name"; /** - * Retrieve Name of tasklet. + * Retrieve Name of task. * * @return the name */ String getName(); + /** + * Retrieve a service that is offered by the runtime. + * The actual services registered and in place for the + * task is determined by the container. The returned service + * MUST implement the specified interface. + * + * @param serviceClass the interface class that defines the service + * @return an instance of the service implementing interface specified by parameter + * @exception TaskException is thrown when the service is unavailable or not supported + */ + Object getService( Class serviceClass ) + throws TaskException; + /** * Retrieve base directory. * diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java index 977a9a071..9e71cd308 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java @@ -91,6 +91,22 @@ public class DefaultTaskContext } } + /** + * Retrieve a service that is offered by the runtime. + * The actual services registered and in place for the + * task is determined by the container. The returned service + * MUST implement the specified interface. + * + * @param serviceClass the interface class that defines the service + * @return an instance of the service implementing interface specified by parameter + * @exception TaskException is thrown when the service is unavailable or not supported + */ + public Object getService( final Class serviceClass ) + throws TaskException + { + throw new TaskException( "No services available atm" ); + } + /** * Resolve filename. * This involves resolving it against baseDirectory and