git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271703 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -8,6 +8,7 @@ | |||||
| package org.apache.myrmidon.api; | package org.apache.myrmidon.api; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * This interface represents the <em>Context</em> in which Task is executed. | * This interface represents the <em>Context</em> in which Task is executed. | ||||
| @@ -19,7 +20,6 @@ import java.io.File; | |||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| */ | */ | ||||
| public interface TaskContext | public interface TaskContext | ||||
| extends Context | |||||
| { | { | ||||
| //these are the names of properties that every TaskContext must contain | //these are the names of properties that every TaskContext must contain | ||||
| String BASE_DIRECTORY = "myrmidon.base.directory"; | String BASE_DIRECTORY = "myrmidon.base.directory"; | ||||
| @@ -32,6 +32,32 @@ public interface TaskContext | |||||
| */ | */ | ||||
| String getName(); | String getName(); | ||||
| /** | |||||
| * Resolve a value according to the context. | |||||
| * This involves evaluating the string and replacing | |||||
| * ${} sequences with property values. | |||||
| * | |||||
| * @param value the value to resolve | |||||
| * @return the resolved value | |||||
| */ | |||||
| Object resolveValue( String value ) | |||||
| throws TaskException; | |||||
| /** | |||||
| * Retrieve property for name. | |||||
| * | |||||
| * @param name the name of property | |||||
| * @return the value of property, or null if the property has no value. | |||||
| */ | |||||
| Object getProperty( String name ); | |||||
| /** | |||||
| * Retrieve a copy of all the properties accessible via context. | |||||
| * | |||||
| * @return the map of all property names to values | |||||
| */ | |||||
| Map getProperties(); | |||||
| /** | /** | ||||
| * Retrieve a service that is offered by the runtime. | * Retrieve a service that is offered by the runtime. | ||||
| * The actual services registered and in place for the | * The actual services registered and in place for the | ||||
| @@ -22,7 +22,7 @@ import org.apache.avalon.framework.logger.LogEnabled; | |||||
| import org.apache.avalon.framework.service.ServiceException; | import org.apache.avalon.framework.service.ServiceException; | ||||
| import org.apache.avalon.framework.service.ServiceManager; | import org.apache.avalon.framework.service.ServiceManager; | ||||
| import org.apache.avalon.framework.service.Serviceable; | import org.apache.avalon.framework.service.Serviceable; | ||||
| import org.apache.myrmidon.api.Context; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.interfaces.configurer.Configurer; | import org.apache.myrmidon.interfaces.configurer.Configurer; | ||||
| @@ -66,7 +66,7 @@ public class ClassicConfigurer | |||||
| */ | */ | ||||
| public void configure( final Object object, | public void configure( final Object object, | ||||
| final Configuration configuration, | final Configuration configuration, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| if( DEBUG ) | if( DEBUG ) | ||||
| @@ -157,7 +157,7 @@ public class ClassicConfigurer | |||||
| public void configure( final Object object, | public void configure( final Object object, | ||||
| final String name, | final String name, | ||||
| final String value, | final String value, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| configureAttribute( object, name, value, context ); | configureAttribute( object, name, value, context ); | ||||
| @@ -173,7 +173,7 @@ public class ClassicConfigurer | |||||
| */ | */ | ||||
| private void configureContent( final Object object, | private void configureContent( final Object object, | ||||
| final String content, | final String content, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| setValue( object, "addContent", content, context ); | setValue( object, "addContent", content, context ); | ||||
| @@ -182,7 +182,7 @@ public class ClassicConfigurer | |||||
| private void configureAttribute( final Object object, | private void configureAttribute( final Object object, | ||||
| final String name, | final String name, | ||||
| final String value, | final String value, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| final String methodName = getMethodNameFor( name ); | final String methodName = getMethodNameFor( name ); | ||||
| @@ -192,7 +192,7 @@ public class ClassicConfigurer | |||||
| private void setValue( final Object object, | private void setValue( final Object object, | ||||
| final String methodName, | final String methodName, | ||||
| final String value, | final String value, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| // OMFG the rest of this is soooooooooooooooooooooooooooooooo | // OMFG the rest of this is soooooooooooooooooooooooooooooooo | ||||
| @@ -212,7 +212,7 @@ public class ClassicConfigurer | |||||
| private void setValue( final Object object, | private void setValue( final Object object, | ||||
| final String value, | final String value, | ||||
| final Context context, | |||||
| final TaskContext context, | |||||
| final Method[] methods ) | final Method[] methods ) | ||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| @@ -232,7 +232,7 @@ public class ClassicConfigurer | |||||
| private void setValue( final Object object, | private void setValue( final Object object, | ||||
| Object value, | Object value, | ||||
| final Method[] methods, | final Method[] methods, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| final Class sourceClass = value.getClass(); | final Class sourceClass = value.getClass(); | ||||
| @@ -254,7 +254,7 @@ public class ClassicConfigurer | |||||
| private boolean setValue( final Object object, | private boolean setValue( final Object object, | ||||
| final Object originalValue, | final Object originalValue, | ||||
| final Method method, | final Method method, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| Class parameterType = method.getParameterTypes()[ 0 ]; | Class parameterType = method.getParameterTypes()[ 0 ]; | ||||
| @@ -433,7 +433,7 @@ public class ClassicConfigurer | |||||
| private void configureElement( final Object object, | private void configureElement( final Object object, | ||||
| final Configuration configuration, | final Configuration configuration, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| final String name = configuration.getName(); | final String name = configuration.getName(); | ||||
| @@ -468,7 +468,7 @@ public class ClassicConfigurer | |||||
| private void createElement( final Object object, | private void createElement( final Object object, | ||||
| final Method method, | final Method method, | ||||
| final Configuration configuration, | final Configuration configuration, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| try | try | ||||
| @@ -490,7 +490,7 @@ public class ClassicConfigurer | |||||
| private void addElement( final Object object, | private void addElement( final Object object, | ||||
| final Method method, | final Method method, | ||||
| final Configuration configuration, | final Configuration configuration, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| try | try | ||||
| @@ -21,7 +21,7 @@ import org.apache.avalon.framework.logger.LogEnabled; | |||||
| import org.apache.avalon.framework.service.ServiceException; | import org.apache.avalon.framework.service.ServiceException; | ||||
| import org.apache.avalon.framework.service.ServiceManager; | import org.apache.avalon.framework.service.ServiceManager; | ||||
| import org.apache.avalon.framework.service.Serviceable; | import org.apache.avalon.framework.service.Serviceable; | ||||
| import org.apache.myrmidon.api.Context; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.myrmidon.framework.DataType; | import org.apache.myrmidon.framework.DataType; | ||||
| import org.apache.myrmidon.interfaces.configurer.Configurer; | import org.apache.myrmidon.interfaces.configurer.Configurer; | ||||
| import org.apache.myrmidon.interfaces.role.RoleInfo; | import org.apache.myrmidon.interfaces.role.RoleInfo; | ||||
| @@ -79,7 +79,7 @@ public class DefaultConfigurer | |||||
| */ | */ | ||||
| public void configure( final Object object, | public void configure( final Object object, | ||||
| final Configuration configuration, | final Configuration configuration, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| try | try | ||||
| @@ -110,7 +110,7 @@ public class DefaultConfigurer | |||||
| */ | */ | ||||
| private void configureObject( final Object object, | private void configureObject( final Object object, | ||||
| final Configuration configuration, | final Configuration configuration, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws Exception | throws Exception | ||||
| { | { | ||||
| if( object instanceof Configurable ) | if( object instanceof Configurable ) | ||||
| @@ -220,7 +220,7 @@ public class DefaultConfigurer | |||||
| public void configure( final Object object, | public void configure( final Object object, | ||||
| final String name, | final String name, | ||||
| final String value, | final String value, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws ConfigurationException | throws ConfigurationException | ||||
| { | { | ||||
| // Locate the configurer for this object | // Locate the configurer for this object | ||||
| @@ -252,7 +252,7 @@ public class DefaultConfigurer | |||||
| */ | */ | ||||
| private void setContent( final ConfigurationState state, | private void setContent( final ConfigurationState state, | ||||
| final String content, | final String content, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws Exception | throws Exception | ||||
| { | { | ||||
| // Locate the content configurer | // Locate the content configurer | ||||
| @@ -271,7 +271,7 @@ public class DefaultConfigurer | |||||
| */ | */ | ||||
| private void configureElement( final ConfigurationState state, | private void configureElement( final ConfigurationState state, | ||||
| final Configuration element, | final Configuration element, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws Exception | throws Exception | ||||
| { | { | ||||
| final String elementName = element.getName(); | final String elementName = element.getName(); | ||||
| @@ -292,7 +292,7 @@ public class DefaultConfigurer | |||||
| */ | */ | ||||
| private void configureInline( final ConfigurationState state, | private void configureInline( final ConfigurationState state, | ||||
| final Configuration element, | final Configuration element, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws Exception | throws Exception | ||||
| { | { | ||||
| final String name = element.getName(); | final String name = element.getName(); | ||||
| @@ -314,7 +314,7 @@ public class DefaultConfigurer | |||||
| */ | */ | ||||
| private void configureReference( final ConfigurationState state, | private void configureReference( final ConfigurationState state, | ||||
| final Configuration element, | final Configuration element, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws Exception | throws Exception | ||||
| { | { | ||||
| @@ -338,7 +338,7 @@ public class DefaultConfigurer | |||||
| private void setReference( final ConfigurationState state, | private void setReference( final ConfigurationState state, | ||||
| final String refName, | final String refName, | ||||
| final String unresolvedId, | final String unresolvedId, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws Exception | throws Exception | ||||
| { | { | ||||
| // Adjust the name | // Adjust the name | ||||
| @@ -384,7 +384,7 @@ public class DefaultConfigurer | |||||
| private void setAttribute( final ConfigurationState state, | private void setAttribute( final ConfigurationState state, | ||||
| final String name, | final String name, | ||||
| final String value, | final String value, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws Exception | throws Exception | ||||
| { | { | ||||
| if( name.toLowerCase().endsWith( "-ref" ) ) | if( name.toLowerCase().endsWith( "-ref" ) ) | ||||
| @@ -407,7 +407,7 @@ public class DefaultConfigurer | |||||
| private void setValue( final PropertyConfigurer setter, | private void setValue( final PropertyConfigurer setter, | ||||
| final ConfigurationState state, | final ConfigurationState state, | ||||
| final String value, | final String value, | ||||
| final Context context ) | |||||
| final TaskContext context ) | |||||
| throws Exception | throws Exception | ||||
| { | { | ||||
| // Resolve property references in the attribute value | // Resolve property references in the attribute value | ||||
| @@ -445,7 +445,7 @@ public class DefaultConfigurer | |||||
| */ | */ | ||||
| private Object setupChild( final ConfigurationState state, | private Object setupChild( final ConfigurationState state, | ||||
| final Configuration element, | final Configuration element, | ||||
| final Context context, | |||||
| final TaskContext context, | |||||
| final PropertyConfigurer childConfigurer ) | final PropertyConfigurer childConfigurer ) | ||||
| throws Exception | throws Exception | ||||
| { | { | ||||
| @@ -9,7 +9,7 @@ package org.apache.myrmidon.components.workspace; | |||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | import org.apache.avalon.excalibur.i18n.ResourceManager; | ||||
| import org.apache.avalon.excalibur.i18n.Resources; | import org.apache.avalon.excalibur.i18n.Resources; | ||||
| import org.apache.myrmidon.api.Context; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| /** | /** | ||||
| @@ -38,7 +38,7 @@ public final class PropertyUtil | |||||
| * @exception TaskException if an error occurs | * @exception TaskException if an error occurs | ||||
| */ | */ | ||||
| public static Object resolveProperty( final String property, | public static Object resolveProperty( final String property, | ||||
| final Context context, | |||||
| final TaskContext context, | |||||
| final boolean ignoreUndefined ) | final boolean ignoreUndefined ) | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| @@ -99,7 +99,7 @@ public final class PropertyUtil | |||||
| * @exception TaskException if an error occurs | * @exception TaskException if an error occurs | ||||
| */ | */ | ||||
| public static Object recursiveResolveProperty( final String property, | public static Object recursiveResolveProperty( final String property, | ||||
| final Context context, | |||||
| final TaskContext context, | |||||
| final boolean ignoreUndefined ) | final boolean ignoreUndefined ) | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| @@ -219,7 +219,7 @@ public final class PropertyUtil | |||||
| * @exception TaskException if an error occurs | * @exception TaskException if an error occurs | ||||
| */ | */ | ||||
| private static Object resolveValue( final String key, | private static Object resolveValue( final String key, | ||||
| final Context context, | |||||
| final TaskContext context, | |||||
| final boolean ignoreUndefined ) | final boolean ignoreUndefined ) | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| @@ -9,7 +9,7 @@ package org.apache.myrmidon.interfaces.configurer; | |||||
| import org.apache.avalon.framework.configuration.Configuration; | import org.apache.avalon.framework.configuration.Configuration; | ||||
| import org.apache.avalon.framework.configuration.ConfigurationException; | import org.apache.avalon.framework.configuration.ConfigurationException; | ||||
| import org.apache.myrmidon.api.Context; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| /** | /** | ||||
| * Class used to configure tasks. | * Class used to configure tasks. | ||||
| @@ -32,7 +32,7 @@ public interface Configurer | |||||
| * @param context the Context | * @param context the Context | ||||
| * @exception ConfigurationException if an error occurs | * @exception ConfigurationException if an error occurs | ||||
| */ | */ | ||||
| void configure( Object object, Configuration configuration, Context context ) | |||||
| void configure( Object object, Configuration configuration, TaskContext context ) | |||||
| throws ConfigurationException; | throws ConfigurationException; | ||||
| /** | /** | ||||
| @@ -46,6 +46,6 @@ public interface Configurer | |||||
| * @param context the Context | * @param context the Context | ||||
| * @exception ConfigurationException if an error occurs | * @exception ConfigurationException if an error occurs | ||||
| */ | */ | ||||
| void configure( Object object, String name, String value, Context context ) | |||||
| void configure( Object object, String name, String value, TaskContext context ) | |||||
| throws ConfigurationException; | throws ConfigurationException; | ||||
| } | } | ||||