git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269049 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -100,8 +100,8 @@ public class Main | |||
| QUIET_OPT, VERBOSE_OPT, LOG_LEVEL_OPT | |||
| }; | |||
| protected ProjectListener m_listener; | |||
| protected File m_homeDir; | |||
| private ProjectListener m_listener; | |||
| private File m_homeDir; | |||
| /** | |||
| * Main entry point called to run standard Ant. | |||
| @@ -139,9 +139,8 @@ public class Main | |||
| /** | |||
| * Initialise the options for command line parser. | |||
| * This is called by super-class. | |||
| */ | |||
| protected CLOptionDescriptor[] createCLOptions() | |||
| private CLOptionDescriptor[] createCLOptions() | |||
| { | |||
| //TODO: localise | |||
| final CLOptionDescriptor[] options = new CLOptionDescriptor[ 11 ]; | |||
| @@ -9,7 +9,7 @@ package org.apache.ant.modules.basic; | |||
| import java.util.Iterator; | |||
| import org.apache.ant.AntException; | |||
| import org.apache.ant.configuration.Configurer; | |||
| import org.apache.myrmidon.components.Configurer; | |||
| import org.apache.ant.convert.Converter; | |||
| import org.apache.ant.tasklet.DataType; | |||
| import org.apache.ant.tasklet.engine.DataTypeEngine; | |||
| @@ -44,7 +44,7 @@ public class Property | |||
| throws ComponentException | |||
| { | |||
| m_configurer = (Configurer)componentManager. | |||
| lookup( "org.apache.ant.configuration.Configurer" ); | |||
| lookup( "org.apache.myrmidon.components.Configurer" ); | |||
| m_engine = (DataTypeEngine)componentManager. | |||
| lookup( "org.apache.ant.tasklet.engine.DataTypeEngine" ); | |||
| @@ -10,7 +10,7 @@ package org.apache.ant.runtime; | |||
| import java.io.File; | |||
| import java.util.Properties; | |||
| import org.apache.ant.AntException; | |||
| import org.apache.ant.configuration.Configurer; | |||
| import org.apache.myrmidon.components.Configurer; | |||
| import org.apache.ant.convert.engine.ConverterEngine; | |||
| import org.apache.ant.project.ProjectBuilder; | |||
| import org.apache.ant.project.ProjectEngine; | |||
| @@ -170,7 +170,7 @@ public class DefaultAntEngine | |||
| defaults.setProperty( "ant.comp.deployer", | |||
| "org.apache.ant.tasklet.engine.DefaultTskDeployer" ); | |||
| defaults.setProperty( "ant.comp.configurer", | |||
| "org.apache.ant.configuration.DefaultConfigurer" ); | |||
| "org.apache.myrmidon.components.configurer.DefaultConfigurer" ); | |||
| return defaults; | |||
| } | |||
| @@ -193,7 +193,7 @@ public class DefaultAntEngine | |||
| componentManager.put( "org.apache.ant.project.ProjectBuilder", m_builder ); | |||
| componentManager.put( "org.apache.ant.tasklet.engine.TskDeployer", m_deployer ); | |||
| componentManager.put( "org.apache.avalon.framework.camelot.Factory", m_factory ); | |||
| componentManager.put( "org.apache.ant.configuration.Configurer", m_configurer ); | |||
| componentManager.put( "org.apache.myrmidon.components.Configurer", m_configurer ); | |||
| return componentManager; | |||
| } | |||
| @@ -9,25 +9,9 @@ package org.apache.ant.tasklet.engine; | |||
| import java.util.HashMap; | |||
| import org.apache.ant.AntException; | |||
| import org.apache.ant.configuration.Configurer; | |||
| import org.apache.ant.configuration.DefaultConfigurer; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| import org.apache.avalon.framework.configuration.Configurable; | |||
| import org.apache.ant.convert.engine.ConverterEngine; | |||
| import org.apache.myrmidon.api.Task; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.avalon.framework.logger.AbstractLoggable; | |||
| import org.apache.avalon.framework.component.Component; | |||
| import org.apache.avalon.framework.component.ComponentManager; | |||
| import org.apache.avalon.framework.component.DefaultComponentManager; | |||
| import org.apache.avalon.framework.component.ComponentException; | |||
| import org.apache.avalon.framework.component.Composable; | |||
| import org.apache.avalon.framework.context.Context; | |||
| import org.apache.avalon.framework.context.Contextualizable; | |||
| import org.apache.avalon.framework.component.DefaultComponentManager; | |||
| import org.apache.avalon.framework.activity.Disposable; | |||
| import org.apache.avalon.framework.activity.Initializable; | |||
| import org.apache.avalon.framework.logger.Loggable; | |||
| import org.apache.avalon.framework.camelot.DefaultFactory; | |||
| import org.apache.avalon.framework.camelot.DefaultRegistry; | |||
| import org.apache.avalon.framework.camelot.Factory; | |||
| @@ -35,7 +19,23 @@ import org.apache.avalon.framework.camelot.FactoryException; | |||
| import org.apache.avalon.framework.camelot.Locator; | |||
| import org.apache.avalon.framework.camelot.Registry; | |||
| import org.apache.avalon.framework.camelot.RegistryException; | |||
| import org.apache.avalon.framework.component.Component; | |||
| import org.apache.avalon.framework.component.ComponentException; | |||
| import org.apache.avalon.framework.component.ComponentManager; | |||
| import org.apache.avalon.framework.component.Composable; | |||
| import org.apache.avalon.framework.component.DefaultComponentManager; | |||
| import org.apache.avalon.framework.component.DefaultComponentManager; | |||
| import org.apache.avalon.framework.configuration.Configurable; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| import org.apache.avalon.framework.context.Context; | |||
| import org.apache.avalon.framework.context.Contextualizable; | |||
| import org.apache.avalon.framework.logger.AbstractLoggable; | |||
| import org.apache.avalon.framework.logger.Loggable; | |||
| import org.apache.log.Logger; | |||
| import org.apache.myrmidon.api.Task; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.components.Configurer; | |||
| import org.apache.myrmidon.components.configurer.DefaultConfigurer; | |||
| public class DefaultTaskletEngine | |||
| extends AbstractLoggable | |||
| @@ -74,7 +74,7 @@ public class DefaultTaskletEngine | |||
| { | |||
| return m_dataTypeEngine; | |||
| } | |||
| /** | |||
| * Retrieve relevent services needed to deploy. | |||
| * | |||
| @@ -91,7 +91,7 @@ public class DefaultTaskletEngine | |||
| m_tskDeployer = (TskDeployer)componentManager. | |||
| lookup( "org.apache.ant.tasklet.engine.TskDeployer" ); | |||
| m_configurer = (Configurer)componentManager. | |||
| lookup( "org.apache.ant.configuration.Configurer" ); | |||
| lookup( "org.apache.myrmidon.components.Configurer" ); | |||
| m_dataTypeEngine = (DataTypeEngine)componentManager. | |||
| lookup( "org.apache.ant.tasklet.engine.DataTypeEngine" ); | |||
| m_converterEngine = (ConverterEngine)componentManager. | |||
| @@ -128,7 +128,7 @@ public class DefaultTaskletEngine | |||
| getLogger().debug( "Disposing" ); | |||
| doDispose( task, taskData ); | |||
| } | |||
| protected Task createTask( final String name ) | |||
| throws AntException | |||
| { | |||
| @@ -147,7 +147,7 @@ public class DefaultTaskletEngine | |||
| } | |||
| } | |||
| protected void doConfigure( final Task task, | |||
| protected void doConfigure( final Task task, | |||
| final Configuration taskData, | |||
| final TaskContext context ) | |||
| throws AntException | |||
| @@ -156,11 +156,11 @@ public class DefaultTaskletEngine | |||
| catch( final Throwable throwable ) | |||
| { | |||
| throw new AntException( "Error configuring task " + taskData.getName() + " at " + | |||
| taskData.getLocation() + "(Reason: " + | |||
| taskData.getLocation() + "(Reason: " + | |||
| throwable.getMessage() + ")", throwable ); | |||
| } | |||
| } | |||
| protected void doCompose( final Task task, final Configuration taskData ) | |||
| throws AntException | |||
| { | |||
| @@ -170,29 +170,29 @@ public class DefaultTaskletEngine | |||
| catch( final Throwable throwable ) | |||
| { | |||
| throw new AntException( "Error composing task " + taskData.getName() + " at " + | |||
| taskData.getLocation() + "(Reason: " + | |||
| throwable.getMessage() + ")", throwable ); | |||
| taskData.getLocation() + "(Reason: " + | |||
| throwable.getMessage() + ")", throwable ); | |||
| } | |||
| } | |||
| } | |||
| protected void doContextualize( final Task task, | |||
| protected void doContextualize( final Task task, | |||
| final Configuration taskData, | |||
| final TaskContext context ) | |||
| throws AntException | |||
| { | |||
| try | |||
| { | |||
| try | |||
| { | |||
| if( task instanceof Contextualizable ) | |||
| { | |||
| ((Contextualizable)task).contextualize( context ); | |||
| ((Contextualizable)task).contextualize( context ); | |||
| } | |||
| } | |||
| catch( final Throwable throwable ) | |||
| { | |||
| throw new AntException( "Error contextualizing task " + taskData.getName() + " at " + | |||
| taskData.getLocation() + "(Reason: " + | |||
| throwable.getMessage() + ")", throwable ); | |||
| taskData.getLocation() + "(Reason: " + | |||
| throwable.getMessage() + ")", throwable ); | |||
| } | |||
| } | |||
| @@ -205,7 +205,7 @@ public class DefaultTaskletEngine | |||
| catch( final Throwable throwable ) | |||
| { | |||
| throw new AntException( "Error disposing task " + taskData.getName() + " at " + | |||
| taskData.getLocation() + "(Reason: " + | |||
| taskData.getLocation() + "(Reason: " + | |||
| throwable.getMessage() + ")", throwable ); | |||
| } | |||
| } | |||
| @@ -5,11 +5,11 @@ | |||
| * version 1.1, a copy of which has been included with this distribution in | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.ant.configuration; | |||
| package org.apache.myrmidon.components; | |||
| import org.apache.avalon.framework.component.Component; | |||
| import org.apache.avalon.framework.configuration.ConfigurationException; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| import org.apache.avalon.framework.configuration.ConfigurationException; | |||
| import org.apache.avalon.framework.context.Context; | |||
| /** | |||
| @@ -5,7 +5,7 @@ | |||
| * version 1.1, a copy of which has been included with this distribution in | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.ant.configuration; | |||
| package org.apache.myrmidon.components.configurer; | |||
| import java.lang.reflect.InvocationTargetException; | |||
| import java.lang.reflect.Method; | |||
| @@ -18,13 +18,14 @@ import org.apache.avalon.excalibur.property.PropertyUtil; | |||
| import org.apache.avalon.framework.component.ComponentException; | |||
| import org.apache.avalon.framework.component.ComponentManager; | |||
| import org.apache.avalon.framework.component.Composable; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| import org.apache.avalon.framework.configuration.Configurable; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| import org.apache.avalon.framework.configuration.ConfigurationException; | |||
| import org.apache.avalon.framework.context.Context; | |||
| import org.apache.avalon.framework.logger.AbstractLoggable; | |||
| import org.apache.avalon.framework.logger.Loggable; | |||
| import org.apache.log.Logger; | |||
| import org.apache.myrmidon.components.Configurer; | |||
| /** | |||
| * Class used to configure tasks. | |||
| @@ -35,18 +36,27 @@ public class DefaultConfigurer | |||
| extends AbstractLoggable | |||
| implements Configurer, Composable, Loggable | |||
| { | |||
| protected final static String RESERVED_ATTRIBUTES[] = | |||
| ///Compile time constant to turn on extreme debugging | |||
| private final static boolean DEBUG = false; | |||
| /* | |||
| * TODO: Should reserved names be "configurable" ? | |||
| */ | |||
| ///Attribute names that are reserved | |||
| private final static String RESERVED_ATTRIBUTES[] = | |||
| { | |||
| "id" | |||
| "id", "logger" | |||
| }; | |||
| protected final static String RESERVED_ELEMENTS[] = | |||
| ///Element names that are reserved | |||
| private final static String RESERVED_ELEMENTS[] = | |||
| { | |||
| "content" | |||
| }; | |||
| protected final static boolean DEBUG = false; | |||
| protected Converter m_converter; | |||
| ///Converter to use for converting between values | |||
| private Converter m_converter; | |||
| public void compose( final ComponentManager componentManager ) | |||
| throws ComponentException | |||
| @@ -62,7 +72,7 @@ public class DefaultConfigurer | |||
| * and if it does will pass the task the configuration - else it will use | |||
| * ants rules to map configuration to types | |||
| * | |||
| * @param tasklet the tasklet | |||
| * @param object the object | |||
| * @param configuration the configuration | |||
| * @param context the Context | |||
| * @exception ConfigurationException if an error occurs | |||
| @@ -102,7 +112,7 @@ public class DefaultConfigurer | |||
| if( DEBUG ) | |||
| { | |||
| getLogger().debug( "Configuring attribute name=" + name + | |||
| " value=" + value ); | |||
| " value=" + value ); | |||
| } | |||
| configureAttribute( object, name, value, context ); | |||
| @@ -147,18 +157,18 @@ public class DefaultConfigurer | |||
| * @param context the Context | |||
| * @exception ConfigurationException if an error occurs | |||
| */ | |||
| protected void configureContent( final Object object, | |||
| final String content, | |||
| final Context context ) | |||
| private void configureContent( final Object object, | |||
| final String content, | |||
| final Context context ) | |||
| throws ConfigurationException | |||
| { | |||
| setValue( object, "addContent", content, context ); | |||
| } | |||
| protected void configureAttribute( final Object object, | |||
| final String name, | |||
| final String value, | |||
| final Context context ) | |||
| private void configureAttribute( final Object object, | |||
| final String name, | |||
| final String value, | |||
| final Context context ) | |||
| throws ConfigurationException | |||
| { | |||
| for( int i = 0; i < RESERVED_ATTRIBUTES.length; i++ ) | |||
| @@ -170,10 +180,10 @@ public class DefaultConfigurer | |||
| setValue( object, methodName, value, context ); | |||
| } | |||
| protected void setValue( final Object object, | |||
| final String methodName, | |||
| final String value, | |||
| final Context context ) | |||
| private void setValue( final Object object, | |||
| final String methodName, | |||
| final String value, | |||
| final Context context ) | |||
| throws ConfigurationException | |||
| { | |||
| // OMFG the rest of this is soooooooooooooooooooooooooooooooo | |||
| @@ -192,10 +202,10 @@ public class DefaultConfigurer | |||
| setValue( object, value, context, methods ); | |||
| } | |||
| protected void setValue( final Object object, | |||
| final String value, | |||
| final Context context, | |||
| final Method methods[] ) | |||
| private void setValue( final Object object, | |||
| final String value, | |||
| final Context context, | |||
| final Method methods[] ) | |||
| throws ConfigurationException | |||
| { | |||
| try | |||
| @@ -212,10 +222,10 @@ public class DefaultConfigurer | |||
| } | |||
| } | |||
| protected void setValue( final Object object, | |||
| Object value, | |||
| final Method methods[], | |||
| final Context context ) | |||
| private void setValue( final Object object, | |||
| Object value, | |||
| final Method methods[], | |||
| final Context context ) | |||
| throws ConfigurationException | |||
| { | |||
| final Class sourceClass = value.getClass(); | |||
| @@ -234,12 +244,12 @@ public class DefaultConfigurer | |||
| source + " to a matching type" ); | |||
| } | |||
| protected boolean setValue( final Object object, | |||
| Object value, | |||
| final Method method, | |||
| final Class sourceClass, | |||
| final String source, | |||
| final Context context ) | |||
| private boolean setValue( final Object object, | |||
| Object value, | |||
| final Method method, | |||
| final Class sourceClass, | |||
| final String source, | |||
| final Context context ) | |||
| throws ConfigurationException | |||
| { | |||
| Class parameterType = method.getParameterTypes()[ 0 ]; | |||
| @@ -289,7 +299,7 @@ public class DefaultConfigurer | |||
| return true; | |||
| } | |||
| protected Class getComplexTypeFor( final Class clazz ) | |||
| private Class getComplexTypeFor( final Class clazz ) | |||
| { | |||
| if( String.class == clazz ) return String.class; | |||
| else if( Integer.TYPE.equals( clazz ) ) return Integer.class; | |||
| @@ -306,7 +316,7 @@ public class DefaultConfigurer | |||
| } | |||
| } | |||
| protected Method[] getMethodsFor( final Class clazz, final String methodName ) | |||
| private Method[] getMethodsFor( final Class clazz, final String methodName ) | |||
| { | |||
| final Method methods[] = clazz.getMethods(); | |||
| final ArrayList matches = new ArrayList(); | |||
| @@ -331,7 +341,7 @@ public class DefaultConfigurer | |||
| return (Method[])matches.toArray( new Method[0] ); | |||
| } | |||
| protected Method[] getCreateMethodsFor( final Class clazz, final String methodName ) | |||
| private Method[] getCreateMethodsFor( final Class clazz, final String methodName ) | |||
| { | |||
| final Method methods[] = clazz.getMethods(); | |||
| final ArrayList matches = new ArrayList(); | |||
| @@ -358,12 +368,12 @@ public class DefaultConfigurer | |||
| return (Method[])matches.toArray( new Method[0] ); | |||
| } | |||
| protected String getMethodNameFor( final String attribute ) | |||
| private String getMethodNameFor( final String attribute ) | |||
| { | |||
| return "set" + getJavaNameFor( attribute.toLowerCase() ); | |||
| } | |||
| protected String getJavaNameFor( final String name ) | |||
| private String getJavaNameFor( final String name ) | |||
| { | |||
| final StringBuffer sb = new StringBuffer(); | |||
| @@ -387,9 +397,9 @@ public class DefaultConfigurer | |||
| return sb.toString(); | |||
| } | |||
| protected void configureElement( final Object object, | |||
| final Configuration configuration, | |||
| final Context context ) | |||
| private void configureElement( final Object object, | |||
| final Configuration configuration, | |||
| final Context context ) | |||
| throws ConfigurationException | |||
| { | |||
| final String name = configuration.getName(); | |||
| @@ -427,10 +437,10 @@ public class DefaultConfigurer | |||
| } | |||
| } | |||
| protected void createElement( final Object object, | |||
| final Method method, | |||
| final Configuration configuration, | |||
| final Context context ) | |||
| private void createElement( final Object object, | |||
| final Method method, | |||
| final Configuration configuration, | |||
| final Context context ) | |||
| throws ConfigurationException | |||
| { | |||
| try | |||
| @@ -448,10 +458,10 @@ public class DefaultConfigurer | |||
| } | |||
| } | |||
| protected void addElement( final Object object, | |||
| final Method method, | |||
| final Configuration configuration, | |||
| final Context context ) | |||
| private void addElement( final Object object, | |||
| final Method method, | |||
| final Configuration configuration, | |||
| final Context context ) | |||
| throws ConfigurationException | |||
| { | |||
| try | |||
| @@ -0,0 +1,28 @@ | |||
| /* | |||
| * 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 file. | |||
| */ | |||
| package org.apache.myrmidon.framework; | |||
| import org.apache.ant.tasklet.DataType; | |||
| /** | |||
| * Interface for ItemSet. | |||
| * An item set contains a number of items. Example item sets include | |||
| * PatternSets, FileSets, FilterSets etc. | |||
| * | |||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
| */ | |||
| public interface ItemSet | |||
| extends DataType | |||
| { | |||
| /** | |||
| * Returns an array containing the items(s) contained within set. | |||
| * | |||
| * Question: should ItemSet be context sensitive???? | |||
| */ | |||
| Object[] getItems( /* Context context??? */ ); | |||
| } | |||
| @@ -0,0 +1,35 @@ | |||
| /* | |||
| * 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 file. | |||
| */ | |||
| package org.apache.myrmidon.framework; | |||
| import org.apache.ant.tasklet.DataType; | |||
| /** | |||
| * Interface for Mappers. | |||
| * Mappers are responsible for mapping source items to targets items. | |||
| * Example mappers will map source files to destination files | |||
| * (ie A.java to A.class). | |||
| * | |||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| */ | |||
| public interface Mapper | |||
| extends DataType | |||
| { | |||
| /** | |||
| * Returns an array containing the target items(s) for the | |||
| * given source file. | |||
| * | |||
| * <p>if the given rule doesn't apply to the input item, | |||
| * implementation must return null. Scanner will then | |||
| * omit the item in question.</p> | |||
| * | |||
| * @param item the item to be mapped | |||
| */ | |||
| Object[] mapItem( Object item ); | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| /* | |||
| * 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 file. | |||
| */ | |||
| package org.apache.myrmidon.framework; | |||
| import org.apache.avalon.framework.component.Component; | |||
| /** | |||
| * Interface for Scanners. | |||
| * | |||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
| */ | |||
| public interface Scanner | |||
| extends Component | |||
| { | |||
| } | |||