Browse Source

Add utility methods that directly delegate to the context to do work.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270202 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
37e9144202
1 changed files with 57 additions and 2 deletions
  1. +57
    -2
      proposal/myrmidon/src/java/org/apache/myrmidon/api/AbstractTask.java

+ 57
- 2
proposal/myrmidon/src/java/org/apache/myrmidon/api/AbstractTask.java View File

@@ -7,9 +7,11 @@
*/
package org.apache.myrmidon.api;

import java.io.File;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;

@@ -23,7 +25,7 @@ public abstract class AbstractTask
implements Task, Contextualizable, Initializable, Disposable
{
///Variable to hold context for use by sub-classes
private TaskContext m_context;
private TaskContext m_context;

/**
* Retrieve context from container.
@@ -46,7 +48,7 @@ public abstract class AbstractTask
}

/**
* Execute task.
* Execute task.
* This method is called to perform actual work associated with task.
* It is called after Task has been Configured and Initialized and before
* beig Disposed (If task implements appropriate interfaces).
@@ -75,4 +77,57 @@ public abstract class AbstractTask
{
return m_context;
}

protected final JavaVersion getJavaVersion()
{
return getContext().getJavaVersion();
}

protected final Object get( final Object key )
throws ContextException
{
return getContext().get( key );
}

//Will be made protected in the future
public final String getName()
{
return getContext().getName();
}

protected final File getBaseDirectory()
{
return getContext().getBaseDirectory();
}

protected final File resolveFile( final String filename )
throws TaskException
{
return getContext().resolveFile( filename );
}

protected final Object getProperty( final String name )
{
return getContext().getProperty( name );
}

protected final void setProperty( final String name, final Object value )
throws TaskException
{
getContext().setProperty( name, value );
}

protected final void setProperty( final String name,
final Object value,
final TaskContext.ScopeEnum scope )
throws TaskException
{
getContext().setProperty( name, value, scope );
}

protected final TaskContext createSubContext( final String name )
throws TaskException
{
return getContext().createSubContext( name );
}
}

Loading…
Cancel
Save