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 383644e50..c79d47239 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 @@ -12,6 +12,8 @@ import java.util.Map; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.excalibur.io.FileUtil; +import org.apache.avalon.excalibur.property.PropertyException; +import org.apache.avalon.excalibur.property.PropertyUtil; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.context.DefaultContext; import org.apache.myrmidon.api.TaskContext; @@ -104,6 +106,38 @@ public class DefaultTaskContext return FileUtil.resolveFile( getBaseDirectory(), filename ); } + /** + * Resolve a value according to the context. + * This involves evaluating the string and thus removing + * ${} sequences according to the rules specified at + * ............ + * + * @param value the value to resolve + * @return the resolved value + */ + public Object resolveValue( final String value ) + throws TaskException + { + try + { + final Object object = + PropertyUtil.resolveProperty( value, this, false ); + + if( null == object ) + { + final String message = REZ.getString( "null-resolved-value.error", value ); + throw new TaskException( message ); + } + + return object; + } + catch( final PropertyException pe ) + { + final String message = REZ.getString( "bad-resolve.error", value ); + throw new TaskException( message, pe ); + } + } + /** * Retrieve property for name. * diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties index ad0c8aae5..7725db7d3 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties @@ -17,3 +17,5 @@ no-dir.error=No Base Directory in Context. no-parent.error=Can't set a property with parent scope when context has no parent. bad-scope.error=Unknown property scope! ({0}). bad-property.error=Property {0} must have a value of type {1}. +null-resolved-value.error=Value "{0}" resolved to null. +bad-resolve.error=Unable to resolve value "{0}". \ No newline at end of file