From 19600e6d005c8bebbf6697bd00516e843f0a34f4 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Wed, 6 Dec 2000 06:11:28 +0000 Subject: [PATCH] Refactored proposal so it is more inline with apporpriate design patterns. Added in a number of new tasks to demonstrate interaction with tasklet runtime. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268316 13f79535-47bb-0310-9956-ffa450edef68 --- proposal/myrmidon/lib/avalonapi.jar | Bin 161795 -> 161852 bytes .../src/java/org/apache/ant/Main.java | 7 +- .../org/apache/ant/convert/Converter.java | 2 +- .../apache/ant/convert/ConverterEngine.java | 20 ++ .../ant/convert/ConverterException.java | 41 +++ .../ant/convert/DefaultConverterEngine.java | 72 ++++ .../convert/core/StringToClassConverter.java | 31 ++ .../convert/core/StringToURLConverter.java | 32 ++ .../ant/convert/core/converters.properties | 2 + .../ant/project/DefaultProjectEngine.java | 51 +-- .../org/apache/ant/project/ProjectEngine.java | 11 +- .../engine/DefaultTaskletConfigurer.java | 30 +- .../tasklet/engine/DefaultTaskletEngine.java | 87 +++-- .../tasklet/engine/DefaultTskDeployer.java | 309 ++++++++++++++++++ .../ant/tasklet/engine/TaskletConfigurer.java | 2 + .../engine/TaskletConverterEngine.java | 29 ++ .../ant/tasklet/engine/TaskletEngine.java | 17 +- .../ant/tasklet/engine/TskDeployer.java | 191 +---------- .../core/AbstractResourceRegisterer.java | 103 ++++++ .../ant/tasks/core/RegisterConverter.java | 139 ++++++++ .../ant/tasks/core/RegisterTasklet.java | 99 +----- .../ant/tasks/core/RegisterTasklib.java | 72 ++++ .../apache/ant/tasks/core/taskdefs.properties | 2 + proposal/myrmidon/src/make/sample.xmk | 13 +- proposal/myrmidon/src/script/ant | 4 +- 25 files changed, 977 insertions(+), 389 deletions(-) create mode 100644 proposal/myrmidon/src/java/org/apache/ant/convert/ConverterEngine.java create mode 100644 proposal/myrmidon/src/java/org/apache/ant/convert/ConverterException.java create mode 100644 proposal/myrmidon/src/java/org/apache/ant/convert/DefaultConverterEngine.java create mode 100644 proposal/myrmidon/src/java/org/apache/ant/convert/core/StringToClassConverter.java create mode 100644 proposal/myrmidon/src/java/org/apache/ant/convert/core/StringToURLConverter.java create mode 100644 proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTskDeployer.java create mode 100644 proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletConverterEngine.java create mode 100644 proposal/myrmidon/src/java/org/apache/ant/tasks/core/AbstractResourceRegisterer.java create mode 100644 proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterConverter.java create mode 100644 proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterTasklib.java diff --git a/proposal/myrmidon/lib/avalonapi.jar b/proposal/myrmidon/lib/avalonapi.jar index fdf0857cf1a21f3ba302a4f6edf8274072edef76..acd6ca71e5c1393c1f758fee824b87634ffb0d09 100644 GIT binary patch delta 13470 zcmZu&30zOx6Yt*keJ|}Lv}!MHQXy#Yf_XY zr3E2T*`A&MoO27m_x^o8_xPp2}L(%-K!@ztFz_YX!{zc;#QQ9o2N@14C3;sVe z#1K>73A`^DnKH4a)(ee)8-S-ez-x}DArjC~I4!{v;}anhpQW`~_I$FuPYFt!wS-TK z+++IDVfqC=3*KJf&(P2=ilGHrqxludvyVFS9L2A|^;`@A)Y zZ4PE2tWD#DSV&wdGdNAwPwvOT`f>ZUTa#w!HE-UT@K8otu6*6xV*21d#|=|Yda+_{ zBh7Sfdbst=%hz-b&Z=+cl|27q_QSLD$G@3=|82l0_mGU|H^+#3I%=5Nu$wx+z8Y*t z=9%B$^(O}YrM^OO8Y{bENJNP}|Jjvec{Z`O7aO16{JVFZCOf)SGSl8%@l~Z;{$%Fabq*IU^5AT;vA2!rU2VO?vaI?%%B{@axj{SqgKtGg-TiXIqbmw|+poWx@cj+N zZao??eNnxk;M`{MC6+Nd7GrX?^L6F+qhPjW^o(uSkBHBc33cQ*7Ay z@c5F$A*z)%^PU|pSuJbRqGUEP_`E@JetWZ9=$Bi&cYG}3yZtie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(MvAo36dvG-EP!#T4iY{(MRYeaNKUMOrL?EAT&UcQXwD diff --git a/proposal/myrmidon/src/java/org/apache/ant/Main.java b/proposal/myrmidon/src/java/org/apache/ant/Main.java index 59aa2a7f8..8446af2e7 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/Main.java +++ b/proposal/myrmidon/src/java/org/apache/ant/Main.java @@ -30,9 +30,10 @@ import org.apache.ant.project.ProjectListener; import org.apache.ant.project.ProjectToListenerAdapter; import org.apache.ant.tasklet.JavaVersion; import org.apache.ant.tasklet.TaskletContext; +import org.apache.ant.tasklet.engine.TaskletEngine; +import org.apache.ant.tasklet.engine.TskDeployer; import org.apache.avalon.Disposable; import org.apache.avalon.Initializable; -import org.apache.avalon.camelot.Deployer; import org.apache.avalon.camelot.DeploymentException; import org.apache.avalon.util.ObjectUtil; import org.apache.avalon.util.StringUtil; @@ -241,7 +242,7 @@ public class Main * @param clOptions the list of command line options */ protected void execute( final List clOptions ) - throws Throwable + throws Exception { final int size = clOptions.size(); final ArrayList targets = new ArrayList(); @@ -384,7 +385,7 @@ public class Main final ExtensionFileFilter filter = new ExtensionFileFilter( ".tsk" ); final File[] files = taskLibDirectory.listFiles( filter ); - final Deployer deployer = engine.getDeployer(); + final TskDeployer deployer = engine.getTaskletEngine().getTskDeployer(); for( int i = 0; i < files.length; i++ ) { diff --git a/proposal/myrmidon/src/java/org/apache/ant/convert/Converter.java b/proposal/myrmidon/src/java/org/apache/ant/convert/Converter.java index bcbdfcb33..91f2d37c8 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/convert/Converter.java +++ b/proposal/myrmidon/src/java/org/apache/ant/convert/Converter.java @@ -25,5 +25,5 @@ public interface Converter * @exception Exception if an error occurs */ Object convert( Class destination, Object original ) - throws Exception; + throws ConverterException, Exception; } diff --git a/proposal/myrmidon/src/java/org/apache/ant/convert/ConverterEngine.java b/proposal/myrmidon/src/java/org/apache/ant/convert/ConverterEngine.java new file mode 100644 index 000000000..fc946e132 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/convert/ConverterEngine.java @@ -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.ant.convert; + +import org.apache.avalon.Component; +import org.apache.log.Logger; + +public interface ConverterEngine + extends Component, Converter +{ + void setLogger( Logger logger ); + + ConverterRegistry getConverterRegistry(); + ConverterFactory getConverterFactory(); +} diff --git a/proposal/myrmidon/src/java/org/apache/ant/convert/ConverterException.java b/proposal/myrmidon/src/java/org/apache/ant/convert/ConverterException.java new file mode 100644 index 000000000..9ccd7aed7 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/convert/ConverterException.java @@ -0,0 +1,41 @@ +/* + * 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.convert; + +import org.apache.ant.AntException; + +/** + * ConverterException thrown when a problem occurs during convertion etc. + * + * @author Peter Donald + */ +public class ConverterException + extends AntException +{ + /** + * Basic constructor with a message + * + * @param message the message + */ + public ConverterException( final String message ) + { + this( message, null ); + } + + /** + * Constructor that builds cascade so that other exception information can be retained. + * + * @param message the message + * @param throwable the throwable + */ + public ConverterException( final String message, final Throwable throwable ) + { + super( message, throwable ); + } +} + diff --git a/proposal/myrmidon/src/java/org/apache/ant/convert/DefaultConverterEngine.java b/proposal/myrmidon/src/java/org/apache/ant/convert/DefaultConverterEngine.java new file mode 100644 index 000000000..31e650436 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/convert/DefaultConverterEngine.java @@ -0,0 +1,72 @@ +/* + * 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.convert; + +import org.apache.ant.AntException; +import org.apache.avalon.Component; +import org.apache.avalon.Initializable; +import org.apache.log.Logger; + +public class DefaultConverterEngine + implements ConverterEngine, Initializable +{ + protected ConverterFactory m_converterFactory; + protected ConverterRegistry m_converterRegistry; + protected Logger m_logger; + + public void setLogger( final Logger logger ) + { + m_logger = logger; + } + + public ConverterRegistry getConverterRegistry() + { + return m_converterRegistry; + } + + public ConverterFactory getConverterFactory() + { + return m_converterFactory; + } + + public void init() + throws Exception + { + m_converterRegistry = createConverterRegistry(); + m_converterFactory = createConverterFactory(); + } + + protected ConverterRegistry createConverterRegistry() + { + return new DefaultConverterRegistry(); + } + + protected ConverterFactory createConverterFactory() + { + return new DefaultConverterFactory(); + } + + public Object convert( Class destination, final Object original ) + throws Exception + { + final ConverterInfo info = + m_converterRegistry.getConverterInfo( original.getClass().getName(), + destination.getName() ); + + if( null == info ) + { + throw new ConverterException( "Unable to find converter for " + + original.getClass() + " to " + destination + + " conversion" ); + } + + final ConverterEntry entry = m_converterFactory.create( info ); + final Converter converter = entry.getConverter(); + return converter.convert( destination, original ); + } +} diff --git a/proposal/myrmidon/src/java/org/apache/ant/convert/core/StringToClassConverter.java b/proposal/myrmidon/src/java/org/apache/ant/convert/core/StringToClassConverter.java new file mode 100644 index 000000000..99d6b568a --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/convert/core/StringToClassConverter.java @@ -0,0 +1,31 @@ +/* + * 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.convert.core; + +import org.apache.ant.convert.AbstractConverter; + +/** + * String to class converter + * + * @author Peter Donald + */ +public class StringToClassConverter + extends AbstractConverter +{ + public StringToClassConverter() + { + super( String.class, Class.class ); + } + + public Object convert( final Object original ) + throws Exception + { + return Class.forName( (String)original ); + } +} + diff --git a/proposal/myrmidon/src/java/org/apache/ant/convert/core/StringToURLConverter.java b/proposal/myrmidon/src/java/org/apache/ant/convert/core/StringToURLConverter.java new file mode 100644 index 000000000..ce262e182 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/convert/core/StringToURLConverter.java @@ -0,0 +1,32 @@ +/* + * 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.convert.core; + +import java.net.URL; +import org.apache.ant.convert.AbstractConverter; + +/** + * String to url converter + * + * @author Peter Donald + */ +public class StringToURLConverter + extends AbstractConverter +{ + public StringToURLConverter() + { + super( String.class, URL.class ); + } + + public Object convert( final Object original ) + throws Exception + { + return new URL( (String)original ); + } +} + diff --git a/proposal/myrmidon/src/java/org/apache/ant/convert/core/converters.properties b/proposal/myrmidon/src/java/org/apache/ant/convert/core/converters.properties index 52c6bb2a5..f40d2ce4c 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/convert/core/converters.properties +++ b/proposal/myrmidon/src/java/org/apache/ant/convert/core/converters.properties @@ -4,3 +4,5 @@ org.apache.ant.convert.core.StringToShortConverter=java.lang.String, java.lang.S org.apache.ant.convert.core.StringToByteConverter=java.lang.String, java.lang.Byte org.apache.ant.convert.core.StringToDoubleConverter=java.lang.String, java.lang.Double org.apache.ant.convert.core.StringToFloatConverter=java.lang.String, java.lang.Float +org.apache.ant.convert.core.StringToClassConverter=java.lang.String, java.lang.Class +org.apache.ant.convert.core.StringToURLConverter=java.lang.String, java.net.URL diff --git a/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectEngine.java b/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectEngine.java index 8628a3844..e6374c897 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectEngine.java +++ b/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectEngine.java @@ -11,31 +11,19 @@ import java.util.ArrayList; import java.util.Iterator; import org.apache.ant.AntException; import org.apache.ant.configuration.Configuration; -import org.apache.ant.convert.ConverterRegistry; -import org.apache.ant.convert.DefaultConverterRegistry; import org.apache.ant.tasklet.DefaultTaskletContext; import org.apache.ant.tasklet.TaskletContext; import org.apache.ant.tasklet.engine.DefaultTaskletEngine; -import org.apache.ant.tasklet.engine.DefaultTaskletInfo; -import org.apache.ant.tasklet.engine.DefaultTaskletRegistry; import org.apache.ant.tasklet.engine.TaskletEngine; -import org.apache.ant.tasklet.engine.TaskletRegistry; -import org.apache.ant.tasklet.engine.TskDeployer; import org.apache.avalon.Composer; import org.apache.avalon.DefaultComponentManager; import org.apache.avalon.Disposable; import org.apache.avalon.Initializable; -import org.apache.avalon.camelot.Deployer; -import org.apache.avalon.camelot.DeploymentException; -import org.apache.avalon.camelot.RegistryException; import org.apache.log.Logger; public class DefaultProjectEngine implements ProjectEngine, Initializable, Disposable { - protected Deployer m_deployer; - protected TaskletRegistry m_taskletRegistry; - protected ConverterRegistry m_converterRegistry; protected TaskletEngine m_taskletEngine; protected Logger m_logger; protected ProjectListenerSupport m_listenerSupport; @@ -61,15 +49,13 @@ public class DefaultProjectEngine { m_listenerSupport = new ProjectListenerSupport(); - m_taskletRegistry = createTaskletRegistry(); - m_converterRegistry = createConverterRegistry(); - m_deployer = createDeployer(); - setupTaskletEngine(); m_componentManager = new DefaultComponentManager(); m_componentManager.put( "org.apache.ant.project.ProjectEngine", this ); m_componentManager.put( "org.apache.ant.tasklet.engine.TaskletEngine", m_taskletEngine ); + m_componentManager.put( "org.apache.ant.convert.ConverterEngine", + m_taskletEngine.getConverterEngine() ); } public void dispose() @@ -81,9 +67,9 @@ public class DefaultProjectEngine } } - public Deployer getDeployer() + public TaskletEngine getTaskletEngine() { - return m_deployer; + return m_taskletEngine; } protected void setupTaskletEngine() @@ -92,17 +78,6 @@ public class DefaultProjectEngine m_taskletEngine = createTaskletEngine(); m_taskletEngine.setLogger( m_logger ); - if( m_taskletEngine instanceof Composer ) - { - final DefaultComponentManager componentManager = new DefaultComponentManager(); - componentManager.put( "org.apache.ant.tasklet.engine.TaskletRegistry", - m_taskletRegistry ); - componentManager.put( "org.apache.ant.convert.ConverterRegistry", - m_converterRegistry ); - - ((Composer)m_taskletEngine).compose( componentManager ); - } - if( m_taskletEngine instanceof Initializable ) { ((Initializable)m_taskletEngine).init(); @@ -114,24 +89,6 @@ public class DefaultProjectEngine return new DefaultTaskletEngine(); } - protected TaskletRegistry createTaskletRegistry() - { - return new DefaultTaskletRegistry(); - } - - protected ConverterRegistry createConverterRegistry() - { - return new DefaultConverterRegistry(); - } - - protected Deployer createDeployer() - { - final TskDeployer deployer = - new TskDeployer( m_taskletRegistry, m_converterRegistry ); - deployer.setLogger( m_logger ); - return deployer; - } - public void execute( final Project project, final String target ) throws AntException { diff --git a/proposal/myrmidon/src/java/org/apache/ant/project/ProjectEngine.java b/proposal/myrmidon/src/java/org/apache/ant/project/ProjectEngine.java index 46cf41886..6cba6d91f 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/project/ProjectEngine.java +++ b/proposal/myrmidon/src/java/org/apache/ant/project/ProjectEngine.java @@ -9,20 +9,23 @@ package org.apache.ant.project; import org.apache.ant.AntException; import org.apache.ant.tasklet.TaskletContext; +import org.apache.ant.tasklet.engine.TaskletEngine; import org.apache.avalon.Component; -import org.apache.avalon.camelot.Deployer; -import org.apache.avalon.camelot.Registry; import org.apache.log.Logger; public interface ProjectEngine extends Component { - Deployer getDeployer(); + void setLogger( Logger logger ); + + TaskletEngine getTaskletEngine(); + void addProjectListener( ProjectListener listener ); void removeProjectListener( ProjectListener listener ); - void setLogger( Logger logger ); + void execute( Project project, String target ) throws AntException; + void execute( Project project, String target, TaskletContext context ) throws AntException; } diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletConfigurer.java b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletConfigurer.java index d69b38246..4ff181bd2 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletConfigurer.java +++ b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletConfigurer.java @@ -14,10 +14,7 @@ import java.util.Iterator; import org.apache.ant.configuration.Configurable; import org.apache.ant.configuration.Configuration; import org.apache.ant.convert.Converter; -import org.apache.ant.convert.ConverterEntry; -import org.apache.ant.convert.ConverterFactory; -import org.apache.ant.convert.ConverterInfo; -import org.apache.ant.convert.ConverterRegistry; +import org.apache.ant.convert.ConverterException; import org.apache.ant.tasklet.Tasklet; import org.apache.avalon.ComponentManager; import org.apache.avalon.ComponentNotAccessibleException; @@ -25,7 +22,6 @@ import org.apache.avalon.ComponentNotFoundException; import org.apache.avalon.Composer; import org.apache.avalon.ConfigurationException; import org.apache.avalon.Context; -import org.apache.avalon.camelot.FactoryException; import org.apache.avalon.util.PropertyException; import org.apache.avalon.util.PropertyUtil; @@ -47,16 +43,12 @@ public class DefaultTaskletConfigurer "content" }; - protected ConverterRegistry m_converterRegistry; - protected ConverterFactory m_converterFactory; + protected Converter m_converter; public void compose( final ComponentManager componentManager ) throws ComponentNotFoundException, ComponentNotAccessibleException { - m_converterRegistry = (ConverterRegistry)componentManager. - lookup( "org.apache.ant.convert.ConverterRegistry" ); - m_converterFactory = (ConverterFactory)componentManager. - lookup( "org.apache.ant.convert.ConverterFactory" ); + m_converter = (Converter)componentManager.lookup( "org.apache.ant.convert.Converter" ); } /** @@ -240,23 +232,13 @@ public class DefaultTaskletConfigurer if( !parameterType.isAssignableFrom( sourceClass ) ) { - final String destination = parameterType.getName(); - try { - final ConverterInfo info = m_converterRegistry. - getConverterInfo( source, destination ); - - if( null == info ) return false; - - final ConverterEntry entry = m_converterFactory.create( info ); - final Converter converter = entry.getConverter(); - value = converter.convert( parameterType, value ); + value = m_converter.convert( parameterType, object ); } - catch( final FactoryException fe ) + catch( final ConverterException ce ) { - throw new ConfigurationException( "Badly configured ConverterFactory ", - fe ); + return false; } catch( final Exception e ) { diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletEngine.java b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletEngine.java index 6a540f125..02d381881 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletEngine.java +++ b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletEngine.java @@ -11,14 +11,13 @@ import java.util.HashMap; import org.apache.ant.AntException; import org.apache.ant.configuration.Configurable; import org.apache.ant.configuration.Configuration; +import org.apache.ant.convert.ConverterEngine; import org.apache.ant.convert.ConverterFactory; -import org.apache.ant.convert.ConverterRegistry; import org.apache.ant.tasklet.Tasklet; import org.apache.ant.tasklet.TaskletContext; -import org.apache.avalon.ComponentManager; -import org.apache.avalon.ComponentNotAccessibleException; -import org.apache.avalon.ComponentNotFoundException; +import org.apache.avalon.Component; import org.apache.avalon.Composer; +import org.apache.avalon.ComponentManager; import org.apache.avalon.Context; import org.apache.avalon.Contextualizable; import org.apache.avalon.DefaultComponentManager; @@ -29,76 +28,102 @@ import org.apache.avalon.camelot.RegistryException; import org.apache.log.Logger; public class DefaultTaskletEngine - implements TaskletEngine, Initializable, Composer + implements TaskletEngine, Initializable { + protected TskDeployer m_tskDeployer; protected TaskletFactory m_taskletFactory; - protected ConverterFactory m_converterFactory; protected TaskletRegistry m_taskletRegistry; - protected ConverterRegistry m_converterRegistry; protected TaskletConfigurer m_configurer; protected Logger m_logger; + protected ConverterEngine m_converterEngine; public void setLogger( final Logger logger ) { m_logger = logger; } - public void compose( final ComponentManager componentManager ) - throws ComponentNotFoundException, ComponentNotAccessibleException + public TskDeployer getTskDeployer() { - m_taskletRegistry = (TaskletRegistry)componentManager. - lookup( "org.apache.ant.tasklet.engine.TaskletRegistry" ); - m_converterRegistry = (ConverterRegistry)componentManager. - lookup( "org.apache.ant.convert.ConverterRegistry" ); + return m_tskDeployer; } - public TaskletRegistry getTaskletRegistry() + public ConverterEngine getConverterEngine() { - return m_taskletRegistry; + return m_converterEngine; } - public ConverterRegistry getConverterRegistry() + public TaskletRegistry getTaskletRegistry() { - return m_converterRegistry; + return m_taskletRegistry; } public void init() throws Exception { + m_taskletRegistry = createTaskletRegistry(); m_taskletFactory = createTaskletFactory(); - m_converterFactory = createConverterFactory(); + + m_converterEngine = createConverterEngine(); + m_converterEngine.setLogger( m_logger ); + setupSubComponent( m_converterEngine ); + m_configurer = createTaskletConfigurer(); + setupSubComponent( m_configurer ); - if( m_configurer instanceof Composer ) + m_tskDeployer = createTskDeployer(); + m_tskDeployer.setLogger( m_logger ); + setupSubComponent( m_tskDeployer ); + } + + protected void setupSubComponent( final Component component ) + throws Exception + { + if( component instanceof Composer ) { final DefaultComponentManager componentManager = new DefaultComponentManager(); - componentManager.put( "org.apache.ant.convert.ConverterFactory", - m_converterFactory ); - componentManager.put( "org.apache.ant.convert.ConverterRegistry", - m_converterRegistry ); + componentManager.put( "org.apache.ant.convert.Converter", + getConverterEngine() ); + componentManager.put( "org.apache.ant.convert.ConverterEngine", + getConverterEngine() ); + componentManager.put( "org.apache.ant.tasklet.engine.TaskletEngine", + this ); - ((Composer)m_configurer).compose( componentManager ); + ((Composer)component).compose( componentManager ); } - - if( m_configurer instanceof Initializable ) + + if( component instanceof Initializable ) { - ((Initializable)m_configurer).init(); + ((Initializable)component).init(); } } + + protected TskDeployer createTskDeployer() + { + return new DefaultTskDeployer(); + } protected TaskletConfigurer createTaskletConfigurer() { return new DefaultTaskletConfigurer(); } - + + protected TaskletRegistry createTaskletRegistry() + { + return new DefaultTaskletRegistry(); + } + protected TaskletFactory createTaskletFactory() { return new DefaultTaskletFactory(); } - - protected ConverterFactory createConverterFactory() + + protected ConverterEngine createConverterEngine() { - return (ConverterFactory)m_taskletFactory; + //this is done so that the loaders are shared + //which results in much less overhead + final TaskletConverterEngine engine = new TaskletConverterEngine(); + engine.setConverterFactory( (ConverterFactory)m_taskletFactory ); + return engine; } public void execute( final Configuration task, diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTskDeployer.java b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTskDeployer.java new file mode 100644 index 000000000..261add19c --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTskDeployer.java @@ -0,0 +1,309 @@ +/* + * 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 java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.Properties; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; +import org.apache.ant.convert.ConverterEngine; +import org.apache.ant.convert.ConverterRegistry; +import org.apache.ant.convert.DefaultConverterInfo; +import org.apache.ant.tasklet.engine.DefaultTaskletInfo; +import org.apache.avalon.Component; +import org.apache.avalon.ComponentManager; +import org.apache.avalon.ComponentNotAccessibleException; +import org.apache.avalon.ComponentNotFoundException; +import org.apache.avalon.Composer; +import org.apache.avalon.camelot.AbstractDeployer; +import org.apache.avalon.camelot.DeploymentException; +import org.apache.avalon.camelot.RegistryException; +import org.apache.log.Logger; + +/** + * This class deploys a .tsk file into a registry. + * + * @author Peter Donald + */ +public class DefaultTskDeployer + extends AbstractDeployer + implements Composer, TskDeployer +{ + protected final static String TASKDEF_FILE = "TASK-LIB/taskdefs.properties"; + protected final static String CONVERTER_FILE = "TASK-LIB/converters.properties"; + + protected TaskletRegistry m_taskletRegistry; + protected ConverterRegistry m_converterRegistry; + + /** + * Default constructor. + */ + public DefaultTskDeployer() + { + m_autoUndeploy = true; + m_type = "Tasklet"; + } + + /** + * Retrieve relevent services needed to deploy. + * + * @param componentManager the ComponentManager + * @exception ComponentNotFoundException if an error occurs + * @exception ComponentNotAccessibleException if an error occurs + */ + public void compose( final ComponentManager componentManager ) + throws ComponentNotFoundException, ComponentNotAccessibleException + { + final ConverterEngine converterEngine = (ConverterEngine)componentManager. + lookup( "org.apache.ant.convert.ConverterEngine" ); + + m_converterRegistry = converterEngine.getConverterRegistry(); + + final TaskletEngine taskletEngine = (TaskletEngine)componentManager. + lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); + + m_taskletRegistry = taskletEngine.getTaskletRegistry(); + } + + public void setLogger( final Logger logger ) + { + m_logger = logger; + } + + protected boolean isValidLocation( final String location ) + { + //TODO: Make sure it is valid JavaIdentifier + //that optionally has '-' embedded in it + return true; + } + + /** + * Deploy Tasklets from a .tsk file. + * Eventually this should be cached for performance reasons. + * + * @param location the location + * @param file the file + * @exception DeploymentException if an error occurs + */ + protected void deployFromFile( final String location, final File file ) + throws DeploymentException + { + m_logger.info( "Deploying .tsk file (" + file + ") as " + location ); + + final ZipFile zipFile = getZipFileFor( file ); + + try + { + final Properties taskdefs = loadProperties( zipFile, TASKDEF_FILE ); + final Properties converters = loadProperties( zipFile, CONVERTER_FILE ); + + try { zipFile.close(); } + catch( final IOException ioe ) {} + + URL url = null; + + try { url = file.toURL(); } + catch( final MalformedURLException mue ) {} + + handleTasklets( taskdefs, url ); + handleConverters( converters, url ); + } + catch( final DeploymentException de ) + { + try { zipFile.close(); } + catch( final IOException ioe ) {} + + throw de; + } + } + + public void deployConverter( String name, String location, URL url ) + throws DeploymentException + { + checkDeployment( location, url ); + final ZipFile zipFile = getZipFileFor( url ); + final Properties converters = loadProperties( zipFile, CONVERTER_FILE ); + final String value = converters.getProperty( name ); + + if( null == value ) + { + throw new DeploymentException( "Unable to locate converter named " + name ); + } + + handleConverter( name, value, url ); + } + + public void deployTasklet( final String name, final String location, final URL url ) + throws DeploymentException + { + checkDeployment( location, url ); + final ZipFile zipFile = getZipFileFor( url ); + final Properties tasklets = loadProperties( zipFile, TASKDEF_FILE ); + final String value = tasklets.getProperty( name ); + + if( null == value ) + { + throw new DeploymentException( "Unable to locate tasklet named " + name ); + } + + handleTasklet( name, value, url ); + } + + protected ZipFile getZipFileFor( final URL url ) + throws DeploymentException + { + final File file = getFileFor( url ); + return getZipFileFor( file ); + } + + protected ZipFile getZipFileFor( final File file ) + throws DeploymentException + { + try { return new ZipFile( file ); } + catch( final IOException ioe ) + { + throw new DeploymentException( "Error opening " + file + + " due to " + ioe.getMessage(), + ioe ); + } + } + + /** + * Create and register Infos for all converters stored in deployment. + * + * @param properties the properties + * @param url the url of deployment + * @exception DeploymentException if an error occurs + */ + protected void handleConverters( final Properties properties, final URL url ) + throws DeploymentException + { + final Enumeration enum = properties.propertyNames(); + + while( enum.hasMoreElements() ) + { + final String key = (String)enum.nextElement(); + final String value = (String)properties.get( key ); + + handleConverter( key, value, url ); + } + } + + protected void handleConverter( final String name, final String param, final URL url ) + throws DeploymentException + { + final int index = param.indexOf( ',' ); + + if( -1 == index ) + { + throw new DeploymentException( "Malformed converter definition (" + name + ")" ); + } + + final String source = param.substring( 0, index ).trim(); + final String destination = param.substring( index + 1 ).trim(); + + final DefaultConverterInfo info = + new DefaultConverterInfo( source, destination, name, url ); + + try { m_converterRegistry.register( name, info ); } + catch( final RegistryException re ) + { + throw new DeploymentException( "Error registering converter " + + name + " due to " + re, + re ); + } + + m_logger.debug( "Registered converter " + name + " that converts from " + + source + " to " + destination ); + } + + /** + * Create and register Infos for all tasklets stored in deployment. + * + * @param properties the properties + * @param url the url of deployment + * @exception DeploymentException if an error occurs + */ + protected void handleTasklets( final Properties properties, final URL url ) + throws DeploymentException + { + final Enumeration enum = properties.propertyNames(); + + while( enum.hasMoreElements() ) + { + final String key = (String)enum.nextElement(); + final String value = (String)properties.get( key ); + handleTasklet( key, value, url ); + } + } + + protected void handleTasklet( final String name, final String classname, final URL url ) + throws DeploymentException + { + final DefaultTaskletInfo info = new DefaultTaskletInfo( classname, url ); + + try { m_taskletRegistry.register( name, info ); } + catch( final RegistryException re ) + { + throw new DeploymentException( "Error registering " + name + " due to " + re, + re ); + } + + m_logger.debug( "Registered tasklet " + name + " as " + classname ); + } + + /** + * Utility method to load properties from zip. + * + * @param zipFile the zip file + * @param filename the property filename + * @return the Properties + * @exception DeploymentException if an error occurs + */ + protected Properties loadProperties( final ZipFile zipFile, final String filename ) + throws DeploymentException + { + final ZipEntry entry = zipFile.getEntry( filename ); + if( null == entry ) + { + throw new DeploymentException( "Unable to locate " + filename + + " in " + zipFile.getName() ); + } + + Properties properties = new Properties(); + + try + { + properties.load( zipFile.getInputStream( entry ) ); + } + catch( final IOException ioe ) + { + throw new DeploymentException( "Error reading " + filename + + " from " + zipFile.getName(), + ioe ); + } + + return properties; + } + + protected boolean canUndeploy( final Component component ) + throws DeploymentException + { + return true; + } + + protected void shutdownDeployment( final Component component ) + throws DeploymentException + { + } +} diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletConfigurer.java b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletConfigurer.java index d9621e9b8..725f78473 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletConfigurer.java +++ b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletConfigurer.java @@ -9,6 +9,7 @@ package org.apache.ant.tasklet.engine; import org.apache.ant.configuration.Configuration; import org.apache.ant.tasklet.Tasklet; +import org.apache.avalon.Component; import org.apache.avalon.ConfigurationException; import org.apache.avalon.Context; @@ -18,6 +19,7 @@ import org.apache.avalon.Context; * @author Peter Donald */ public interface TaskletConfigurer + extends Component { /** * Configure a task based on a configuration in a particular context. diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletConverterEngine.java b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletConverterEngine.java new file mode 100644 index 000000000..c623a2016 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletConverterEngine.java @@ -0,0 +1,29 @@ +/* + * 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.convert.ConverterFactory; +import org.apache.ant.convert.DefaultConverterEngine; + +public class TaskletConverterEngine + extends DefaultConverterEngine +{ + /** + * Set the ConverterFactory. + * Package access intended. + */ + void setConverterFactory( final ConverterFactory converterFactory ) + { + m_converterFactory = converterFactory; + } + + protected ConverterFactory createConverterFactory() + { + return m_converterFactory; + } +} diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletEngine.java b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletEngine.java index 1210bd172..516786c22 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletEngine.java +++ b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletEngine.java @@ -9,12 +9,10 @@ package org.apache.ant.tasklet.engine; import org.apache.ant.AntException; import org.apache.ant.configuration.Configuration; -import org.apache.ant.convert.ConverterRegistry; +import org.apache.ant.convert.ConverterEngine; import org.apache.ant.tasklet.TaskletContext; import org.apache.avalon.Component; import org.apache.avalon.ComponentManager; -import org.apache.avalon.Composer; -import org.apache.avalon.Contextualizable; import org.apache.log.Logger; /** @@ -26,6 +24,13 @@ public interface TaskletEngine extends Component { void setLogger( Logger logger ); + + /** + * Retrieve deployer for engine. + * + * @return the deployer + */ + TskDeployer getTskDeployer(); /** * Retrieve tasklet registry associated with engine. @@ -35,11 +40,11 @@ public interface TaskletEngine TaskletRegistry getTaskletRegistry(); /** - * Retrieve converter registry associated with engine. + * Retrieve converter engine. * - * @return the ConverterRegistry + * @return the ConverterEngine */ - ConverterRegistry getConverterRegistry(); + ConverterEngine getConverterEngine(); /** * execute a task. diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TskDeployer.java b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TskDeployer.java index d93973279..b7acad9d6 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TskDeployer.java +++ b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TskDeployer.java @@ -7,22 +7,9 @@ */ package org.apache.ant.tasklet.engine; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; import java.net.URL; -import java.util.Enumeration; -import java.util.Properties; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; -import org.apache.ant.tasklet.engine.DefaultTaskletInfo; -import org.apache.ant.convert.ConverterRegistry; -import org.apache.ant.convert.DefaultConverterInfo; -import org.apache.avalon.Component; -import org.apache.avalon.camelot.AbstractDeployer; +import org.apache.avalon.camelot.Deployer; import org.apache.avalon.camelot.DeploymentException; -import org.apache.avalon.camelot.RegistryException; import org.apache.log.Logger; /** @@ -30,176 +17,14 @@ import org.apache.log.Logger; * * @author Peter Donald */ -public class TskDeployer - extends AbstractDeployer +public interface TskDeployer + extends Deployer { - protected final static String TASKDEF_FILE = "TASK-LIB/taskdefs.properties"; - protected final static String CONVERTER_FILE = "TASK-LIB/converters.properties"; + void setLogger( Logger logger ); - protected TaskletRegistry m_taskletRegistry; - protected ConverterRegistry m_converterRegistry; - - public TskDeployer( final TaskletRegistry taskletRegistry, - final ConverterRegistry converterRegistry ) - { - m_taskletRegistry = taskletRegistry; - m_converterRegistry = converterRegistry; - m_autoUndeploy = true; - m_type = "Tasklet"; - } - - public void setLogger( final Logger logger ) - { - m_logger = logger; - } - - protected boolean isValidLocation( final String location ) - { - //TODO: Make sure it is valid JavaIdentifier - //that optionally has '-' embedded in it - return true; - } - - /** - * Deploy Tasklets from a .tsk file. - * Eventually this should be cached for performance reasons. - * - * @param location the location - * @param file the file - * @exception DeploymentException if an error occurs - */ - protected void deployFromFile( final String location, final File file ) - throws DeploymentException - { - m_logger.info( "Deploying .tsk file (" + file + ") as " + location ); - - ZipFile zipFile = null; - - try { zipFile = new ZipFile( file ); } - catch( final IOException ioe ) - { - throw new DeploymentException( "Error opening " + file + - " due to " + ioe.getMessage(), - ioe ); - } - - try - { - final Properties taskdefs = loadProperties( zipFile, TASKDEF_FILE ); - final Properties converters = loadProperties( zipFile, CONVERTER_FILE ); - - try { zipFile.close(); } - catch( final IOException ioe ) {} - - URL url = null; - - try { url = file.toURL(); } - catch( final MalformedURLException mue ) {} - - handleTaskdefs( taskdefs, url ); - handleConverters( converters, url ); - } - catch( final DeploymentException de ) - { - try { zipFile.close(); } - catch( final IOException ioe ) {} - - throw de; - } - } - - protected void handleConverters( final Properties properties, final URL url ) - throws DeploymentException - { - final Enumeration enum = properties.propertyNames(); - - while( enum.hasMoreElements() ) - { - final String key = (String)enum.nextElement(); - final String value = (String)properties.get( key ); - final int index = value.indexOf( ',' ); - - if( -1 == index ) - { - throw new DeploymentException( "Malformed converter definition (" + - key + ")" ); - } - - final String source = value.substring( 0, index ).trim(); - final String destination = value.substring( index + 1 ).trim(); - - final DefaultConverterInfo info = - new DefaultConverterInfo( source, destination, key, url ); - - try { m_converterRegistry.register( key, info ); } - catch( final RegistryException re ) - { - throw new DeploymentException( "Error registering converter " + - key + " due to " + re, - re ); - } - - m_logger.debug( "Registered converter " + key + " that converts from " + - source + " to " + destination ); - } - } - - protected void handleTaskdefs( final Properties properties, final URL url ) - throws DeploymentException - { - final Enumeration enum = properties.propertyNames(); - - while( enum.hasMoreElements() ) - { - final String key = (String)enum.nextElement(); - final String value = (String)properties.get( key ); - final DefaultTaskletInfo info = new DefaultTaskletInfo( value, url ); - - try { m_taskletRegistry.register( key, info ); } - catch( final RegistryException re ) - { - throw new DeploymentException( "Error registering " + key + " due to " + re, - re ); - } - - m_logger.debug( "Registered tasklet " + key + " as " + value ); - } - } - - protected Properties loadProperties( final ZipFile zipFile, final String filename ) - throws DeploymentException - { - final ZipEntry entry = zipFile.getEntry( filename ); - if( null == entry ) - { - throw new DeploymentException( "Unable to locate " + filename + - " in " + zipFile.getName() ); - } - - Properties properties = new Properties(); - - try - { - properties.load( zipFile.getInputStream( entry ) ); - } - catch( final IOException ioe ) - { - throw new DeploymentException( "Error reading " + filename + - " from " + zipFile.getName(), - ioe ); - } - - return properties; - } - - protected boolean canUndeploy( final Component component ) - throws DeploymentException - { - return true; - } + void deployConverter( String name, String location, URL url ) + throws DeploymentException; - protected void shutdownDeployment( final Component component ) - throws DeploymentException - { - } + void deployTasklet( String name, String location, URL url ) + throws DeploymentException; } diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasks/core/AbstractResourceRegisterer.java b/proposal/myrmidon/src/java/org/apache/ant/tasks/core/AbstractResourceRegisterer.java new file mode 100644 index 000000000..d695e54f7 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/tasks/core/AbstractResourceRegisterer.java @@ -0,0 +1,103 @@ +/* + * 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.tasks.core; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import org.apache.ant.AntException; +import org.apache.ant.tasklet.AbstractTasklet; +import org.apache.ant.tasklet.engine.DefaultTaskletInfo; +import org.apache.ant.tasklet.engine.TaskletEngine; +import org.apache.avalon.ComponentManager; +import org.apache.avalon.ComponentNotAccessibleException; +import org.apache.avalon.ComponentNotFoundException; +import org.apache.avalon.Composer; +import org.apache.avalon.camelot.RegistryException; + +/** + * Method to register a single tasklet. + * + * @author Peter Donald + */ +public abstract class AbstractResourceRegisterer + extends AbstractTasklet + implements Composer +{ + protected String m_lib; + protected String m_name; + protected String m_classname; + protected TaskletEngine m_engine; + + public void compose( final ComponentManager componentManager ) + throws ComponentNotFoundException, ComponentNotAccessibleException + { + m_engine = (TaskletEngine)componentManager. + lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); + } + + public void setLib( final String lib ) + { + m_lib = lib; + } + + public void setName( final String name ) + { + m_name = name; + } + + public void setClassname( final String classname ) + { + m_classname = classname; + } + + public void run() + throws AntException + { + if( null == m_name ) + { + throw new AntException( "Must specify name parameter" ); + } + else if( null == m_lib && null == m_classname ) + { + throw new AntException( "Must specify classname if you don't specify " + + "lib parameter" ); + } + + final URL url = getURL( m_lib ); + + try + { + registerResource( m_name, m_classname, url ); + } + catch( final RegistryException re ) + { + throw new AntException( "Error registering resource", re ); + } + } + + protected URL getURL( final String libName ) + { + if( null != libName ) + { + final File lib = new File( getContext().resolveFilename( libName ) ); + try { return lib.toURL(); } + catch( final MalformedURLException mue ) + { + throw new AntException( "Malformed task-lib parameter " + m_lib, mue ); + } + } + else + { + return null; + } + } + + protected abstract void registerResource( String name, String classname, URL url ) + throws AntException, RegistryException; +} diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterConverter.java b/proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterConverter.java new file mode 100644 index 000000000..35544fccc --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterConverter.java @@ -0,0 +1,139 @@ +/* + * 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.tasks.core; + +import java.io.File; +import java.net.URL; +import java.net.MalformedURLException; +import org.apache.ant.AntException; +import org.apache.ant.convert.DefaultConverterInfo; +import org.apache.ant.convert.ConverterEngine; +import org.apache.ant.tasklet.AbstractTasklet; +import org.apache.ant.tasklet.engine.TaskletEngine; +import org.apache.avalon.ComponentManager; +import org.apache.avalon.ComponentNotAccessibleException; +import org.apache.avalon.ComponentNotFoundException; +import org.apache.avalon.Composer; +import org.apache.avalon.camelot.DeploymentException; +import org.apache.avalon.camelot.RegistryException; + +/** + * Method to register a single converter. + * + * @author Peter Donald + */ +public class RegisterConverter + extends AbstractTasklet + implements Composer +{ + protected String m_sourceType; + protected String m_destinationType; + protected String m_lib; + protected String m_classname; + protected TaskletEngine m_engine; + + public void compose( final ComponentManager componentManager ) + throws ComponentNotFoundException, ComponentNotAccessibleException + { + m_engine = (TaskletEngine)componentManager. + lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); + } + + public void setLib( final String lib ) + { + m_lib = lib; + } + + public void setClassname( final String classname ) + { + m_classname = classname; + } + + public void setSourceType( final String sourceType ) + { + m_sourceType = sourceType; + } + + public void setDestinationType( final String destinationType ) + { + m_destinationType = destinationType; + } + + public void run() + throws AntException + { + if( null == m_classname ) + { + throw new AntException( "Must specify classname parameter" ); + } + + final URL url = getURL( m_lib ); + + boolean isFullyDefined = true; + + if( null == m_sourceType && null == m_destinationType ) + { + isFullyDefined = false; + } + else if( null == m_sourceType || null == m_destinationType ) + { + throw new AntException( "Must specify the source-type and destination-type " + + "parameters when supplying a name" ); + } + + if( !isFullyDefined && null == url ) + { + throw new AntException( "Must supply parameter if not fully specifying converter" ); + } + + if( !isFullyDefined ) + { + try + { + m_engine.getTskDeployer().deployConverter( m_classname, url.toString(), url ); + } + catch( final DeploymentException de ) + { + throw new AntException( "Failed deploying " + m_classname + + " from " + url, de ); + } + } + else + { + final DefaultConverterInfo info = + new DefaultConverterInfo( m_sourceType, m_destinationType, m_classname, url ); + + try + { + m_engine.getConverterEngine(). + getConverterRegistry().register( m_classname, info ); + } + catch( final RegistryException re ) + { + throw new AntException( "Error registering resource", re ); + } + } + } + + protected URL getURL( final String libName ) + { + if( null != libName ) + { + final File lib = new File( getContext().resolveFilename( libName ) ); + try { return lib.toURL(); } + catch( final MalformedURLException mue ) + { + throw new AntException( "Malformed task-lib parameter " + m_lib, mue ); + } + } + else + { + return null; + } + } +} diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterTasklet.java b/proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterTasklet.java index dbee8c3ac..e1f1bb9fb 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterTasklet.java +++ b/proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterTasklet.java @@ -7,18 +7,10 @@ */ package org.apache.ant.tasks.core; -import java.io.File; -import java.net.MalformedURLException; import java.net.URL; import org.apache.ant.AntException; -import org.apache.ant.tasklet.AbstractTasklet; import org.apache.ant.tasklet.engine.DefaultTaskletInfo; -import org.apache.ant.tasklet.engine.TaskletEngine; -import org.apache.ant.tasklet.engine.TaskletRegistry; -import org.apache.avalon.ComponentManager; -import org.apache.avalon.ComponentNotAccessibleException; -import org.apache.avalon.ComponentNotFoundException; -import org.apache.avalon.Composer; +import org.apache.avalon.camelot.DeploymentException; import org.apache.avalon.camelot.RegistryException; /** @@ -27,90 +19,25 @@ import org.apache.avalon.camelot.RegistryException; * @author Peter Donald */ public class RegisterTasklet - extends AbstractTasklet - implements Composer + extends AbstractResourceRegisterer { - protected TaskletRegistry m_taskletRegistry; - protected String m_tasklib; - protected String m_taskName; - protected String m_classname; - - public void compose( final ComponentManager componentManager ) - throws ComponentNotFoundException, ComponentNotAccessibleException - { - final TaskletEngine engine = (TaskletEngine)componentManager. - lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); - m_taskletRegistry = engine.getTaskletRegistry(); - } - - public void setTaskLib( final String tasklib ) - { - m_tasklib = tasklib; - } - - public void setTaskName( final String taskName ) - { - m_taskName = taskName; - } - - public void setClassname( final String classname ) - { - m_classname = classname; - } - - public void run() - throws AntException + protected void registerResource( final String name, + final String classname, + final URL url ) + throws AntException, RegistryException { -/* - if( null == m_tasklib ) - { - throw new AntException( "Must specify tasklib parameter" ); - } -*/ - if( null == m_taskName ) + if( null == classname ) { - throw new AntException( "Must specify taskname parameter" ); - } - - if( null == m_tasklib && null == m_classname ) - { - throw new AntException( "Must specify classname if don't specify " + - "tasklib parameter" ); - } - - if( null == m_classname ) - { - m_classname = getDefaultClassName(); - } - - try - { - URL url = null; - - if( null != m_tasklib ) + try { m_engine.getTskDeployer().deployTasklet( name, url.toString(), url ); } + catch( final DeploymentException de ) { - final File tasklib = new File( getContext().resolveFilename( m_tasklib ) ); - url = tasklib.toURL(); + throw new AntException( "Failed deploying " + name + " from " + url, de ); } - - final DefaultTaskletInfo info = new DefaultTaskletInfo( m_classname, url ); - - m_taskletRegistry.register( m_taskName, info ); - } - catch( final MalformedURLException mue ) - { - throw new AntException( "Malformed task-lib parameter " + m_tasklib, mue ); } - catch( final RegistryException re ) + else { - throw new AntException( "Error registering " + m_taskName + " due to " + re, re ); + final DefaultTaskletInfo info = new DefaultTaskletInfo( classname, url ); + m_engine.getTaskletRegistry().register( name, info ); } } - - protected String getDefaultClassName() - throws AntException - { - //TODO: - throw new AntException( "Not yet capable of automagically finding classname" ); - } } diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterTasklib.java b/proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterTasklib.java new file mode 100644 index 000000000..d7f1f748e --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterTasklib.java @@ -0,0 +1,72 @@ +/* + * 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.tasks.core; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import org.apache.ant.AntException; +import org.apache.ant.tasklet.AbstractTasklet; +import org.apache.ant.tasklet.engine.TaskletEngine; +import org.apache.avalon.ComponentManager; +import org.apache.avalon.ComponentNotAccessibleException; +import org.apache.avalon.ComponentNotFoundException; +import org.apache.avalon.Composer; +import org.apache.avalon.camelot.DeploymentException; + +/** + * Method to register a tasklib. + * + * @author Peter Donald + */ +public class RegisterTasklib + extends AbstractTasklet + implements Composer +{ + protected String m_lib; + protected TaskletEngine m_engine; + + public void compose( final ComponentManager componentManager ) + throws ComponentNotFoundException, ComponentNotAccessibleException + { + m_engine = (TaskletEngine)componentManager. + lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); + } + + public void setLib( final String lib ) + { + m_lib = lib; + } + + public void run() + throws AntException + { + if( null == m_lib ) + { + throw new AntException( "Must specify lib parameter" ); + } + + URL url = null; + + final File lib = new File( getContext().resolveFilename( m_lib ) ); + try { url = lib.toURL(); } + catch( final MalformedURLException mue ) + { + throw new AntException( "Malformed task-lib parameter " + m_lib, mue ); + } + + try + { + m_engine.getTskDeployer().deploy( url.toString(), url ); + } + catch( final DeploymentException de ) + { + throw new AntException( "Error registering resource", de ); + } + } +} diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasks/core/taskdefs.properties b/proposal/myrmidon/src/java/org/apache/ant/tasks/core/taskdefs.properties index 73f28858e..f2a9d2ae0 100644 --- a/proposal/myrmidon/src/java/org/apache/ant/tasks/core/taskdefs.properties +++ b/proposal/myrmidon/src/java/org/apache/ant/tasks/core/taskdefs.properties @@ -6,4 +6,6 @@ conf-test=org.apache.ant.tasks.core.ConfigurationTest content-test=org.apache.ant.tasks.core.ContentTest property=org.apache.ant.tasks.core.Property register-tasklet=org.apache.ant.tasks.core.RegisterTasklet +register-converter=org.apache.ant.tasks.core.RegisterConverter +register-tasklib=org.apache.ant.tasks.core.RegisterTasklib ant-call=org.apache.ant.tasks.core.AntCall \ No newline at end of file diff --git a/proposal/myrmidon/src/make/sample.xmk b/proposal/myrmidon/src/make/sample.xmk index 79467fdf2..67fb3d9e2 100644 --- a/proposal/myrmidon/src/make/sample.xmk +++ b/proposal/myrmidon/src/make/sample.xmk @@ -58,10 +58,18 @@ Legal: - + + @@ -74,6 +82,7 @@ Legal: + \ No newline at end of file diff --git a/proposal/myrmidon/src/script/ant b/proposal/myrmidon/src/script/ant index d215b85a8..00bbeeff5 100644 --- a/proposal/myrmidon/src/script/ant +++ b/proposal/myrmidon/src/script/ant @@ -25,7 +25,7 @@ while [ -h "$PRG" ] ; do fi done -ANT_HOME=`dirname "$PRG"`/.. +MYRMIDON_HOME=`dirname "$PRG"`/.. if [ "$JAVA_HOME" == "" ] ; then @@ -42,4 +42,4 @@ else fi fi -$JAVACMD $ANT_OPTS -jar ant.jar --ant-home=${ANT_HOME} $@ \ No newline at end of file +$JAVACMD $ANT_OPTS -jar ant.jar --ant-home=${MYRMIDON_HOME} $@ \ No newline at end of file