git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269654 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -15,7 +15,7 @@ import org.apache.myrmidon.api.TaskException; | |||||
| * | * | ||||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | ||||
| */ | */ | ||||
| public class Echo | |||||
| public class Echo | |||||
| extends AbstractTask | extends AbstractTask | ||||
| { | { | ||||
| private String m_message; | private String m_message; | ||||
| @@ -7,6 +7,8 @@ | |||||
| */ | */ | ||||
| package org.apache.myrmidon.libs.core; | package org.apache.myrmidon.libs.core; | ||||
| 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.ComponentException; | ||||
| import org.apache.avalon.framework.component.ComponentManager; | import org.apache.avalon.framework.component.ComponentManager; | ||||
| import org.apache.avalon.framework.component.Composable; | import org.apache.avalon.framework.component.Composable; | ||||
| @@ -32,6 +34,9 @@ public class Property | |||||
| extends AbstractContainerTask | extends AbstractContainerTask | ||||
| implements Configurable | implements Configurable | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( Property.class ); | |||||
| private String m_name; | private String m_name; | ||||
| private Object m_value; | private Object m_value; | ||||
| private boolean m_localScope = true; | private boolean m_localScope = true; | ||||
| @@ -46,7 +51,8 @@ public class Property | |||||
| try { m_factory = typeManager.getFactory( DataType.ROLE ); } | try { m_factory = typeManager.getFactory( DataType.ROLE ); } | ||||
| catch( final TypeException te ) | catch( final TypeException te ) | ||||
| { | { | ||||
| throw new ComponentException( "Unable to retrieve factory from TypeManager", te ); | |||||
| final String message = REZ.getString( "property.bad-factory.error" ); | |||||
| throw new ComponentException( message, te ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -72,7 +78,8 @@ public class Property | |||||
| } | } | ||||
| catch( final Exception e ) | catch( final Exception e ) | ||||
| { | { | ||||
| throw new ConfigurationException( "Unable to set datatype", e ); | |||||
| final String message = REZ.getString( "property.no-set.error" ); | |||||
| throw new ConfigurationException( message, e ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -87,7 +94,8 @@ public class Property | |||||
| { | { | ||||
| if( null != m_value ) | if( null != m_value ) | ||||
| { | { | ||||
| throw new TaskException( "Value can not be set multiple times" ); | |||||
| final String message = REZ.getString( "property.multi-set.error" ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| m_value = value; | m_value = value; | ||||
| @@ -103,12 +111,14 @@ public class Property | |||||
| { | { | ||||
| if( null == m_name ) | if( null == m_name ) | ||||
| { | { | ||||
| throw new TaskException( "Name must be specified" ); | |||||
| final String message = REZ.getString( "property.no-name.error" ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| if( null == m_value ) | if( null == m_value ) | ||||
| { | { | ||||
| throw new TaskException( "Value must be specified" ); | |||||
| final String message = REZ.getString( "property.no-value.error" ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| if( m_localScope ) | if( m_localScope ) | ||||
| @@ -0,0 +1,15 @@ | |||||
| property.bad-factory.error=Unable to retrieve DataType factory from TypeManager. | |||||
| property.no-set.error=Unable to set datatype. | |||||
| property.multi-set.error=Value can not be set multiple times. | |||||
| property.no-name.error=Name must be specified. | |||||
| property.no-value.error=Value must be specified. | |||||
| convert.bad-byte.error=Error converting object ({0}) to Byte. | |||||
| convert.bad-class.error=Error converting object ({0}) to Class. | |||||
| convert.bad-double.error=Error converting object ({0}) to Double. | |||||
| convert.bad-file.error=Error converting object ({0}) to File. | |||||
| convert.bad-float.error=Error converting object ({0}) to Float. | |||||
| convert.bad-integer.error=Error converting object ({0}) to Integer. | |||||
| convert.bad-long.error=Error converting object ({0}) to Long. | |||||
| convert.bad-short.error=Error converting object ({0}) to Short. | |||||
| convert.bad-url.error=Error converting object ({0}) to URL. | |||||
| @@ -7,6 +7,8 @@ | |||||
| */ | */ | ||||
| package org.apache.myrmidon.libs.core; | package org.apache.myrmidon.libs.core; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.avalon.framework.context.Context; | import org.apache.avalon.framework.context.Context; | ||||
| import org.apache.myrmidon.converter.AbstractConverter; | import org.apache.myrmidon.converter.AbstractConverter; | ||||
| import org.apache.myrmidon.converter.ConverterException; | import org.apache.myrmidon.converter.ConverterException; | ||||
| @@ -19,20 +21,23 @@ import org.apache.myrmidon.converter.ConverterException; | |||||
| public class StringToByteConverter | public class StringToByteConverter | ||||
| extends AbstractConverter | extends AbstractConverter | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( StringToByteConverter.class ); | |||||
| public StringToByteConverter() | public StringToByteConverter() | ||||
| { | { | ||||
| super( String.class, Byte.class ); | super( String.class, Byte.class ); | ||||
| } | } | ||||
| public Object convert( final Object original, final Context context ) | |||||
| public Object convert( final Object object, final Context context ) | |||||
| throws ConverterException | throws ConverterException | ||||
| { | { | ||||
| try { return new Byte( (String)original ); } | |||||
| try { return new Byte( (String)object ); } | |||||
| catch( final NumberFormatException nfe ) | catch( final NumberFormatException nfe ) | ||||
| { | { | ||||
| throw new ConverterException( "Error formatting object", nfe ); | |||||
| final String message = REZ.getString( "convert.bad-byte.error", object ); | |||||
| throw new ConverterException( message, nfe ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -7,6 +7,8 @@ | |||||
| */ | */ | ||||
| package org.apache.myrmidon.libs.core; | package org.apache.myrmidon.libs.core; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.avalon.framework.context.Context; | import org.apache.avalon.framework.context.Context; | ||||
| import org.apache.myrmidon.converter.AbstractConverter; | import org.apache.myrmidon.converter.AbstractConverter; | ||||
| import org.apache.myrmidon.converter.ConverterException; | import org.apache.myrmidon.converter.ConverterException; | ||||
| @@ -19,19 +21,23 @@ import org.apache.myrmidon.converter.ConverterException; | |||||
| public class StringToClassConverter | public class StringToClassConverter | ||||
| extends AbstractConverter | extends AbstractConverter | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( StringToClassConverter.class ); | |||||
| public StringToClassConverter() | public StringToClassConverter() | ||||
| { | { | ||||
| super( String.class, Class.class ); | super( String.class, Class.class ); | ||||
| } | } | ||||
| public Object convert( final Object original, final Context context ) | |||||
| public Object convert( final Object object, final Context context ) | |||||
| throws ConverterException | throws ConverterException | ||||
| { | { | ||||
| //TODO: Should we use ContextClassLoader here??? | //TODO: Should we use ContextClassLoader here??? | ||||
| try { return Class.forName( (String)original ); } | |||||
| try { return Class.forName( (String)object ); } | |||||
| catch( final Exception e ) | catch( final Exception e ) | ||||
| { | { | ||||
| throw new ConverterException( "Error converting to class type", e ); | |||||
| final String message = REZ.getString( "convert.bad-class.error", object ); | |||||
| throw new ConverterException( message, e ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -7,6 +7,8 @@ | |||||
| */ | */ | ||||
| package org.apache.myrmidon.libs.core; | package org.apache.myrmidon.libs.core; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.avalon.framework.context.Context; | import org.apache.avalon.framework.context.Context; | ||||
| import org.apache.myrmidon.converter.AbstractConverter; | import org.apache.myrmidon.converter.AbstractConverter; | ||||
| import org.apache.myrmidon.converter.ConverterException; | import org.apache.myrmidon.converter.ConverterException; | ||||
| @@ -19,18 +21,22 @@ import org.apache.myrmidon.converter.ConverterException; | |||||
| public class StringToDoubleConverter | public class StringToDoubleConverter | ||||
| extends AbstractConverter | extends AbstractConverter | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( StringToDoubleConverter.class ); | |||||
| public StringToDoubleConverter() | public StringToDoubleConverter() | ||||
| { | { | ||||
| super( String.class, Double.class ); | super( String.class, Double.class ); | ||||
| } | } | ||||
| public Object convert( final Object original, final Context context ) | |||||
| public Object convert( final Object object, final Context context ) | |||||
| throws ConverterException | throws ConverterException | ||||
| { | { | ||||
| try { return new Double( (String)original ); } | |||||
| try { return new Double( (String)object ); } | |||||
| catch( final NumberFormatException nfe ) | catch( final NumberFormatException nfe ) | ||||
| { | { | ||||
| throw new ConverterException( "Error formatting object", nfe ); | |||||
| final String message = REZ.getString( "convert.bad-double.error", object ); | |||||
| throw new ConverterException( message, nfe ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -8,6 +8,8 @@ | |||||
| package org.apache.myrmidon.libs.core; | package org.apache.myrmidon.libs.core; | ||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.avalon.framework.context.Context; | import org.apache.avalon.framework.context.Context; | ||||
| import org.apache.myrmidon.api.TaskContext; | import org.apache.myrmidon.api.TaskContext; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| @@ -22,22 +24,26 @@ import org.apache.myrmidon.converter.ConverterException; | |||||
| public class StringToFileConverter | public class StringToFileConverter | ||||
| extends AbstractConverter | extends AbstractConverter | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( StringToFileConverter.class ); | |||||
| public StringToFileConverter() | public StringToFileConverter() | ||||
| { | { | ||||
| super( String.class, File.class ); | super( String.class, File.class ); | ||||
| } | } | ||||
| public Object convert( final Object original, final Context context ) | |||||
| public Object convert( final Object object, final Context context ) | |||||
| throws ConverterException | throws ConverterException | ||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| final TaskContext taskContext = (TaskContext)context; | final TaskContext taskContext = (TaskContext)context; | ||||
| return taskContext.resolveFile( (String)original ); | |||||
| return taskContext.resolveFile( (String)object ); | |||||
| } | } | ||||
| catch( final TaskException te ) | catch( final TaskException te ) | ||||
| { | { | ||||
| throw new ConverterException( "Error resolving file during conversion", te ); | |||||
| final String message = REZ.getString( "convert.bad-file.error", object ); | |||||
| throw new ConverterException( message, te ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -7,6 +7,8 @@ | |||||
| */ | */ | ||||
| package org.apache.myrmidon.libs.core; | package org.apache.myrmidon.libs.core; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.avalon.framework.context.Context; | import org.apache.avalon.framework.context.Context; | ||||
| import org.apache.myrmidon.converter.AbstractConverter; | import org.apache.myrmidon.converter.AbstractConverter; | ||||
| import org.apache.myrmidon.converter.ConverterException; | import org.apache.myrmidon.converter.ConverterException; | ||||
| @@ -19,18 +21,22 @@ import org.apache.myrmidon.converter.ConverterException; | |||||
| public class StringToFloatConverter | public class StringToFloatConverter | ||||
| extends AbstractConverter | extends AbstractConverter | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( StringToFloatConverter.class ); | |||||
| public StringToFloatConverter() | public StringToFloatConverter() | ||||
| { | { | ||||
| super( String.class, Float.class ); | super( String.class, Float.class ); | ||||
| } | } | ||||
| public Object convert( final Object original, final Context context ) | |||||
| public Object convert( final Object object, final Context context ) | |||||
| throws ConverterException | throws ConverterException | ||||
| { | { | ||||
| try { return new Float( (String)original ); } | |||||
| try { return new Float( (String)object ); } | |||||
| catch( final NumberFormatException nfe ) | catch( final NumberFormatException nfe ) | ||||
| { | { | ||||
| throw new ConverterException( "Error formatting object", nfe ); | |||||
| final String message = REZ.getString( "convert.bad-float.error", object ); | |||||
| throw new ConverterException( message, nfe ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -7,6 +7,8 @@ | |||||
| */ | */ | ||||
| package org.apache.myrmidon.libs.core; | package org.apache.myrmidon.libs.core; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.avalon.framework.context.Context; | import org.apache.avalon.framework.context.Context; | ||||
| import org.apache.myrmidon.converter.AbstractConverter; | import org.apache.myrmidon.converter.AbstractConverter; | ||||
| import org.apache.myrmidon.converter.ConverterException; | import org.apache.myrmidon.converter.ConverterException; | ||||
| @@ -19,18 +21,22 @@ import org.apache.myrmidon.converter.ConverterException; | |||||
| public class StringToIntegerConverter | public class StringToIntegerConverter | ||||
| extends AbstractConverter | extends AbstractConverter | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( StringToFloatConverter.class ); | |||||
| public StringToIntegerConverter() | public StringToIntegerConverter() | ||||
| { | { | ||||
| super( String.class, Integer.class ); | super( String.class, Integer.class ); | ||||
| } | } | ||||
| public Object convert( final Object original, final Context context ) | |||||
| public Object convert( final Object object, final Context context ) | |||||
| throws ConverterException | throws ConverterException | ||||
| { | { | ||||
| try { return new Integer( (String)original ); } | |||||
| try { return new Integer( (String)object ); } | |||||
| catch( final NumberFormatException nfe ) | catch( final NumberFormatException nfe ) | ||||
| { | { | ||||
| throw new ConverterException( "Error formatting object", nfe ); | |||||
| final String message = REZ.getString( "convert.bad-integer.error", object ); | |||||
| throw new ConverterException( message, nfe ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -7,6 +7,8 @@ | |||||
| */ | */ | ||||
| package org.apache.myrmidon.libs.core; | package org.apache.myrmidon.libs.core; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.avalon.framework.context.Context; | import org.apache.avalon.framework.context.Context; | ||||
| import org.apache.myrmidon.converter.AbstractConverter; | import org.apache.myrmidon.converter.AbstractConverter; | ||||
| import org.apache.myrmidon.converter.ConverterException; | import org.apache.myrmidon.converter.ConverterException; | ||||
| @@ -19,18 +21,22 @@ import org.apache.myrmidon.converter.ConverterException; | |||||
| public class StringToLongConverter | public class StringToLongConverter | ||||
| extends AbstractConverter | extends AbstractConverter | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( StringToLongConverter.class ); | |||||
| public StringToLongConverter() | public StringToLongConverter() | ||||
| { | { | ||||
| super( String.class, Long.class ); | super( String.class, Long.class ); | ||||
| } | } | ||||
| public Object convert( final Object original, final Context context ) | |||||
| public Object convert( final Object object, final Context context ) | |||||
| throws ConverterException | throws ConverterException | ||||
| { | { | ||||
| try { return new Long( (String)original ); } | |||||
| try { return new Long( (String)object ); } | |||||
| catch( final NumberFormatException nfe ) | catch( final NumberFormatException nfe ) | ||||
| { | { | ||||
| throw new ConverterException( "Error formatting object", nfe ); | |||||
| final String message = REZ.getString( "convert.bad-long.error", object ); | |||||
| throw new ConverterException( message, nfe ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -7,6 +7,8 @@ | |||||
| */ | */ | ||||
| package org.apache.myrmidon.libs.core; | package org.apache.myrmidon.libs.core; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.avalon.framework.context.Context; | import org.apache.avalon.framework.context.Context; | ||||
| import org.apache.myrmidon.converter.AbstractConverter; | import org.apache.myrmidon.converter.AbstractConverter; | ||||
| import org.apache.myrmidon.converter.ConverterException; | import org.apache.myrmidon.converter.ConverterException; | ||||
| @@ -19,20 +21,23 @@ import org.apache.myrmidon.converter.ConverterException; | |||||
| public class StringToShortConverter | public class StringToShortConverter | ||||
| extends AbstractConverter | extends AbstractConverter | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( StringToShortConverter.class ); | |||||
| public StringToShortConverter() | public StringToShortConverter() | ||||
| { | { | ||||
| super( String.class, Short.class ); | super( String.class, Short.class ); | ||||
| } | } | ||||
| public Object convert( final Object original, final Context context ) | |||||
| public Object convert( final Object object, final Context context ) | |||||
| throws ConverterException | throws ConverterException | ||||
| { | { | ||||
| try { return new Short( (String)original ); } | |||||
| try { return new Short( (String)object ); } | |||||
| catch( final NumberFormatException nfe ) | catch( final NumberFormatException nfe ) | ||||
| { | { | ||||
| throw new ConverterException( "Error formatting object", nfe ); | |||||
| final String message = REZ.getString( "convert.bad-short.error", object ); | |||||
| throw new ConverterException( message, nfe ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -9,6 +9,8 @@ package org.apache.myrmidon.libs.core; | |||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.avalon.framework.context.Context; | import org.apache.avalon.framework.context.Context; | ||||
| import org.apache.myrmidon.converter.AbstractConverter; | import org.apache.myrmidon.converter.AbstractConverter; | ||||
| import org.apache.myrmidon.converter.ConverterException; | import org.apache.myrmidon.converter.ConverterException; | ||||
| @@ -21,18 +23,22 @@ import org.apache.myrmidon.converter.ConverterException; | |||||
| public class StringToURLConverter | public class StringToURLConverter | ||||
| extends AbstractConverter | extends AbstractConverter | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( StringToURLConverter.class ); | |||||
| public StringToURLConverter() | public StringToURLConverter() | ||||
| { | { | ||||
| super( String.class, URL.class ); | super( String.class, URL.class ); | ||||
| } | } | ||||
| public Object convert( final Object original, final Context context ) | |||||
| public Object convert( final Object object, final Context context ) | |||||
| throws ConverterException | throws ConverterException | ||||
| { | { | ||||
| try { return new URL( (String)original ); } | |||||
| try { return new URL( (String)object ); } | |||||
| catch( final MalformedURLException mue ) | catch( final MalformedURLException mue ) | ||||
| { | { | ||||
| throw new ConverterException( "Error formatting object", mue ); | |||||
| final String message = REZ.getString( "convert.bad-url.error", object ); | |||||
| throw new ConverterException( message, mue ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -10,6 +10,8 @@ package org.apache.myrmidon.libs.runtime; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import java.net.URL; | 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.ComponentException; | ||||
| import org.apache.avalon.framework.component.ComponentManager; | import org.apache.avalon.framework.component.ComponentManager; | ||||
| import org.apache.avalon.framework.component.Composable; | import org.apache.avalon.framework.component.Composable; | ||||
| @@ -29,6 +31,9 @@ public class ConverterDef | |||||
| extends AbstractTask | extends AbstractTask | ||||
| implements Composable | implements Composable | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( ConverterDef.class ); | |||||
| private String m_sourceType; | private String m_sourceType; | ||||
| private String m_destinationType; | private String m_destinationType; | ||||
| private File m_lib; | private File m_lib; | ||||
| @@ -68,19 +73,23 @@ public class ConverterDef | |||||
| { | { | ||||
| if( null == m_classname ) | if( null == m_classname ) | ||||
| { | { | ||||
| throw new TaskException( "Must specify classname parameter" ); | |||||
| final String message = REZ.getString( "converterdef.no-classname.error" ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| else if( null == m_sourceType ) | else if( null == m_sourceType ) | ||||
| { | { | ||||
| throw new TaskException( "Must specify the source-type parameter" ); | |||||
| final String message = REZ.getString( "converterdef.no-source.error" ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| else if( null == m_destinationType ) | else if( null == m_destinationType ) | ||||
| { | { | ||||
| throw new TaskException( "Must specify the destination-type parameter" ); | |||||
| final String message = REZ.getString( "converterdef.no-destination.error" ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| else if( null == m_lib ) | else if( null == m_lib ) | ||||
| { | { | ||||
| throw new TaskException( "Must specify the lib parameter" ); | |||||
| final String message = REZ.getString( "converterdef.no-lib.error" ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| try | try | ||||
| @@ -95,7 +104,8 @@ public class ConverterDef | |||||
| } | } | ||||
| catch( final Exception e ) | catch( final Exception e ) | ||||
| { | { | ||||
| throw new TaskException( "Failed to register converter " + m_classname, e ); | |||||
| final String message = REZ.getString( "converterdef.no-register.error", m_classname ); | |||||
| throw new TaskException( message, e ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -10,19 +10,21 @@ package org.apache.myrmidon.libs.runtime; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import org.apache.avalon.framework.configuration.Configurable; | |||||
| import org.apache.avalon.framework.configuration.Configuration; | |||||
| import org.apache.avalon.framework.configuration.ConfigurationException; | |||||
| 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.ComponentException; | ||||
| import org.apache.avalon.framework.component.ComponentManager; | import org.apache.avalon.framework.component.ComponentManager; | ||||
| import org.apache.avalon.framework.component.Composable; | 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; | |||||
| import org.apache.myrmidon.api.AbstractTask; | import org.apache.myrmidon.api.AbstractTask; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.aspects.AspectHandler; | |||||
| import org.apache.myrmidon.components.aspect.AspectManager; | import org.apache.myrmidon.components.aspect.AspectManager; | ||||
| import org.apache.myrmidon.components.type.TypeFactory; | |||||
| import org.apache.myrmidon.components.type.TypeException; | import org.apache.myrmidon.components.type.TypeException; | ||||
| import org.apache.myrmidon.components.type.TypeFactory; | |||||
| import org.apache.myrmidon.components.type.TypeManager; | import org.apache.myrmidon.components.type.TypeManager; | ||||
| import org.apache.myrmidon.aspects.AspectHandler; | |||||
| import org.apache.myrmidon.framework.AbstractContainerTask; | import org.apache.myrmidon.framework.AbstractContainerTask; | ||||
| /** | /** | ||||
| @@ -32,26 +34,30 @@ import org.apache.myrmidon.framework.AbstractContainerTask; | |||||
| */ | */ | ||||
| public class Facility | public class Facility | ||||
| extends AbstractContainerTask | extends AbstractContainerTask | ||||
| implements Composable, Configurable | |||||
| implements Composable, Configurable | |||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( Facility.class ); | |||||
| private String m_namespace; | private String m_namespace; | ||||
| private AspectHandler m_aspectHandler; | private AspectHandler m_aspectHandler; | ||||
| private AspectManager m_aspectManager; | private AspectManager m_aspectManager; | ||||
| private TypeFactory m_factory; | private TypeFactory m_factory; | ||||
| public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
| throws ComponentException | throws ComponentException | ||||
| { | { | ||||
| super.compose( componentManager ); | super.compose( componentManager ); | ||||
| m_aspectManager = (AspectManager)componentManager.lookup( AspectManager.ROLE ); | m_aspectManager = (AspectManager)componentManager.lookup( AspectManager.ROLE ); | ||||
| final TypeManager typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | final TypeManager typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | ||||
| try { m_factory = typeManager.getFactory( AspectHandler.ROLE ); } | try { m_factory = typeManager.getFactory( AspectHandler.ROLE ); } | ||||
| catch( final TypeException te ) | catch( final TypeException te ) | ||||
| { | { | ||||
| throw new ComponentException( "Unable to retrieve factory from TypeManager", te ); | |||||
| final String message = REZ.getString( "facility.no-factory.error" ); | |||||
| throw new ComponentException( message, te ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -68,7 +74,7 @@ public class Facility | |||||
| final Configuration[] children = configuration.getChildren(); | final Configuration[] children = configuration.getChildren(); | ||||
| if( 1 == children.length ) | |||||
| if( 1 == children.length ) | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -76,16 +82,17 @@ public class Facility | |||||
| } | } | ||||
| catch( final Exception e ) | catch( final Exception e ) | ||||
| { | { | ||||
| throw new ConfigurationException( "Failed to create aspect handler of type '" + | |||||
| children[ 0 ].getName() + "'", e ); | |||||
| final String message = | |||||
| REZ.getString( "facility.no-create.error", children[ 0 ].getName() ); | |||||
| throw new ConfigurationException( message, e ); | |||||
| } | } | ||||
| configure( m_aspectHandler, children[ 0 ] ); | configure( m_aspectHandler, children[ 0 ] ); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new ConfigurationException( "Expected one sub-element to " + | |||||
| "configure facility" ); | |||||
| final String message = REZ.getString( "facility.multi-element.error" ); | |||||
| throw new ConfigurationException( message ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -99,7 +106,8 @@ public class Facility | |||||
| { | { | ||||
| if( null == m_namespace ) | if( null == m_namespace ) | ||||
| { | { | ||||
| throw new TaskException( "Must specify namespace parameter" ); | |||||
| final String message = REZ.getString( "facility.no-namespace.error" ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| m_aspectManager.addAspectHandler( m_namespace, m_aspectHandler ); | m_aspectManager.addAspectHandler( m_namespace, m_aspectHandler ); | ||||
| @@ -7,6 +7,8 @@ | |||||
| */ | */ | ||||
| package org.apache.myrmidon.libs.runtime; | package org.apache.myrmidon.libs.runtime; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| @@ -27,6 +29,9 @@ public class Import | |||||
| extends AbstractTask | extends AbstractTask | ||||
| implements Composable | implements Composable | ||||
| { | { | ||||
| private static final Resources REZ = | |||||
| ResourceManager.getPackageResources( Import.class ); | |||||
| private File m_lib; | private File m_lib; | ||||
| private Deployer m_deployer; | private Deployer m_deployer; | ||||
| @@ -46,7 +51,8 @@ public class Import | |||||
| { | { | ||||
| if( null == m_lib ) | if( null == m_lib ) | ||||
| { | { | ||||
| throw new TaskException( "Must specify lib parameter" ); | |||||
| final String message = REZ.getString( "import.no-lib.error" ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| try | try | ||||
| @@ -55,7 +61,8 @@ public class Import | |||||
| } | } | ||||
| catch( final DeploymentException de ) | catch( final DeploymentException de ) | ||||
| { | { | ||||
| throw new TaskException( "Error importing tasklib", de ); | |||||
| final String message = REZ.getString( "import.no-deploy.error" ); | |||||
| throw new TaskException( message, de ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,13 @@ | |||||
| converterdef.no-classname.error=Must specify classname parameter. | |||||
| converterdef.no-source.error=Must specify the source-type parameter. | |||||
| 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. | |||||
| import.no-lib.error=Must specify lib parameter. | |||||
| import.no-deploy.error=Error importing tasklib. | |||||