Remove the ugly hacks in Executor when it returned own registry (broke IOC). This no longer needed due to TypeManager git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269083 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -10,8 +10,6 @@ package org.apache.ant.modules.core; | |||
| import java.io.File; | |||
| import java.net.MalformedURLException; | |||
| import java.net.URL; | |||
| import org.apache.ant.tasklet.engine.DataTypeEngine; | |||
| import org.apache.avalon.framework.camelot.RegistryException; | |||
| import org.apache.avalon.framework.component.ComponentException; | |||
| import org.apache.avalon.framework.component.ComponentManager; | |||
| import org.apache.avalon.framework.component.Composable; | |||
| @@ -19,31 +17,28 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.components.deployer.TskDeployer; | |||
| import org.apache.myrmidon.components.executor.Executor; | |||
| import org.apache.myrmidon.components.type.TypeManager; | |||
| /** | |||
| * Method to register a single tasklet. | |||
| * Method to register a a typeet. | |||
| * | |||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
| */ | |||
| public abstract class AbstractResourceRegisterer | |||
| public abstract class AbstractTypeDefinition | |||
| extends AbstractTask | |||
| implements Composable | |||
| { | |||
| protected String m_lib; | |||
| protected String m_name; | |||
| protected String m_classname; | |||
| protected TskDeployer m_tskDeployer; | |||
| protected DataTypeEngine m_dataTypeEngine; | |||
| protected Executor m_engine; | |||
| private String m_lib; | |||
| private String m_name; | |||
| private String m_classname; | |||
| private TskDeployer m_tskDeployer; | |||
| private TypeManager m_typeManager; | |||
| public void compose( final ComponentManager componentManager ) | |||
| throws ComponentException | |||
| { | |||
| m_engine = (Executor)componentManager.lookup( Executor.ROLE ); | |||
| m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | |||
| m_tskDeployer = (TskDeployer)componentManager.lookup( TskDeployer.ROLE ); | |||
| m_dataTypeEngine = (DataTypeEngine)componentManager. | |||
| lookup( "org.apache.ant.tasklet.engine.DataTypeEngine" ); | |||
| } | |||
| public void setLib( final String lib ) | |||
| @@ -76,17 +71,20 @@ public abstract class AbstractResourceRegisterer | |||
| final URL url = getURL( m_lib ); | |||
| try | |||
| { | |||
| registerResource( m_name, m_classname, url ); | |||
| } | |||
| catch( final RegistryException re ) | |||
| { | |||
| throw new TaskException( "Error registering resource", re ); | |||
| } | |||
| registerResource( m_name, m_classname, url ); | |||
| } | |||
| protected final TskDeployer getDeployer() | |||
| { | |||
| return m_tskDeployer; | |||
| } | |||
| protected final TypeManager getTypeManager() | |||
| { | |||
| return m_typeManager; | |||
| } | |||
| protected URL getURL( final String libName ) | |||
| private final URL getURL( final String libName ) | |||
| throws TaskException | |||
| { | |||
| if( null != libName ) | |||
| @@ -105,5 +103,5 @@ public abstract class AbstractResourceRegisterer | |||
| } | |||
| protected abstract void registerResource( String name, String classname, URL url ) | |||
| throws TaskException, RegistryException; | |||
| throws TaskException; | |||
| } | |||
| @@ -1,43 +0,0 @@ | |||
| /* | |||
| * 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.ant.tasklet.engine; | |||
| import org.apache.ant.tasklet.DataType; | |||
| import org.apache.avalon.framework.component.Component; | |||
| import org.apache.avalon.framework.camelot.FactoryException; | |||
| import org.apache.avalon.framework.camelot.Registry; | |||
| import org.apache.avalon.framework.camelot.RegistryException; | |||
| /** | |||
| * This is basically a engine that can be used to access data-types. | |||
| * The engine acts as a repository and factory for these types. | |||
| * | |||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
| */ | |||
| public interface DataTypeEngine | |||
| extends Component | |||
| { | |||
| /** | |||
| * Retrieve registry of data-types. | |||
| * This is used by deployer to add types into engine. | |||
| * | |||
| * @return the registry | |||
| */ | |||
| Registry getRegistry(); | |||
| /** | |||
| * Create a data-type of type registered under name. | |||
| * | |||
| * @param name the name of data type | |||
| * @return the DataType | |||
| * @exception RegistryException if an error occurs | |||
| * @exception FactoryException if an error occurs | |||
| */ | |||
| DataType createDataType( String name ) | |||
| throws RegistryException, FactoryException; | |||
| } | |||
| @@ -1,71 +0,0 @@ | |||
| /* | |||
| * 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.ant.tasklet.engine; | |||
| import org.apache.ant.tasklet.DataType; | |||
| import org.apache.avalon.framework.component.ComponentManager; | |||
| import org.apache.avalon.framework.component.ComponentException; | |||
| import org.apache.avalon.framework.component.Composable; | |||
| import org.apache.avalon.framework.component.Composable; | |||
| import org.apache.avalon.framework.camelot.DefaultRegistry; | |||
| import org.apache.avalon.framework.camelot.Factory; | |||
| 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; | |||
| /** | |||
| * This is basically a engine that can be used to access data-types. | |||
| * The engine acts as a repository and factory for these types. | |||
| * | |||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
| */ | |||
| public class DefaultDataTypeEngine | |||
| implements DataTypeEngine, Composable | |||
| { | |||
| protected Factory m_factory; | |||
| protected Registry m_registry = new DefaultRegistry( Locator.class ); | |||
| /** | |||
| * Retrieve registry of data-types. | |||
| * This is used by deployer to add types into engine. | |||
| * | |||
| * @return the registry | |||
| */ | |||
| public Registry getRegistry() | |||
| { | |||
| return m_registry; | |||
| } | |||
| /** | |||
| * Retrieve relevent services needed to deploy. | |||
| * | |||
| * @param componentManager the ComponentManager | |||
| * @exception ComponentException if an error occurs | |||
| */ | |||
| public void compose( final ComponentManager componentManager ) | |||
| throws ComponentException | |||
| { | |||
| m_factory = (Factory)componentManager.lookup( "org.apache.avalon.framework.camelot.Factory" ); | |||
| } | |||
| /** | |||
| * Create a data-type of type registered under name. | |||
| * | |||
| * @param name the name of data type | |||
| * @return the DataType | |||
| * @exception RegistryException if an error occurs | |||
| * @exception FactoryException if an error occurs | |||
| */ | |||
| public DataType createDataType( final String name ) | |||
| throws RegistryException, FactoryException | |||
| { | |||
| final Locator locator = (Locator)m_registry.getInfo( name, Locator.class ); | |||
| return (DataType)m_factory.create( locator, DataType.class ); | |||
| } | |||
| } | |||
| @@ -18,7 +18,6 @@ import java.util.zip.ZipFile; | |||
| import org.apache.ant.convert.engine.ConverterEngine; | |||
| import org.apache.ant.convert.engine.ConverterRegistry; | |||
| import org.apache.ant.convert.engine.DefaultConverterInfo; | |||
| import org.apache.ant.tasklet.engine.DataTypeEngine; | |||
| import org.apache.avalon.framework.camelot.AbstractDeployer; | |||
| import org.apache.avalon.framework.camelot.DefaultLocator; | |||
| import org.apache.avalon.framework.camelot.DefaultRegistry; | |||
| @@ -9,7 +9,6 @@ package org.apache.myrmidon.components.embeddor; | |||
| import java.io.File; | |||
| import org.apache.ant.convert.engine.ConverterEngine; | |||
| import org.apache.ant.tasklet.engine.DataTypeEngine; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.avalon.framework.activity.Initializable; | |||
| import org.apache.avalon.framework.camelot.CamelotUtil; | |||
| @@ -44,7 +43,6 @@ public class MyrmidonEmbeddor | |||
| private ProjectBuilder m_builder; | |||
| private TskDeployer m_deployer; | |||
| private DataTypeEngine m_dataTypeEngine; | |||
| private TypeManager m_typeManager; | |||
| private ConverterEngine m_converterEngine; | |||
| @@ -139,7 +137,6 @@ public class MyrmidonEmbeddor | |||
| throws Exception | |||
| { | |||
| m_converterEngine = null; | |||
| m_dataTypeEngine = null; | |||
| m_executor = null; | |||
| m_projectManager = null; | |||
| m_builder = null; | |||
| @@ -172,8 +169,6 @@ public class MyrmidonEmbeddor | |||
| //create all the default properties for components | |||
| defaults.setParameter( "org.apache.ant.convert.engine.ConverterEngine", | |||
| "org.apache.ant.convert.engine.DefaultConverterEngine" ); | |||
| defaults.setParameter( "org.apache.ant.tasklet.engine.DataTypeEngine", | |||
| "org.apache.ant.tasklet.engine.DefaultDataTypeEngine" ); | |||
| defaults.setParameter( TypeManager.ROLE, | |||
| "org.apache.myrmidon.components.type.DefaultTypeManager" ); | |||
| @@ -203,7 +198,6 @@ public class MyrmidonEmbeddor | |||
| componentManager.put( "org.apache.ant.convert.engine.ConverterEngine", | |||
| m_converterEngine ); | |||
| componentManager.put( "org.apache.ant.convert.Converter", m_converterEngine ); | |||
| componentManager.put( "org.apache.ant.tasklet.engine.DataTypeEngine", m_dataTypeEngine ); | |||
| componentManager.put( "org.apache.avalon.framework.camelot.Factory", m_factory ); | |||
| //Following components required when Myrmidon is used as build tool | |||
| @@ -239,9 +233,6 @@ public class MyrmidonEmbeddor | |||
| component = getParameter( Configurer.ROLE ); | |||
| m_configurer = (Configurer)createComponent( component, Configurer.class ); | |||
| component = getParameter( "org.apache.ant.tasklet.engine.DataTypeEngine" ); | |||
| m_dataTypeEngine = (DataTypeEngine)createComponent( component, DataTypeEngine.class ); | |||
| component = getParameter( TypeManager.ROLE ); | |||
| m_typeManager = (TypeManager)createComponent( component, TypeManager.class ); | |||
| @@ -268,7 +259,6 @@ public class MyrmidonEmbeddor | |||
| { | |||
| setupComponent( m_factory ); | |||
| setupComponent( m_converterEngine ); | |||
| setupComponent( m_dataTypeEngine ); | |||
| setupComponent( m_executor ); | |||
| setupComponent( m_projectManager ); | |||
| setupComponent( m_builder ); | |||
| @@ -10,13 +10,6 @@ package org.apache.myrmidon.components.executor; | |||
| import org.apache.ant.convert.engine.ConverterEngine; | |||
| import org.apache.avalon.framework.activity.Disposable; | |||
| import org.apache.avalon.framework.activity.Initializable; | |||
| import org.apache.avalon.framework.camelot.DefaultFactory; | |||
| import org.apache.avalon.framework.camelot.DefaultRegistry; | |||
| import org.apache.avalon.framework.camelot.Factory; | |||
| 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; | |||
| @@ -41,18 +34,11 @@ public class DefaultExecutor | |||
| extends AbstractLoggable | |||
| implements Executor, Composable | |||
| { | |||
| //private Factory m_factory; | |||
| //private Registry m_registry = new DefaultRegistry( Locator.class ); | |||
| private Configurer m_configurer; | |||
| private ComponentSelector m_selector; | |||
| private ComponentManager m_componentManager; | |||
| public Registry getRegistry() | |||
| { | |||
| return null;//m_registry; | |||
| } | |||
| /** | |||
| * Retrieve relevent services needed to deploy. | |||
| * | |||
| @@ -105,19 +91,11 @@ public class DefaultExecutor | |||
| try | |||
| { | |||
| return (Task)m_selector.select( name ); | |||
| //final Locator locator = (Locator)m_registry.getInfo( name, Locator.class ); | |||
| //return (Task)m_factory.create( locator, Task.class ); | |||
| } | |||
| catch( final ComponentException ce ) | |||
| { | |||
| throw new TaskException( "Unable to create task " + name, ce ); | |||
| } | |||
| /* catch( final RegistryException re ) | |||
| { | |||
| throw new TaskException( "Unable to locate task " + name, re ); | |||
| } | |||
| catch( final FactoryException fe ) | |||
| */ | |||
| } | |||
| private void doConfigure( final Task task, | |||
| @@ -7,7 +7,6 @@ | |||
| */ | |||
| package org.apache.myrmidon.components.executor; | |||
| import org.apache.avalon.framework.camelot.Registry; | |||
| import org.apache.avalon.framework.component.Component; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| @@ -23,14 +22,6 @@ public interface Executor | |||
| { | |||
| String ROLE = "org.apache.myrmidon.components.executor.Executor"; | |||
| /** | |||
| * Retrieve locator registry associated with engine. | |||
| * TODO: Remove this as it violates IOC | |||
| * | |||
| * @return the LocatorRegistry | |||
| */ | |||
| Registry getRegistry(); | |||
| /** | |||
| * execute a task. | |||
| * | |||