donaldp 01/08/29 08:34:58
Modified:
proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor
DefaultEmbeddor.java
proposal/myrmidon/src/java/org/apache/myrmidon/components/executor
AspectAwareExecutor.java DefaultExecutor.java
proposal/myrmidon/src/java/org/apache/myrmidon/components/model
DefaultProject.java
proposal/myrmidon/src/java/org/apache/myrmidon/components/role
DefaultRoleManager.java
proposal/myrmidon/src/java/org/apache/myrmidon/components/type
DefaultTypeFactory.java DefaultTypeManager.java
MultiSourceTypeFactory.java
proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace
DefaultWorkspace.java
Added:
proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor
Resources.properties
proposal/myrmidon/src/java/org/apache/myrmidon/components/executor
Resources.properties
proposal/myrmidon/src/java/org/apache/myrmidon/components/model
Resources.properties
proposal/myrmidon/src/java/org/apache/myrmidon/components/role
Resources.properties
proposal/myrmidon/src/java/org/apache/myrmidon/components/type
Resources.properties
proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace
Resources.properties
Log:
i18n-ized remaining components.
Revision Changes Path
1.10 +30 -20
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java
Index: DefaultEmbeddor.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DefaultEmbeddor.java 2001/06/29 08:08:26 1.9
+++ DefaultEmbeddor.java 2001/08/29 15:34:57 1.10
@@ -10,6 +10,8 @@
import java.io.File;
import java.io.FilenameFilter;
import java.util.Map;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.excalibur.io.ExtensionFileFilter;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.avalon.framework.activity.Initializable;
@@ -28,11 +30,11 @@
import org.apache.myrmidon.components.deployer.Deployer;
import org.apache.myrmidon.components.deployer.DeploymentException;
import org.apache.myrmidon.components.executor.Executor;
-import org.apache.myrmidon.components.workspace.Workspace;
import org.apache.myrmidon.components.model.Project;
import org.apache.myrmidon.components.role.RoleManager;
import org.apache.myrmidon.components.type.TypeFactory;
import org.apache.myrmidon.components.type.TypeManager;
+import org.apache.myrmidon.components.workspace.Workspace;
/**
* Default implementation of Embeddor.
@@ -44,6 +46,9 @@
extends AbstractLoggable
implements Embeddor
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DefaultEmbeddor.class );
+
private Deployer m_deployer;
private RoleManager m_roleManager;
@@ -75,8 +80,8 @@
m_parameters = parameters;
}
- public Project createProject( final String location,
- String type,
+ public Project createProject( final String location,
+ String type,
final Parameters parameters )
throws Exception
{
@@ -94,7 +99,7 @@
return FileUtil.getExtension( location );
}
- private ProjectBuilder getProjectBuilder( final String type,
+ private ProjectBuilder getProjectBuilder( final String type,
final Parameters parameters )
throws Exception
{
@@ -112,12 +117,12 @@
if( builder instanceof Parameterizable )
{
((Parameterizable)builder).parameterize( parameters );
- }
+ }
if( builder instanceof Initializable )
{
((Initializable)builder).initialize();
- }
+ }
return builder;
}
@@ -126,7 +131,7 @@
throws Exception
{
final String component = getParameter( Workspace.ROLE );
- final Workspace workspace =
+ final Workspace workspace =
(Workspace)createComponent( component, Workspace.class );
setupLogger( workspace );
@@ -140,12 +145,12 @@
if( workspace instanceof Parameterizable )
{
((Parameterizable)workspace).parameterize( parameters );
- }
+ }
if( workspace instanceof Initializable )
{
((Initializable)workspace).initialize();
- }
+ }
return workspace;
}
@@ -416,11 +421,13 @@
{
if( !file.exists() )
{
- throw new Exception( name + " (" + file + ") does not exist" );
+ final String message = REZ.getString( "file-no-exist.error",
name, file );
+ throw new Exception( message );
}
else if( !file.isDirectory() )
{
- throw new Exception( name + " (" + file + ") is not a directory"
);
+ final String message = REZ.getString( "file-not-dir.error",
name, file );
+ throw new Exception( message );
}
}
@@ -464,28 +471,31 @@
if( !clazz.isInstance( object ) )
{
- throw new Exception( "Object " + component + " is not an
instance of " +
- clazz );
+ final String message = REZ.getString( "bad-type.error",
component, clazz.getName() );
+ throw new Exception( message );
}
return object;
}
catch( final IllegalAccessException iae )
{
- throw new Exception( "Non-public constructor for " + clazz + " "
+ component );
+ final String message = REZ.getString( "bad-ctor.error",
clazz.getName(), component );
+ throw new Exception( message );
}
catch( final InstantiationException ie )
{
- throw new Exception( "Error instantiating class for " + clazz +
" " + component );
+ final String message =
+ REZ.getString( "no-instantiate.error", clazz.getName(),
component );
+ throw new Exception( message );
}
catch( final ClassNotFoundException cnfe )
{
- throw new Exception( "Could not find the class for " + clazz +
- " (" + component + ")" );
+ final String message =
+ REZ.getString( "no-class.error", clazz.getName(), component
);
+ throw new Exception( message );
}
}
-
private void deployFromDirectory( final Deployer deployer,
final File directory,
final FilenameFilter filter )
@@ -522,8 +532,8 @@
}
catch( final Exception e )
{
- throw new DeploymentException( "Unable to retrieve filename
for file " +
- files[ i ], e );
+ final String message = REZ.getString( "bad-filename.error",
files[ i ] );
+ throw new DeploymentException( message, e );
}
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/Resources.properties
Index: Resources.properties
===================================================================
file-no-exist.error={0} ({1}) does not exist.
file-not-dir.error={0} ({1}) is not a directory.
bad-type.error=Object {0} is not an instance of {1}.
bad-ctor.error=Non-public constructor for {0} {1}.
no-instantiate.error=Error instantiating class for {0} {1}.
no-class.error=Could not find the class for {0} ({1}).
bad-filename.error=Unable to retrieve filename for file {0}.
1.6 +50 -39
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/AspectAwareExecutor.java
Index: AspectAwareExecutor.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/AspectAwareExecutor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AspectAwareExecutor.java 2001/06/27 00:50:05 1.5
+++ AspectAwareExecutor.java 2001/08/29 15:34:57 1.6
@@ -7,13 +7,15 @@
*/
package org.apache.myrmidon.components.executor;
-import java.util.HashMap;
import java.util.ArrayList;
+import java.util.HashMap;
+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.configuration.Configuration;
-import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.avalon.framework.parameters.Parameters;
import org.apache.log.Logger;
import org.apache.myrmidon.api.Task;
import org.apache.myrmidon.api.TaskContext;
@@ -24,6 +26,9 @@
public class AspectAwareExecutor
extends DefaultExecutor
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( AspectAwareExecutor.class );
+
private final static Parameters EMPTY_PARAMETERS;
private final static Configuration[] EMPTY_ELEMENTS = new
Configuration[ 0 ];
@@ -71,33 +76,33 @@
taskModel = getAspectManager().preCreate( taskModel );
taskModel = prepareAspects( taskModel );
- getLogger().debug( "Pre-Create" );
+ debug( "creating.notice" );
final Task task = createTask( taskModel.getName(), frame );
getAspectManager().postCreate( task );
- getLogger().debug( "Pre-Loggable" );
+ debug( "logger.notice" );
final Logger logger = frame.getLogger();
getAspectManager().preLoggable( logger );
doLoggable( task, taskModel, logger );
- getLogger().debug( "Contextualizing" );
+ debug( "contextualizing.notice" );
doContextualize( task, taskModel, frame.getContext() );
- getLogger().debug( "Composing" );
+ debug( "composing.notice" );
doCompose( task, taskModel, frame.getComponentManager() );
- getLogger().debug( "Configuring" );
+ debug( "configuring.notice" );
getAspectManager().preConfigure( taskModel );
doConfigure( task, taskModel, frame.getContext() );
- getLogger().debug( "Initializing" );
+ debug( "initializing.notice" );
doInitialize( task, taskModel );
- getLogger().debug( "Executing" );
+ debug( "executing.notice" );
getAspectManager().preExecute();
doExecute( taskModel, task );
- getLogger().debug( "Disposing" );
+ debug( "disposing.notice" );
getAspectManager().preDestroy();
doDispose( task, taskModel );
}
@@ -114,7 +119,7 @@
private final Configuration prepareAspects( final Configuration
taskModel )
throws TaskException
{
- final DefaultConfiguration newTaskModel =
+ final DefaultConfiguration newTaskModel =
new DefaultConfiguration( taskModel.getName(),
taskModel.getLocation() );
final HashMap parameterMap = new HashMap();
final HashMap elementMap = new HashMap();
@@ -128,12 +133,12 @@
return newTaskModel;
}
- private final void dispatchAspectsSettings( final HashMap parameterMap,
+ private final void dispatchAspectsSettings( final HashMap parameterMap,
final HashMap elementMap )
throws TaskException
{
final String[] names = getAspectManager().getNames();
-
+
for( int i = 0; i < names.length; i++ )
{
final ArrayList elementList = (ArrayList)elementMap.remove(
names[ i ] );
@@ -147,18 +152,18 @@
{
elements = (Configuration[])elementList.toArray(
EMPTY_ELEMENTS );
}
-
+
dispatch( names[ i ], parameters, elements );
}
}
- private final void checkForUnusedSettings( final HashMap parameterMap,
+ private final void checkForUnusedSettings( final HashMap parameterMap,
final HashMap elementMap )
throws TaskException
{
if( 0 != parameterMap.size() )
{
- final String[] namespaces =
+ final String[] namespaces =
(String[])parameterMap.keySet().toArray( new String[ 0 ] );
for( int i = 0; i < namespaces.length; i++ )
@@ -166,48 +171,51 @@
final String namespace = namespaces[ i ];
final Parameters parameters = (Parameters)parameterMap.get(
namespace );
final ArrayList elementList = (ArrayList)elementMap.remove(
namespace );
-
+
Configuration[] elements = null;
-
+
if( null == elementList ) elements = EMPTY_ELEMENTS;
else
{
elements = (Configuration[])elementList.toArray(
EMPTY_ELEMENTS );
}
-
+
unusedSetting( namespace, parameters, elements );
}
}
if( 0 != elementMap.size() )
{
- final String[] namespaces =
+ final String[] namespaces =
(String[])elementMap.keySet().toArray( new String[ 0 ] );
-
+
for( int i = 0; i < namespaces.length; i++ )
{
final String namespace = namespaces[ i ];
final ArrayList elementList = (ArrayList)elementMap.remove(
namespace );
- final Configuration[] elements =
+ final Configuration[] elements =
(Configuration[])elementList.toArray( EMPTY_ELEMENTS );
-
+
unusedSetting( namespace, EMPTY_PARAMETERS, elements );
}
}
}
- private void unusedSetting( final String namespace,
- final Parameters parameters,
+ private void unusedSetting( final String namespace,
+ final Parameters parameters,
final Configuration[] elements )
throws TaskException
{
- throw new TaskException( "Unused aspect settings for namespace " +
namespace +
- " (parameterCount=" +
parameters.getNames().length +
- " elementCount=" + elements.length + ")" );
+ final String message =
+ REZ.getString( "unused-settings.error",
+ namespace,
+ Integer.toString( parameters.getNames().length ),
+ Integer.toString( elements.length ) );
+ throw new TaskException( message );
}
- private void dispatch( final String namespace,
- final Parameters parameters,
+ private void dispatch( final String namespace,
+ final Parameters parameters,
final Configuration[] elements )
throws TaskException
{
@@ -215,13 +223,16 @@
if( getLogger().isDebugEnabled() )
{
- getLogger().debug( "Dispatching Aspect Settings to: " +
namespace +
- " parameterCount=" +
parameters.getNames().length +
- " elementCount=" + elements.length );
+ final String message =
+ REZ.getString( "dispatch-settings.notice",
+ namespace,
+ Integer.toString(
parameters.getNames().length ),
+ Integer.toString( elements.length ) );
+ getLogger().debug( message );
}
}
- private final void processElements( final Configuration taskModel,
+ private final void processElements( final Configuration taskModel,
final DefaultConfiguration
newTaskModel,
final HashMap map )
{
@@ -230,8 +241,8 @@
{
final String name = elements[ i ].getName();
final int index = name.indexOf( ':' );
-
- if( -1 == index )
+
+ if( -1 == index )
{
newTaskModel.addChild( elements[ i ] );
}
@@ -245,7 +256,7 @@
}
}
- private final void processAttributes( final Configuration taskModel,
+ private final void processAttributes( final Configuration taskModel,
final DefaultConfiguration
newTaskModel,
final HashMap map )
{
@@ -256,8 +267,8 @@
final String value = taskModel.getAttribute( name, null );
final int index = name.indexOf( ':' );
-
- if( -1 == index )
+
+ if( -1 == index )
{
newTaskModel.setAttribute( name, value );
}
1.11 +64 -30
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java
Index: DefaultExecutor.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DefaultExecutor.java 2001/06/12 13:38:58 1.10
+++ DefaultExecutor.java 2001/08/29 15:34:57 1.11
@@ -7,6 +7,8 @@
*/
package org.apache.myrmidon.components.executor;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.Component;
@@ -34,6 +36,9 @@
extends AbstractLoggable
implements Executor, Composable
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DefaultExecutor.class );
+
private Configurer m_configurer;
/**
@@ -51,30 +56,40 @@
public void execute( final Configuration taskModel, final ExecutionFrame
frame )
throws TaskException
{
- getLogger().debug( "Creating" );
+ debug( "creating.notice" );
final Task task = createTask( taskModel.getName(), frame );
+
+ debug( "logger.notice" );
doLoggable( task, taskModel, frame.getLogger() );
- getLogger().debug( "Contextualizing" );
+ debug( "contextualizing.notice" );
doContextualize( task, taskModel, frame.getContext() );
- getLogger().debug( "Composing" );
+ debug( "composing.notice" );
doCompose( task, taskModel, frame.getComponentManager() );
- getLogger().debug( "Configuring" );
+ debug( "configuring.notice" );
doConfigure( task, taskModel, frame.getContext() );
- getLogger().debug( "Initializing" );
+ debug( "initializing.notice" );
doInitialize( task, taskModel );
- getLogger().debug( "Running" );
-
+ debug( "executing.notice" );
task.execute();
- getLogger().debug( "Disposing" );
+ debug( "disposing.notice" );
doDispose( task, taskModel );
}
+ protected final void debug( final String key )
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message = REZ.getString( key );
+ getLogger().debug( message );
+ }
+ }
+
protected final Task createTask( final String name, final ExecutionFrame
frame )
throws TaskException
{
@@ -85,7 +100,8 @@
}
catch( final TypeException te )
{
- throw new TaskException( "Unable to create task " + name, te );
+ final String message = REZ.getString( "no-create.error", name );
+ throw new TaskException( message, te );
}
}
@@ -97,13 +113,16 @@
try { m_configurer.configure( task, taskModel, context ); }
catch( final Throwable throwable )
{
- throw new TaskException( "Error configuring task " +
taskModel.getName() + " at " +
- taskModel.getLocation() + "(Reason: " +
- throwable.getMessage() + ")", throwable
);
+ final String message =
+ REZ.getString( "config.error",
+ taskModel.getName(),
+ taskModel.getLocation(),
+ throwable.getMessage() );
+ throw new TaskException( message, throwable );
}
}
- protected final void doCompose( final Task task,
+ protected final void doCompose( final Task task,
final Configuration taskModel,
final ComponentManager componentManager )
throws TaskException
@@ -113,9 +132,12 @@
try { ((Composable)task).compose( componentManager ); }
catch( final Throwable throwable )
{
- throw new TaskException( "Error composing task " +
taskModel.getName() + " at " +
- taskModel.getLocation() + "(Reason:
" +
- throwable.getMessage() + ")",
throwable );
+ final String message =
+ REZ.getString( "compose.error",
+ taskModel.getName(),
+ taskModel.getLocation(),
+ throwable.getMessage() );
+ throw new TaskException( message, throwable );
}
}
}
@@ -134,9 +156,12 @@
}
catch( final Throwable throwable )
{
- throw new TaskException( "Error contextualizing task " +
taskModel.getName() + " at " +
- taskModel.getLocation() + "(Reason: " +
- throwable.getMessage() + ")", throwable
);
+ final String message =
+ REZ.getString( "compose.error",
+ taskModel.getName(),
+ taskModel.getLocation(),
+ throwable.getMessage() );
+ throw new TaskException( message, throwable );
}
}
@@ -148,15 +173,18 @@
try { ((Disposable)task).dispose(); }
catch( final Throwable throwable )
{
- throw new TaskException( "Error disposing task " +
taskModel.getName() + " at " +
- taskModel.getLocation() + "(Reason:
" +
- throwable.getMessage() + ")",
throwable );
+ final String message =
+ REZ.getString( "dispose.error",
+ taskModel.getName(),
+ taskModel.getLocation(),
+ throwable.getMessage() );
+ throw new TaskException( message, throwable );
}
}
}
- protected final void doLoggable( final Task task,
- final Configuration taskModel,
+ protected final void doLoggable( final Task task,
+ final Configuration taskModel,
final Logger logger )
throws TaskException
{
@@ -165,9 +193,12 @@
try { ((Loggable)task).setLogger( logger ); }
catch( final Throwable throwable )
{
- throw new TaskException( "Error setting logger for task " +
taskModel.getName() +
- " at " + taskModel.getLocation() +
"(Reason: " +
- throwable.getMessage() + ")",
throwable );
+ final String message =
+ REZ.getString( "logger.error",
+ taskModel.getName(),
+ taskModel.getLocation(),
+ throwable.getMessage() );
+ throw new TaskException( message, throwable );
}
}
}
@@ -180,9 +211,12 @@
try { ((Initializable)task).initialize(); }
catch( final Throwable throwable )
{
- throw new TaskException( "Error initializing task " +
taskModel.getName() + " at " +
- taskModel.getLocation() + "(Reason:
" +
- throwable.getMessage() + ")",
throwable );
+ final String message =
+ REZ.getString( "init.error",
+ taskModel.getName(),
+ taskModel.getLocation(),
+ throwable.getMessage() );
+ throw new TaskException( message, throwable );
}
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/Resources.properties
Index: Resources.properties
===================================================================
creating.notice=Creating.
logger.notice=Setting Logger.
contextualizing.notice=Contextualizing.
composing.notice=Composing.
configuring.notice=Configuring.
initializing.notice=Initializing.
executing.notice=Executing.
disposing.notice=Disposing.
no-create.error=Unable to create task {0}.
config.error=Error configuring task {0} at {1} (Reason: {2}).
compose.error=Error composing task {0} at {1} (Reason: {2}).
context.error=Error contextualizing task {0} at {1} (Reason: {2}).
dispose.error=Error disposing task {0} at {1} (Reason: {2}).
init.error=Error initializing task {0} at {1} (Reason: {2}).
logger.error=Error setting logger for task {0} at {1} (Reason: {2}).
unused-settings.error=Unused aspect settings for namespace {0}
(parameterCount={1} elementCount={2}).
dispatch-settings.notice=Dispatching Aspect Settings to namespace {0}
(parameterCount={1} elementCount={2}).
1.6 +9 -4
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/model/DefaultProject.java
Index: DefaultProject.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/model/DefaultProject.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultProject.java 2001/06/27 01:17:18 1.5
+++ DefaultProject.java 2001/08/29 15:34:57 1.6
@@ -11,6 +11,8 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
/**
* Default project implementation.
@@ -20,6 +22,9 @@
public class DefaultProject
implements Project
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DefaultProject.class );
+
///The imports
private final ArrayList m_imports = new ArrayList();
@@ -167,8 +172,8 @@
{
if( null != m_targets.get( name ) )
{
- throw new IllegalArgumentException( "Can not have two targets in
a " +
- "file with the name " + name
);
+ final String message = REZ.getString( "duplicate-target.error",
name );
+ throw new IllegalArgumentException( message );
}
else
{
@@ -187,8 +192,8 @@
{
if( null != m_projects.get( name ) )
{
- throw new IllegalArgumentException( "Can not have two projects
referenced in a " +
- "file with the name " + name
);
+ final String message = REZ.getString( "duplicate-project.error",
name );
+ throw new IllegalArgumentException( message );
}
else
{
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/model/Resources.properties
Index: Resources.properties
===================================================================
duplicate-project.error=Can not have two projects referenced in a file with
the name {0}.
duplicate-target.error=Can not have two targets in a file with the name {0}.
1.2 +10 -5
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/role/DefaultRoleManager.java
Index: DefaultRoleManager.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/role/DefaultRoleManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultRoleManager.java 2001/06/17 10:35:40 1.1
+++ DefaultRoleManager.java 2001/08/29 15:34:57 1.2
@@ -12,6 +12,8 @@
import java.util.HashMap;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -23,11 +25,14 @@
* Interface to manage roles and mapping to names.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version CVS $Revision: 1.1 $ $Date: 2001/06/17 10:35:40 $
+ * @version CVS $Revision: 1.2 $ $Date: 2001/08/29 15:34:57 $
*/
public class DefaultRoleManager
implements RoleManager, Initializable
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DefaultRoleManager.class );
+
private final static String ROLE_DESCRIPTOR = "META-INF/ant-roles.xml";
/** Parent <code>RoleManager</code> for nested resolution */
@@ -152,15 +157,15 @@
final String oldRole = (String)m_names.get( name );
if( null != oldRole && oldRole.equals( role ) )
{
- throw new IllegalArgumentException( "Name already mapped to
another role (" +
- oldRole + ")" );
+ final String message = REZ.getString( "duplicate-name.error",
oldRole );
+ throw new IllegalArgumentException( message );
}
final String oldName = (String)m_roles.get( role );
if( null != oldName && oldName.equals( name ) )
{
- throw new IllegalArgumentException( "Role already mapped to
another name (" +
- oldName + ")" );
+ final String message = REZ.getString( "duplicate-role.error",
oldName );
+ throw new IllegalArgumentException( message );
}
m_names.put( name, role );
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/role/Resources.properties
Index: Resources.properties
===================================================================
duplicate-name.error=Name already mapped to another role ({0}).
duplicate-role.error=Role already mapped to another name ({0}).
1.3 +10 -4
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/DefaultTypeFactory.java
Index: DefaultTypeFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/DefaultTypeFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultTypeFactory.java 2001/06/03 13:11:41 1.2
+++ DefaultTypeFactory.java 2001/08/29 15:34:57 1.3
@@ -10,16 +10,21 @@
import java.net.URL;
import java.util.HashMap;
import java.net.URLClassLoader;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
/**
* Create a type instance based on name.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version CVS $Revision: 1.2 $ $Date: 2001/06/03 13:11:41 $
+ * @version CVS $Revision: 1.3 $ $Date: 2001/08/29 15:34:57 $
*/
public class DefaultTypeFactory
implements TypeFactory
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DefaultTypeFactory.class );
+
///A Map of shortnames to classnames
private final HashMap m_classNames = new HashMap();
@@ -77,7 +82,8 @@
}
catch( final Exception e )
{
- throw new TypeException( "Unable to instantiate '" + name + "'",
e );
+ final String message = REZ.getString( "no-instantiate.error",
name );
+ throw new TypeException( message, e );
}
}
@@ -88,8 +94,8 @@
if( null == className )
{
- throw new TypeException( "Malconfigured factory, no clasname for
'" +
- name + "'" );
+ final String message = REZ.getString( "no-mapping.error", name );
+ throw new TypeException( message );
}
return className;
1.8 +7 -2
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/DefaultTypeManager.java
Index: DefaultTypeManager.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/DefaultTypeManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefaultTypeManager.java 2001/06/12 13:42:22 1.7
+++ DefaultTypeManager.java 2001/08/29 15:34:57 1.8
@@ -8,6 +8,8 @@
package org.apache.myrmidon.components.type;
import java.util.HashMap;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
/**
* The interface that is used to manage types.
@@ -17,6 +19,9 @@
public class DefaultTypeManager
implements TypeManager
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DefaultTypeManager.class );
+
///Parent type manager to inherit values from.
private final DefaultTypeManager m_parent;
@@ -92,8 +97,8 @@
}
catch( final Exception e )
{
- throw new TypeException( "Role '" + role + "' does not
specify " +
- "accessible work interface" );
+ final String message = REZ.getString(
"no-work-interface.error", role );
+ throw new TypeException( message );
}
}
1.3 +12 -6
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/MultiSourceTypeFactory.java
Index: MultiSourceTypeFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/MultiSourceTypeFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MultiSourceTypeFactory.java 2001/06/12 13:42:47 1.2
+++ MultiSourceTypeFactory.java 2001/08/29 15:34:57 1.3
@@ -8,6 +8,8 @@
package org.apache.myrmidon.components.type;
import java.util.HashMap;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
/**
* This factory acts as a proxy to set of object factorys.
@@ -15,8 +17,11 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public class MultiSourceTypeFactory
- implements TypeFactory
+ implements TypeFactory
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( MultiSourceTypeFactory.class );
+
///Parent Selector
private final MultiSourceTypeFactory m_parent;
@@ -58,14 +63,15 @@
{
TypeFactory factory = getTypeFactory( name );
- if( null == factory && null != m_parent )
+ if( null == factory && null != m_parent )
{
factory = m_parent.getTypeFactory( name );
}
- if( null == factory )
+ if( null == factory )
{
- throw new TypeException( "Failed to locate factory for '" + name
+ "'" );
+ final String message = REZ.getString( "no-factory.error", name );
+ throw new TypeException( message );
}
else
{
@@ -73,8 +79,8 @@
if( !m_type.isInstance( object ) )
{
- throw new TypeException( "Object '" + name + "' is not of " +
- "correct Type (" + m_type.getName()
+ ")" );
+ final String message = REZ.getString( "no-factory.error",
name, m_type.getName() );
+ throw new TypeException( message );
}
return object;
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/Resources.properties
Index: Resources.properties
===================================================================
no-instantiate.error=Unable to instantiate ({0}).
no-mapping.error=Malconfigured factory, no clasname for ({0}).
no-factory.error=Failed to locate factory for {0}.
bad-type.error=Object {0} is not of correct Type ({1}).
no-work-interface.error=Role {0} does not specify accessible work interface.
1.5 +33 -20
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java
Index: DefaultWorkspace.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultWorkspace.java 2001/07/08 07:26:44 1.4
+++ DefaultWorkspace.java 2001/08/29 15:34:58 1.5
@@ -12,21 +12,22 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.component.DefaultComponentManager;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.log.Hierarchy;
import org.apache.log.Logger;
-import org.apache.log.LogTarget;
import org.apache.myrmidon.api.DefaultTaskContext;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
@@ -52,6 +53,9 @@
extends AbstractLoggable
implements Workspace, Composable, Parameterizable, Initializable
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DefaultWorkspace.class );
+
private Executor m_executor;
private ProjectListenerSupport m_listenerSupport = new
ProjectListenerSupport();
private ComponentManager m_componentManager;
@@ -109,7 +113,7 @@
m_hierarchy = new Hierarchy();
- final LogTarget target = new LogTargetToListenerAdapter(
m_listenerSupport );
+ final LogTargetToListenerAdapter target = new
LogTargetToListenerAdapter( m_listenerSupport );
m_hierarchy.setDefaultLogTarget( target );
}
@@ -158,21 +162,22 @@
throws TaskException
{
//TODO: In future this will be expanded to allow
- //users to specify search path or automagically
- //add entries to lib path (like user specific or
+ //users to specify search path or automagically
+ //add entries to lib path (like user specific or
//workspace specific)
final String name = libraryName.replace( '/', File.separatorChar ) +
".atl";
final String home = System.getProperty( "myrmidon.home" );
final File homeDir = new File( home + File.separatorChar + "ext" );
-
+
final File library = new File( homeDir, name );
if( library.exists() )
{
if( !library.canRead() )
{
- throw new TaskException( "Unable to read library at " +
library );
+ final String message = REZ.getString( "no-read.error",
library );
+ throw new TaskException( message );
}
else
{
@@ -180,7 +185,8 @@
}
}
- throw new TaskException( "Unable to locate Type Library " +
libraryName );
+ final String message = REZ.getString( "no-library.error",
libraryName );
+ throw new TaskException( message );
}
private void deployTypeLib( final Deployer deployer, final Project
project )
@@ -206,8 +212,8 @@
}
catch( final DeploymentException de )
{
- throw new TaskException( "Error deploying type library " +
- typeLib + " at " + file, de );
+ final String message = REZ.getString( "no-deploy.error",
typeLib, file );
+ throw new TaskException( message, de );
}
}
}
@@ -235,7 +241,8 @@
try { deployer.compose( componentManager ); }
catch( final ComponentException ce )
{
- throw new TaskException( "Error configuring deployer", ce );
+ final String message = REZ.getString(
"bad-deployer-config.error" );
+ throw new TaskException( message, ce );
}
//HACK: Didn't call initialize because Deployer contained in Embeddor
@@ -272,7 +279,8 @@
}
catch( final Exception e )
{
- throw new TaskException( "Error setting up ExecutionFrame", e );
+ final String message = REZ.getString( "bad-frame.error" );
+ throw new TaskException( message, e );
}
return frame;
@@ -301,7 +309,8 @@
if( null == other )
{
//TODO: Fix this so location information included in description
- throw new TaskException( "Project '" + name + "' not found." );
+ final String message = REZ.getString( "no-project.error", name );
+ throw new TaskException( message );
}
return other;
@@ -338,7 +347,8 @@
final Target target = project.getTarget( targetName );
if( null == target )
{
- throw new TaskException( "Unable to find target " + targetName );
+ final String message = REZ.getString( "no-target.error",
targetName );
+ throw new TaskException( message );
}
//add target to list of targets executed
@@ -385,19 +395,20 @@
{
if( false == condition.evaluate( frame.getContext() ) )
{
- getLogger().debug( "Skipping target " + name +
- " as it does not satisfy condition" );
+ final String message = REZ.getString(
"skip-target.notice", name );
+ getLogger().debug( message );
return;
}
}
catch( final ContextException ce )
{
- throw new TaskException( "Error evaluating Condition for
target " +
- name, ce );
+ final String message = REZ.getString(
"condition-eval.error", name );
+ throw new TaskException( message, ce );
}
}
- getLogger().debug( "Executing target " + name );
+ final String message = REZ.getString( "exec-target.notice", name );
+ getLogger().debug( message );
//frame.getContext().setProperty( Project.TARGET, target );
@@ -420,7 +431,9 @@
throws TaskException
{
final String name = task.getName();
- getLogger().debug( "Executing task " + name );
+
+ final String message = REZ.getString( "exec-task.notice", name );
+ getLogger().debug( message );
//is setting name even necessary ???
frame.getContext().setProperty( TaskContext.NAME, name );
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties
Index: Resources.properties
===================================================================
no-read.error=Unable to read library at {0}.
no-library.error=Unable to locate Type Library {0}.
no-deploy.error=Error deploying type library {0} at {1}.
bad-deployer-config.error=Error configuring deployer.
bad-frame.error=Error setting up ExecutionFrame.
no-project.error=Project {0} not found.
no-target.error=Target {0} not found.
skip-target.notice=Skipping target {0} as it does not satisfy condition.
condition-eval.error=Error evaluating Condition for target {0}.
exec-target.notice=Executing target {0}.
exec-task.notice=Executing task {0}.