Submitted By: "Adam Murdoch" <adammurdoch_ml@yahoo.com> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270852 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -11,9 +11,6 @@ import java.io.File; | |||
| import java.net.URL; | |||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
| import org.apache.avalon.excalibur.i18n.Resources; | |||
| import org.apache.avalon.framework.component.ComponentException; | |||
| import org.apache.avalon.framework.component.ComponentManager; | |||
| import org.apache.avalon.framework.component.Composable; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.converter.Converter; | |||
| @@ -28,7 +25,6 @@ import org.apache.myrmidon.interfaces.type.TypeManager; | |||
| */ | |||
| public class ConverterDef | |||
| extends AbstractTask | |||
| implements Composable | |||
| { | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( ConverterDef.class ); | |||
| @@ -37,15 +33,6 @@ public class ConverterDef | |||
| private String m_destinationType; | |||
| private File m_lib; | |||
| private String m_classname; | |||
| private ConverterRegistry m_converterRegistry; | |||
| private TypeManager m_typeManager; | |||
| public void compose( final ComponentManager componentManager ) | |||
| throws ComponentException | |||
| { | |||
| m_converterRegistry = (ConverterRegistry)componentManager.lookup( ConverterRegistry.ROLE ); | |||
| m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | |||
| } | |||
| public void setLib( final File lib ) | |||
| { | |||
| @@ -93,13 +80,15 @@ public class ConverterDef | |||
| try | |||
| { | |||
| m_converterRegistry.registerConverter( m_classname, m_sourceType, m_destinationType ); | |||
| final ConverterRegistry converterRegistry = (ConverterRegistry)getService( ConverterRegistry.class ); | |||
| converterRegistry.registerConverter( m_classname, m_sourceType, m_destinationType ); | |||
| final URL url = m_lib.toURL(); | |||
| final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[]{url} ); | |||
| factory.addNameClassMapping( m_classname, m_classname ); | |||
| m_typeManager.registerType( Converter.ROLE, m_classname, factory ); | |||
| final TypeManager typeManager = (TypeManager)getService( TypeManager.class ); | |||
| typeManager.registerType( Converter.ROLE, m_classname, factory ); | |||
| } | |||
| catch( final Exception e ) | |||
| { | |||
| @@ -9,9 +9,6 @@ package org.apache.antlib.runtime; | |||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
| import org.apache.avalon.excalibur.i18n.Resources; | |||
| 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.Configurable; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| import org.apache.avalon.framework.configuration.ConfigurationException; | |||
| @@ -19,9 +16,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.aspects.AspectHandler; | |||
| import org.apache.myrmidon.framework.AbstractContainerTask; | |||
| import org.apache.myrmidon.interfaces.aspect.AspectManager; | |||
| import org.apache.myrmidon.interfaces.type.TypeException; | |||
| import org.apache.myrmidon.interfaces.type.TypeFactory; | |||
| import org.apache.myrmidon.interfaces.type.TypeManager; | |||
| /** | |||
| * Task that definesMethod to register a single converter. | |||
| @@ -30,7 +25,7 @@ import org.apache.myrmidon.interfaces.type.TypeManager; | |||
| */ | |||
| public class Facility | |||
| extends AbstractContainerTask | |||
| implements Composable, Configurable | |||
| implements Configurable | |||
| { | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( Facility.class ); | |||
| @@ -38,28 +33,6 @@ public class Facility | |||
| private String m_namespace; | |||
| private AspectHandler m_aspectHandler; | |||
| private AspectManager m_aspectManager; | |||
| private TypeFactory m_factory; | |||
| public void compose( final ComponentManager componentManager ) | |||
| throws ComponentException | |||
| { | |||
| super.compose( componentManager ); | |||
| m_aspectManager = (AspectManager)componentManager.lookup( AspectManager.ROLE ); | |||
| final TypeManager typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | |||
| try | |||
| { | |||
| m_factory = typeManager.getFactory( AspectHandler.ROLE ); | |||
| } | |||
| catch( final TypeException te ) | |||
| { | |||
| final String message = REZ.getString( "facility.no-factory.error" ); | |||
| throw new ComponentException( message, te ); | |||
| } | |||
| } | |||
| public void configure( final Configuration configuration ) | |||
| throws ConfigurationException | |||
| { | |||
| @@ -77,7 +50,8 @@ public class Facility | |||
| { | |||
| try | |||
| { | |||
| m_aspectHandler = (AspectHandler)m_factory.create( children[ 0 ].getName() ); | |||
| final TypeFactory typeFactory = getTypeFactory( AspectHandler.ROLE ); | |||
| m_aspectHandler = (AspectHandler)typeFactory.create( children[ 0 ].getName() ); | |||
| } | |||
| catch( final Exception e ) | |||
| { | |||
| @@ -109,6 +83,7 @@ public class Facility | |||
| throw new TaskException( message ); | |||
| } | |||
| m_aspectManager.addAspectHandler( m_namespace, m_aspectHandler ); | |||
| final AspectManager aspectManager = (AspectManager)getService( AspectManager.class ); | |||
| aspectManager.addAspectHandler( m_namespace, m_aspectHandler ); | |||
| } | |||
| } | |||
| @@ -10,9 +10,6 @@ package org.apache.antlib.runtime; | |||
| import java.io.File; | |||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
| import org.apache.avalon.excalibur.i18n.Resources; | |||
| import org.apache.avalon.framework.component.ComponentException; | |||
| import org.apache.avalon.framework.component.ComponentManager; | |||
| import org.apache.avalon.framework.component.Composable; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.interfaces.deployer.Deployer; | |||
| @@ -25,19 +22,11 @@ import org.apache.myrmidon.interfaces.deployer.DeploymentException; | |||
| */ | |||
| public class Import | |||
| extends AbstractTask | |||
| implements Composable | |||
| { | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( Import.class ); | |||
| private File m_lib; | |||
| private Deployer m_deployer; | |||
| public void compose( final ComponentManager componentManager ) | |||
| throws ComponentException | |||
| { | |||
| m_deployer = (Deployer)componentManager.lookup( Deployer.ROLE ); | |||
| } | |||
| public void setLib( final File lib ) | |||
| { | |||
| @@ -55,7 +44,8 @@ public class Import | |||
| try | |||
| { | |||
| m_deployer.deploy( m_lib ); | |||
| final Deployer deployer = (Deployer)getService( Deployer.class ); | |||
| deployer.deploy( m_lib ); | |||
| } | |||
| catch( final DeploymentException de ) | |||
| { | |||
| @@ -4,7 +4,6 @@ converterdef.no-destination.error=Must specify the destination-type parameter. | |||
| converterdef.no-lib.error=Must specify the lib parameter. | |||
| converterdef.no-register.error=Failed to register converter {0}. | |||
| facility.no-factory.error=Unable to retrieve AspectHandler factory from TypeManager. | |||
| facility.no-create.error=Failed to create aspect handler of type {0}. | |||
| facility.multi-element.error=Expected one sub-element to configure facility. | |||
| facility.no-namespace.error=Must specify namespace parameter. | |||