git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269653 13f79535-47bb-0310-9956-ffa450edef68master
@@ -7,6 +7,10 @@ | |||
*/ | |||
package org.apache.myrmidon.framework; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.excalibur.property.PropertyException; | |||
import org.apache.avalon.excalibur.property.PropertyUtil; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
@@ -14,13 +18,11 @@ 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.TaskException; | |||
import org.apache.myrmidon.converter.Converter; | |||
import org.apache.myrmidon.converter.ConverterException; | |||
import org.apache.myrmidon.components.configurer.Configurer; | |||
import org.apache.myrmidon.components.converter.MasterConverter; | |||
import org.apache.myrmidon.components.executor.Executor; | |||
import org.apache.avalon.excalibur.property.PropertyException; | |||
import org.apache.avalon.excalibur.property.PropertyUtil; | |||
import org.apache.myrmidon.converter.Converter; | |||
import org.apache.myrmidon.converter.ConverterException; | |||
/** | |||
* This is the class that Task writers should extend to provide custom tasks. | |||
@@ -31,6 +33,9 @@ public abstract class AbstractContainerTask | |||
extends AbstractTask | |||
implements Composable | |||
{ | |||
private static final Resources REZ = | |||
ResourceManager.getPackageResources( AbstractContainerTask.class ); | |||
///For converting own attributes | |||
private MasterConverter m_converter; | |||
@@ -60,20 +65,21 @@ public abstract class AbstractContainerTask | |||
{ | |||
try | |||
{ | |||
final Object object = | |||
final Object object = | |||
PropertyUtil.resolveProperty( value, getContext(), false ); | |||
if( null == object ) | |||
{ | |||
throw new ConfigurationException( "Value (" + value + | |||
") resolved to null" ); | |||
final String message = REZ.getString( "container.null-value.error", value ); | |||
throw new ConfigurationException( message ); | |||
} | |||
return object; | |||
} | |||
catch( final PropertyException pe ) | |||
{ | |||
throw new ConfigurationException( "Error resolving value: " + value, pe ); | |||
final String message = REZ.getString( "container.bad-resolve.error", value ); | |||
throw new ConfigurationException( message, pe ); | |||
} | |||
} | |||
@@ -94,7 +100,8 @@ public abstract class AbstractContainerTask | |||
} | |||
catch( final ConverterException ce ) | |||
{ | |||
throw new ConfigurationException( "Error converting value", ce ); | |||
final String message = REZ.getString( "container.bad-config.error" ); | |||
throw new ConfigurationException( message, ce ); | |||
} | |||
} | |||
@@ -10,6 +10,8 @@ package org.apache.myrmidon.framework; | |||
import java.io.File; | |||
import java.net.URL; | |||
import java.net.URLClassLoader; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
@@ -31,6 +33,9 @@ public abstract class AbstractTypeDef | |||
extends AbstractTask | |||
implements Composable | |||
{ | |||
private static final Resources REZ = | |||
ResourceManager.getPackageResources( AbstractTypeDef.class ); | |||
private File m_lib; | |||
private String m_name; | |||
private String m_className; | |||
@@ -65,11 +70,13 @@ public abstract class AbstractTypeDef | |||
{ | |||
if( null == m_name ) | |||
{ | |||
throw new TaskException( "Must specify name parameter" ); | |||
final String message = REZ.getString( "typedef.no-name.error" ); | |||
throw new TaskException( message ); | |||
} | |||
else if( null == m_className ) | |||
{ | |||
throw new TaskException( "Must specify classname parameter" ); | |||
final String message = REZ.getString( "typedef.no-classname.error" ); | |||
throw new TaskException( message ); | |||
} | |||
final String typeName = getTypeName(); | |||
@@ -82,7 +89,8 @@ public abstract class AbstractTypeDef | |||
try { m_typeManager.registerType( role, m_name, factory ); } | |||
catch( final TypeException te ) | |||
{ | |||
throw new TaskException( "Failed to register type", te ); | |||
final String message = REZ.getString( "typedef.no-register.error" ); | |||
throw new TaskException( message, te ); | |||
} | |||
} | |||
@@ -100,7 +108,8 @@ public abstract class AbstractTypeDef | |||
} | |||
catch( final Exception e ) | |||
{ | |||
throw new TaskException( "Failed to build classLoader due to: " + e, e ); | |||
final String message = REZ.getString( "typedef.bad-classloader.error", e ); | |||
throw new TaskException( message, e ); | |||
} | |||
} | |||
@@ -7,6 +7,8 @@ | |||
*/ | |||
package org.apache.myrmidon.framework; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.excalibur.property.PropertyException; | |||
import org.apache.avalon.excalibur.property.PropertyUtil; | |||
import org.apache.avalon.framework.component.Component; | |||
@@ -22,6 +24,9 @@ import org.apache.myrmidon.api.TaskException; | |||
public class Condition | |||
implements Component | |||
{ | |||
private static final Resources REZ = | |||
ResourceManager.getPackageResources( Condition.class ); | |||
private String m_condition; | |||
private boolean m_isIfCondition; | |||
@@ -66,7 +71,8 @@ public class Condition | |||
} | |||
catch( final PropertyException pe ) | |||
{ | |||
throw new ContextException( "Error resolving " + m_condition, pe ); | |||
final String message = REZ.getString( "condition.no-resolve.error", m_condition ); | |||
throw new ContextException( message, pe ); | |||
} | |||
if( !m_isIfCondition ) | |||
@@ -7,6 +7,8 @@ | |||
*/ | |||
package org.apache.myrmidon.framework; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.myrmidon.api.TaskException; | |||
/** | |||
@@ -17,6 +19,9 @@ import org.apache.myrmidon.api.TaskException; | |||
public class Pattern | |||
implements DataType | |||
{ | |||
private static final Resources REZ = | |||
ResourceManager.getPackageResources( Pattern.class ); | |||
private String m_value; | |||
private Condition m_condition; | |||
@@ -95,7 +100,8 @@ public class Pattern | |||
{ | |||
if( null != m_condition ) | |||
{ | |||
throw new TaskException( "Can only set one of if/else for pattern data type" ); | |||
final String message = REZ.getString( "pattern.ifelse-duplicate.error" ); | |||
throw new TaskException( message ); | |||
} | |||
} | |||
} |
@@ -0,0 +1,16 @@ | |||
container.null-value.error=Value ({0}) resolved to null. | |||
container.bad-resolve.error=Error resolving value ({0}). | |||
container.bad-config.error=Error converting value. | |||
typedef.no-name.error=Must specify name parameter. | |||
typedef.no-classname.error=Must specify classname parameter. | |||
typedef.no-register.error=Failed to register type. | |||
typedef.bad-classloader.error=Failed to build classLoader due to: {0}. | |||
condition.no-resolve.error=Error resolving {0}. | |||
pattern.ifelse-duplicate.error=Can only set one of if/else for pattern data type. | |||
type.no-factory.error=Unable to retrieve DataType factory from TypeManager. | |||
type.no-create.error=Unable to create datatype. | |||
type.no-id.error=Id must be specified. |
@@ -7,6 +7,8 @@ | |||
*/ | |||
package org.apache.myrmidon.framework; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
@@ -29,6 +31,9 @@ public class TypeInstanceTask | |||
extends AbstractContainerTask | |||
implements Configurable | |||
{ | |||
private static final Resources REZ = | |||
ResourceManager.getPackageResources( TypeInstanceTask.class ); | |||
private String m_id; | |||
private Object m_value; | |||
private boolean m_localScope = true; | |||
@@ -43,7 +48,8 @@ public class TypeInstanceTask | |||
try { m_factory = typeManager.getFactory( DataType.ROLE ); } | |||
catch( final TypeException te ) | |||
{ | |||
throw new ComponentException( "Unable to retrieve factory from TypeManager", te ); | |||
final String message = REZ.getString( "type.no-factory.error" ); | |||
throw new ComponentException( message, te ); | |||
} | |||
} | |||
@@ -81,7 +87,8 @@ public class TypeInstanceTask | |||
} | |||
catch( final Exception e ) | |||
{ | |||
throw new ConfigurationException( "Unable to create datatype", e ); | |||
final String message = REZ.getString( "type.no-create.error" ); | |||
throw new ConfigurationException( message, e ); | |||
} | |||
configure( m_value, newConfiguration ); | |||
@@ -102,7 +109,8 @@ public class TypeInstanceTask | |||
{ | |||
if( null == m_id ) | |||
{ | |||
throw new TaskException( "Id must be specified" ); | |||
final String message = REZ.getString( "type.no-id.error" ); | |||
throw new TaskException( message ); | |||
} | |||
if( m_localScope ) | |||