git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268605 13f79535-47bb-0310-9956-ffa450edef68master
@@ -11,7 +11,7 @@ import java.io.File; | |||
import java.util.Properties; | |||
import org.apache.ant.configuration.Configurer; | |||
import org.apache.ant.convert.ConverterEngine; | |||
import org.apache.ant.datatypes.DataTypeEngine; | |||
import org.apache.ant.tasklet.engine.DataTypeEngine; | |||
import org.apache.ant.project.ProjectBuilder; | |||
import org.apache.ant.project.ProjectEngine; | |||
import org.apache.ant.tasklet.JavaVersion; | |||
@@ -160,7 +160,7 @@ public class DefaultAntEngine | |||
defaults.setProperty( "ant.comp.converter", | |||
"org.apache.ant.convert.DefaultConverterEngine" ); | |||
defaults.setProperty( "ant.comp.datatype", | |||
"org.apache.ant.datatypes.DefaultDataTypeEngine" ); | |||
"org.apache.ant.tasklet.engine.DefaultDataTypeEngine" ); | |||
defaults.setProperty( "ant.comp.tasklet", | |||
"org.apache.ant.tasklet.engine.DefaultTaskletEngine" ); | |||
defaults.setProperty( "ant.comp.project", | |||
@@ -188,7 +188,7 @@ public class DefaultAntEngine | |||
componentManager.put( "org.apache.ant.project.ProjectEngine", m_projectEngine ); | |||
componentManager.put( "org.apache.ant.convert.ConverterEngine", m_converterEngine ); | |||
componentManager.put( "org.apache.ant.convert.Converter", m_converterEngine ); | |||
componentManager.put( "org.apache.ant.datatypes.DataTypeEngine", m_dataTypeEngine ); | |||
componentManager.put( "org.apache.ant.tasklet.engine.DataTypeEngine", m_dataTypeEngine ); | |||
componentManager.put( "org.apache.ant.project.ProjectBuilder", m_builder ); | |||
componentManager.put( "org.apache.ant.tasklet.engine.TskDeployer", m_deployer ); | |||
componentManager.put( "org.apache.avalon.camelot.Factory", m_factory ); | |||
@@ -1,101 +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.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.ComponentManagerException; | |||
import org.apache.avalon.Composer; | |||
import org.apache.avalon.camelot.RegistryException; | |||
/** | |||
* Method to register a single tasklet. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
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 ComponentManagerException | |||
{ | |||
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 = getContext().resolveFile( 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; | |||
} |
@@ -1,87 +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.tasks.core; | |||
import java.util.ArrayList; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.project.ProjectEngine; | |||
import org.apache.ant.project.Project; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.ant.tasklet.DefaultTaskletContext; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.avalon.ComponentManager; | |||
import org.apache.avalon.Context; | |||
import org.apache.avalon.ComponentManagerException; | |||
import org.apache.avalon.Composer; | |||
/** | |||
* This is abstract base class for tasklets. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class AntCall | |||
extends AbstractTasklet | |||
implements Composer | |||
{ | |||
protected ProjectEngine m_projectEngine; | |||
protected Project m_project; | |||
protected String m_target; | |||
protected ArrayList m_properties = new ArrayList(); | |||
protected TaskletContext m_childContext; | |||
protected ComponentManager m_componentManager; | |||
public void contextualize( final Context context ) | |||
{ | |||
super.contextualize( context ); | |||
m_childContext = new DefaultTaskletContext( getContext() ); | |||
} | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentManagerException | |||
{ | |||
m_componentManager = componentManager; | |||
m_projectEngine = (ProjectEngine)componentManager. | |||
lookup( "org.apache.ant.project.ProjectEngine" ); | |||
m_project = (Project)componentManager.lookup( "org.apache.ant.project.Project" ); | |||
} | |||
public void setTarget( final String target ) | |||
{ | |||
m_target = target; | |||
} | |||
public Property createParam() | |||
throws Exception | |||
{ | |||
final Property property = new Property(); | |||
property.setLogger( getLogger() ); | |||
property.contextualize( m_childContext ); | |||
property.compose( m_componentManager ); | |||
m_properties.add( property ); | |||
return property; | |||
} | |||
public void run() | |||
throws AntException | |||
{ | |||
if( null == m_target ) | |||
{ | |||
throw new AntException( "Target attribute must be specified" ); | |||
} | |||
final int size = m_properties.size(); | |||
for( int i = 0; i < size; i++ ) | |||
{ | |||
final Property property = (Property)m_properties.get( i ); | |||
property.run(); | |||
} | |||
getLogger().info( "Calling target " + m_target ); | |||
m_projectEngine.execute( m_project, m_target, m_childContext ); | |||
} | |||
} |
@@ -1,47 +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.tasks.core; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.configuration.Configurable; | |||
import org.apache.ant.configuration.Configuration; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.avalon.ConfigurationException; | |||
/** | |||
* This is abstract base class for tasklets. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class ConfigurationTest | |||
extends AbstractTasklet | |||
implements Configurable | |||
{ | |||
protected String m_message; | |||
public void configure( final Configuration configuration ) | |||
throws ConfigurationException | |||
{ | |||
String message = configuration.getAttribute( "message" ); | |||
final Object object = getContext().resolveValue( message ); | |||
if( object instanceof String ) | |||
{ | |||
m_message = (String)object; | |||
} | |||
else | |||
{ | |||
m_message = object.toString(); | |||
} | |||
} | |||
public void run() | |||
throws AntException | |||
{ | |||
getLogger().warn( m_message ); | |||
} | |||
} |
@@ -1,37 +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.tasks.core; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
/** | |||
* This is abstract base class for tasklets. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class ContentTest | |||
extends AbstractTasklet | |||
{ | |||
public void addContent( final Integer value ) | |||
{ | |||
getLogger().warn( "Integer content: " + value ); | |||
} | |||
/* | |||
public void addContent( final String blah ) | |||
{ | |||
System.out.println( "String: " + blah ); | |||
} | |||
*/ | |||
public void run() | |||
throws AntException | |||
{ | |||
} | |||
} |
@@ -1,33 +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.tasks.core; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
/** | |||
* This is abstract base class for tasklets. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class Echo | |||
extends AbstractTasklet | |||
{ | |||
protected String m_message; | |||
public void setMessage( final String message ) | |||
{ | |||
m_message = message; | |||
} | |||
public void run() | |||
throws AntException | |||
{ | |||
getLogger().warn( m_message ); | |||
} | |||
} |
@@ -1,90 +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.tasks.core; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
/** | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class PrimitiveTypesTest | |||
extends AbstractTasklet | |||
{ | |||
public void setInteger( final Integer value ) | |||
{ | |||
getLogger().warn( "setInteger( " + value + " );" ); | |||
} | |||
public void setInteger2( final int value ) | |||
{ | |||
getLogger().warn( "setInteger2( " + value + " );" ); | |||
} | |||
public void setShort( final Short value ) | |||
{ | |||
getLogger().warn( "setShort( " + value + " );" ); | |||
} | |||
public void setShort2( final short value ) | |||
{ | |||
getLogger().warn( "setShort2( " + value + " );" ); | |||
} | |||
public void setByte( final Byte value ) | |||
{ | |||
getLogger().warn( "setByte( " + value + " );" ); | |||
} | |||
public void setByte2( final byte value ) | |||
{ | |||
getLogger().warn( "setByte2( " + value + " );" ); | |||
} | |||
public void setLong( final Long value ) | |||
{ | |||
getLogger().warn( "setLong( " + value + " );" ); | |||
} | |||
public void setLong2( final long value ) | |||
{ | |||
getLogger().warn( "setLong2( " + value + " );" ); | |||
} | |||
public void setFloat( final Float value ) | |||
{ | |||
getLogger().warn( "setFloat( " + value + " );" ); | |||
} | |||
public void setFloat2( final float value ) | |||
{ | |||
getLogger().warn( "setFloat2( " + value + " );" ); | |||
} | |||
public void setDouble( final Double value ) | |||
{ | |||
getLogger().warn( "setDouble( " + value + " );" ); | |||
} | |||
public void setDouble2( final double value ) | |||
{ | |||
getLogger().warn( "setDouble2( " + value + " );" ); | |||
} | |||
public void setString( final String value ) | |||
{ | |||
getLogger().warn( "setString( " + value + " );" ); | |||
} | |||
public void run() | |||
throws AntException | |||
{ | |||
} | |||
} |
@@ -1,181 +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.tasks.core; | |||
import java.util.Iterator; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.configuration.Configurable; | |||
import org.apache.ant.configuration.Configuration; | |||
import org.apache.ant.configuration.Configurer; | |||
import org.apache.ant.convert.Converter; | |||
import org.apache.ant.datatypes.DataType; | |||
import org.apache.ant.datatypes.DataTypeEngine; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.ant.tasklet.TaskletContext; | |||
import org.apache.ant.tasklet.engine.TaskletEngine; | |||
import org.apache.avalon.ComponentManager; | |||
import org.apache.avalon.ComponentManagerException; | |||
import org.apache.avalon.Composer; | |||
import org.apache.avalon.ConfigurationException; | |||
import org.apache.avalon.Resolvable; | |||
/** | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class Property | |||
extends AbstractTasklet | |||
implements Configurable, Composer | |||
{ | |||
protected String m_name; | |||
protected Object m_value; | |||
protected boolean m_localScope = true; | |||
protected DataTypeEngine m_engine; | |||
protected Converter m_converter; | |||
protected Configurer m_configurer; | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentManagerException | |||
{ | |||
m_configurer = (Configurer)componentManager. | |||
lookup( "org.apache.ant.configuration.Configurer" ); | |||
m_engine = (DataTypeEngine)componentManager. | |||
lookup( "org.apache.ant.datatypes.DataTypeEngine" ); | |||
m_converter = (Converter)componentManager.lookup( "org.apache.ant.convert.Converter" ); | |||
} | |||
public void configure( final Configuration configuration ) | |||
throws ConfigurationException | |||
{ | |||
final Iterator attributes = configuration.getAttributeNames(); | |||
while( attributes.hasNext() ) | |||
{ | |||
final String name = (String)attributes.next(); | |||
final String value = configuration.getAttribute( name ); | |||
final Object object = getContext().resolveValue( value ); | |||
if( null == object ) | |||
{ | |||
throw new AntException( "Value for attribute " + name + "resolved to null" ); | |||
} | |||
if( name.equals( "name" ) ) | |||
{ | |||
try | |||
{ | |||
final String convertedValue = | |||
(String)m_converter.convert( String.class, object, getContext() ); | |||
setName( convertedValue ); | |||
} | |||
catch( final Exception e ) | |||
{ | |||
throw new ConfigurationException( "Error converting value", e ); | |||
} | |||
} | |||
else if( name.equals( "value" ) ) | |||
{ | |||
setValue( object ); | |||
} | |||
else if( name.equals( "local-scope" ) ) | |||
{ | |||
try | |||
{ | |||
final Boolean localScope = | |||
(Boolean)m_converter.convert( Boolean.class, object, getContext() ); | |||
setLocalScope( Boolean.TRUE == localScope ); | |||
} | |||
catch( final Exception e ) | |||
{ | |||
throw new ConfigurationException( "Error converting value", e ); | |||
} | |||
} | |||
else | |||
{ | |||
throw new ConfigurationException( "Unknown attribute " + name ); | |||
} | |||
} | |||
final Iterator children = configuration.getChildren(); | |||
while( children.hasNext() ) | |||
{ | |||
final Configuration child = (Configuration)children.next(); | |||
try | |||
{ | |||
final DataType value = m_engine.createDataType( child.getName() ); | |||
setValue( value ); | |||
m_configurer.configure( value, child, getContext() ); | |||
} | |||
catch( final Exception e ) | |||
{ | |||
throw new ConfigurationException( "Unable to set datatype", e ); | |||
} | |||
} | |||
} | |||
public void setName( final String name ) | |||
{ | |||
m_name = name; | |||
} | |||
public void setValue( final Object value ) | |||
throws AntException | |||
{ | |||
if( null != m_value ) | |||
{ | |||
throw new AntException( "Value can not be set multiple times" ); | |||
} | |||
m_value = value; | |||
} | |||
public void setLocalScope( final boolean localScope ) | |||
{ | |||
m_localScope = localScope; | |||
} | |||
public void run() | |||
throws AntException | |||
{ | |||
if( null == m_name ) | |||
{ | |||
throw new AntException( "Name must be specified" ); | |||
} | |||
if( null == m_value ) | |||
{ | |||
throw new AntException( "Value must be specified" ); | |||
} | |||
final TaskletContext context = getContext(); | |||
Object value = m_value; | |||
if( value instanceof String ) | |||
{ | |||
value = context.resolveValue( (String)value ); | |||
} | |||
while( null != value && value instanceof Resolvable ) | |||
{ | |||
value = ((Resolvable)value).resolve( context ); | |||
} | |||
if( m_localScope ) | |||
{ | |||
context.setProperty( m_name, value ); | |||
} | |||
else | |||
{ | |||
context.setProperty( m_name, value, TaskletContext.PARENT ); | |||
} | |||
} | |||
} |
@@ -1,140 +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.tasks.core; | |||
import java.io.File; | |||
import java.net.URL; | |||
import java.net.MalformedURLException; | |||
import org.apache.ant.AntException; | |||
import org.apache.avalon.camelot.DefaultLocator; | |||
import org.apache.ant.convert.ConverterEngine; | |||
import org.apache.ant.convert.DefaultConverterInfo; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
import org.apache.ant.tasklet.engine.TaskletEngine; | |||
import org.apache.avalon.ComponentManager; | |||
import org.apache.avalon.ComponentManagerException; | |||
import org.apache.avalon.Composer; | |||
import org.apache.avalon.camelot.DeploymentException; | |||
import org.apache.avalon.camelot.RegistryException; | |||
/** | |||
* Method to register a single converter. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
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 ComponentManagerException | |||
{ | |||
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 ); | |||
final DefaultLocator locator = new DefaultLocator( m_classname, url ); | |||
try | |||
{ | |||
m_engine.getConverterEngine().getInfoRegistry().register( m_classname, info ); | |||
m_engine.getConverterEngine().getRegistry().register( m_classname, locator ); | |||
} | |||
catch( final RegistryException re ) | |||
{ | |||
throw new AntException( "Error registering resource", re ); | |||
} | |||
} | |||
} | |||
protected URL getURL( final String libName ) | |||
{ | |||
if( null != libName ) | |||
{ | |||
final File lib = getContext().resolveFile( libName ); | |||
try { return lib.toURL(); } | |||
catch( final MalformedURLException mue ) | |||
{ | |||
throw new AntException( "Malformed task-lib parameter " + m_lib, mue ); | |||
} | |||
} | |||
else | |||
{ | |||
return null; | |||
} | |||
} | |||
} |
@@ -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.tasks.core; | |||
import java.net.URL; | |||
import org.apache.ant.AntException; | |||
import org.apache.avalon.camelot.DefaultLocator; | |||
import org.apache.avalon.camelot.DeploymentException; | |||
import org.apache.avalon.camelot.RegistryException; | |||
/** | |||
* Method to register a single datatype. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class RegisterDataType | |||
extends AbstractResourceRegisterer | |||
{ | |||
protected void registerResource( final String name, | |||
final String classname, | |||
final URL url ) | |||
throws AntException, RegistryException | |||
{ | |||
if( null == classname ) | |||
{ | |||
try { m_engine.getTskDeployer().deployDataType( name, url.toString(), url ); } | |||
catch( final DeploymentException de ) | |||
{ | |||
throw new AntException( "Failed deploying " + name + " from " + url, de ); | |||
} | |||
} | |||
else | |||
{ | |||
final DefaultLocator locator = new DefaultLocator( classname, url ); | |||
m_engine.getDataTypeEngine().getRegistry().register( name, locator ); | |||
} | |||
} | |||
} |
@@ -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.tasks.core; | |||
import java.net.URL; | |||
import org.apache.ant.AntException; | |||
import org.apache.avalon.camelot.DefaultLocator; | |||
import org.apache.avalon.camelot.DeploymentException; | |||
import org.apache.avalon.camelot.RegistryException; | |||
/** | |||
* Method to register a single tasklet. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class RegisterTasklet | |||
extends AbstractResourceRegisterer | |||
{ | |||
protected void registerResource( final String name, | |||
final String classname, | |||
final URL url ) | |||
throws AntException, RegistryException | |||
{ | |||
if( null == classname ) | |||
{ | |||
try { m_engine.getTskDeployer().deployTasklet( name, url.toString(), url ); } | |||
catch( final DeploymentException de ) | |||
{ | |||
throw new AntException( "Failed deploying " + name + " from " + url, de ); | |||
} | |||
} | |||
else | |||
{ | |||
final DefaultLocator locator = new DefaultLocator( classname, url ); | |||
m_engine.getRegistry().register( name, locator ); | |||
} | |||
} | |||
} |
@@ -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.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.ComponentManagerException; | |||
import org.apache.avalon.Composer; | |||
import org.apache.avalon.camelot.DeploymentException; | |||
/** | |||
* Method to register a tasklib. | |||
* | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class RegisterTasklib | |||
extends AbstractTasklet | |||
implements Composer | |||
{ | |||
protected String m_lib; | |||
protected TaskletEngine m_engine; | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentManagerException | |||
{ | |||
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 = getContext().resolveFile( 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 ); | |||
} | |||
} | |||
} |
@@ -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.tasks.core; | |||
import org.apache.ant.AntException; | |||
import org.apache.ant.tasklet.AbstractTasklet; | |||
/** | |||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
*/ | |||
public class SubElementTest | |||
extends AbstractTasklet | |||
{ | |||
public static final class Beep | |||
{ | |||
public void setMessage( final String string ) | |||
{ | |||
System.out.println( string ); | |||
} | |||
} | |||
public Beep createCreateBeep() | |||
{ | |||
System.out.println( "createCreateBeep()" ); | |||
return new Beep(); | |||
} | |||
public void addAddBeep( final Beep beep ) | |||
{ | |||
System.out.println( "addBeeper(" + beep + ");" ); | |||
} | |||
public void run() | |||
throws AntException | |||
{ | |||
} | |||
} |