git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269088 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -15,7 +15,6 @@ import org.apache.avalon.framework.component.ComponentManager; | |||||
| import org.apache.avalon.framework.component.Composable; | import org.apache.avalon.framework.component.Composable; | ||||
| import org.apache.myrmidon.api.AbstractTask; | import org.apache.myrmidon.api.AbstractTask; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.components.converter.ConverterInfo; | |||||
| import org.apache.myrmidon.components.converter.ConverterRegistry; | import org.apache.myrmidon.components.converter.ConverterRegistry; | ||||
| import org.apache.myrmidon.components.deployer.DeploymentException; | import org.apache.myrmidon.components.deployer.DeploymentException; | ||||
| import org.apache.myrmidon.components.deployer.TskDeployer; | import org.apache.myrmidon.components.deployer.TskDeployer; | ||||
| @@ -110,13 +109,11 @@ public class RegisterConverter | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| final ConverterInfo info = new ConverterInfo( m_sourceType, m_destinationType ); | |||||
| m_converterRegistry.registerConverterInfo( m_classname, info ); | |||||
| final DefaultComponentFactory factory = | |||||
| new DefaultComponentFactory( new URL[] { url } ); | |||||
| m_converterRegistry.registerConverter( m_classname, m_sourceType, m_destinationType ); | |||||
| final DefaultComponentFactory factory = new DefaultComponentFactory( new URL[] { url } ); | |||||
| factory.addNameClassMapping( m_classname, m_classname ); | factory.addNameClassMapping( m_classname, m_classname ); | ||||
| try { m_typeManager.registerType( Converter.ROLE, m_classname, factory ); } | try { m_typeManager.registerType( Converter.ROLE, m_classname, factory ); } | ||||
| catch( final Exception e ) | catch( final Exception e ) | ||||
| { | { | ||||
| @@ -1,48 +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.myrmidon.components.converter; | |||||
| /** | |||||
| * This info represents meta-information about a converter. | |||||
| * | |||||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
| */ | |||||
| public class ConverterInfo | |||||
| { | |||||
| private final String m_source; | |||||
| private final String m_destination; | |||||
| public ConverterInfo( final String source, final String destination ) | |||||
| { | |||||
| m_source = source; | |||||
| m_destination = destination; | |||||
| } | |||||
| /** | |||||
| * Retrieve the source type from which it can convert. | |||||
| * NB: Should this be an array ???? | |||||
| * | |||||
| * @return the classname from which object produced | |||||
| */ | |||||
| public String getSource() | |||||
| { | |||||
| return m_source; | |||||
| } | |||||
| /** | |||||
| * Retrieve the type to which the converter converts. | |||||
| * NB: Should this be an array ???? | |||||
| * | |||||
| * @return the classname of the produced object | |||||
| */ | |||||
| public String getDestination() | |||||
| { | |||||
| return m_destination; | |||||
| } | |||||
| } | |||||
| @@ -27,13 +27,14 @@ public interface ConverterRegistry | |||||
| * @param destination the destination classname | * @param destination the destination classname | ||||
| * @return the className of converter or null if none available | * @return the className of converter or null if none available | ||||
| */ | */ | ||||
| String getConverterInfoName( String source, String destination ); | |||||
| String getConverterName( String source, String destination ); | |||||
| /** | /** | ||||
| * Register a converter-info | |||||
| * Register a converter | |||||
| * | * | ||||
| * @param className the className of converter | * @param className the className of converter | ||||
| * @param info the ConverterInfo | |||||
| * @param source the source classname | |||||
| * @param destination the destination classname | |||||
| */ | */ | ||||
| void registerConverterInfo( String className, ConverterInfo info ); | |||||
| void registerConverter( String className, String source, String destination ); | |||||
| } | } | ||||
| @@ -10,7 +10,7 @@ package org.apache.myrmidon.components.converter; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| /** | /** | ||||
| * Default implementation of ConverterInfo registry. | |||||
| * Default implementation of Converter registry. | |||||
| * | * | ||||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | ||||
| */ | */ | ||||
| @@ -19,18 +19,17 @@ public class DefaultConverterRegistry | |||||
| { | { | ||||
| private final HashMap m_mapping = new HashMap(); | private final HashMap m_mapping = new HashMap(); | ||||
| public String getConverterInfoName( final String source, final String destination ) | |||||
| public String getConverterName( final String source, final String destination ) | |||||
| { | { | ||||
| final HashMap map = (HashMap)m_mapping.get( source ); | final HashMap map = (HashMap)m_mapping.get( source ); | ||||
| if( null == map ) return null; | if( null == map ) return null; | ||||
| return (String)map.get( destination ); | return (String)map.get( destination ); | ||||
| } | } | ||||
| public void registerConverterInfo( final String className, final ConverterInfo info ) | |||||
| public void registerConverter( final String className, | |||||
| final String source, | |||||
| final String destination ) | |||||
| { | { | ||||
| final String source = info.getSource(); | |||||
| final String destination = info.getDestination(); | |||||
| HashMap map = (HashMap)m_mapping.get( source ); | HashMap map = (HashMap)m_mapping.get( source ); | ||||
| if( null == map ) | if( null == map ) | ||||
| { | { | ||||
| @@ -29,7 +29,7 @@ public class DefaultMasterConverter | |||||
| { | { | ||||
| private final static boolean DEBUG = false; | private final static boolean DEBUG = false; | ||||
| private ConverterRegistry m_infoRegistry; | |||||
| private ConverterRegistry m_registry; | |||||
| private ComponentSelector m_selector; | private ComponentSelector m_selector; | ||||
| /** | /** | ||||
| @@ -41,7 +41,7 @@ public class DefaultMasterConverter | |||||
| public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
| throws ComponentException | throws ComponentException | ||||
| { | { | ||||
| m_infoRegistry = (ConverterRegistry)componentManager.lookup( ConverterRegistry.ROLE ); | |||||
| m_registry = (ConverterRegistry)componentManager.lookup( ConverterRegistry.ROLE ); | |||||
| final TypeManager typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | final TypeManager typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | ||||
| m_selector = (ComponentSelector)typeManager.lookup( Converter.ROLE + "Selector" ); | m_selector = (ComponentSelector)typeManager.lookup( Converter.ROLE + "Selector" ); | ||||
| @@ -73,9 +73,8 @@ public class DefaultMasterConverter | |||||
| } | } | ||||
| //TODO: Start searching inheritance hierarchy for converter | //TODO: Start searching inheritance hierarchy for converter | ||||
| final String name = | |||||
| m_infoRegistry.getConverterInfoName( originalClass.getName(), | |||||
| destination.getName() ); | |||||
| final String name = m_registry.getConverterName( originalClass.getName(), | |||||
| destination.getName() ); | |||||
| if( null == name ) | if( null == name ) | ||||
| { | { | ||||
| @@ -26,7 +26,6 @@ import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; | |||||
| import org.apache.avalon.framework.logger.AbstractLoggable; | import org.apache.avalon.framework.logger.AbstractLoggable; | ||||
| import org.apache.myrmidon.api.Task; | import org.apache.myrmidon.api.Task; | ||||
| import org.apache.myrmidon.api.DataType; | import org.apache.myrmidon.api.DataType; | ||||
| import org.apache.myrmidon.components.converter.ConverterInfo; | |||||
| import org.apache.myrmidon.components.converter.ConverterRegistry; | import org.apache.myrmidon.components.converter.ConverterRegistry; | ||||
| import org.apache.myrmidon.components.executor.Executor; | import org.apache.myrmidon.components.executor.Executor; | ||||
| import org.apache.myrmidon.components.type.ComponentFactory; | import org.apache.myrmidon.components.type.ComponentFactory; | ||||
| @@ -46,8 +45,8 @@ public class DefaultTskDeployer | |||||
| { | { | ||||
| private final static String TSKDEF_FILE = "TASK-LIB/taskdefs.xml"; | private final static String TSKDEF_FILE = "TASK-LIB/taskdefs.xml"; | ||||
| private DefaultConfigurationBuilder m_configurationBuilder; | |||||
| private ConverterRegistry m_converterInfoRegistry; | |||||
| private DefaultConfigurationBuilder m_configurationBuilder = new DefaultConfigurationBuilder(); | |||||
| private ConverterRegistry m_converterRegistry; | |||||
| private TypeManager m_typeManager; | private TypeManager m_typeManager; | ||||
| /** | /** | ||||
| @@ -68,7 +67,7 @@ public class DefaultTskDeployer | |||||
| public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
| throws ComponentException | throws ComponentException | ||||
| { | { | ||||
| m_converterInfoRegistry = (ConverterRegistry)componentManager.lookup( ConverterRegistry.ROLE ); | |||||
| m_converterRegistry = (ConverterRegistry)componentManager.lookup( ConverterRegistry.ROLE ); | |||||
| m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | ||||
| } | } | ||||
| @@ -245,16 +244,6 @@ public class DefaultTskDeployer | |||||
| } | } | ||||
| } | } | ||||
| private DefaultConfigurationBuilder getBuilder() | |||||
| { | |||||
| if( null == m_configurationBuilder ) | |||||
| { | |||||
| m_configurationBuilder = new DefaultConfigurationBuilder(); | |||||
| } | |||||
| return m_configurationBuilder; | |||||
| } | |||||
| /** | /** | ||||
| * Retrieve zip file for file. | * Retrieve zip file for file. | ||||
| * | * | ||||
| @@ -298,7 +287,7 @@ public class DefaultTskDeployer | |||||
| private Configuration buildConfiguration( final InputStream input ) | private Configuration buildConfiguration( final InputStream input ) | ||||
| throws DeploymentException | throws DeploymentException | ||||
| { | { | ||||
| try { return getBuilder().build( input ); } | |||||
| try { return m_configurationBuilder.build( input ); } | |||||
| catch( final SAXException se ) | catch( final SAXException se ) | ||||
| { | { | ||||
| throw new DeploymentException( "Malformed configuration data", se ); | throw new DeploymentException( "Malformed configuration data", se ); | ||||
| @@ -354,8 +343,7 @@ public class DefaultTskDeployer | |||||
| final String source = converter.getAttribute( "source" ); | final String source = converter.getAttribute( "source" ); | ||||
| final String destination = converter.getAttribute( "destination" ); | final String destination = converter.getAttribute( "destination" ); | ||||
| final ConverterInfo info = new ConverterInfo( source, destination ); | |||||
| m_converterInfoRegistry.registerConverterInfo( name, info ); | |||||
| m_converterRegistry.registerConverter( name, source, destination ); | |||||
| factory.addNameClassMapping( name, name ); | factory.addNameClassMapping( name, name ); | ||||
| m_typeManager.registerType( Converter.ROLE, name, factory ); | m_typeManager.registerType( Converter.ROLE, name, factory ); | ||||