You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2002/05/02 06:03:53 UTC
cvs commit: jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components AbstractComponentTest.java
donaldp 02/05/01 21:03:53
Modified: api/src/java/org/apache/myrmidon/api TaskContext.java
container/src/java/org/apache/myrmidon/components/embeddor
DefaultEmbeddor.java
container/src/java/org/apache/myrmidon/components/executor
DefaultExecutor.java
container/src/java/org/apache/myrmidon/components/property
DefaultPropertyStore.java
container/src/java/org/apache/myrmidon/components/workspace
DefaultExecutionFrame.java DefaultTaskContext.java
DefaultWorkspace.java
container/src/java/org/apache/myrmidon/interfaces/executor
ExecutionFrame.java
container/src/test/org/apache/myrmidon/components
AbstractComponentTest.java
Log:
Handle BASE_DIRECTORY in TaskContext/ExecutionFrame specially rather than as
a property.
Revision Changes Path
1.32 +1 -7 jakarta-ant-myrmidon/api/src/java/org/apache/myrmidon/api/TaskContext.java
Index: TaskContext.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/api/src/java/org/apache/myrmidon/api/TaskContext.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- TaskContext.java 28 Apr 2002 06:06:12 -0000 1.31
+++ TaskContext.java 2 May 2002 04:03:52 -0000 1.32
@@ -16,19 +16,13 @@
* path between the container and the Task.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.31 $ $Date: 2002/04/28 06:06:12 $
+ * @version $Revision: 1.32 $ $Date: 2002/05/02 04:03:52 $
*
* @todo Add some additional standard properties.
*/
public interface TaskContext
{
// Sandard properties that every TaskContext must contain
-
- /**
- * The name of the base directory property. This property must be present.
- */
- String BASE_DIRECTORY = "myrmidon.base.directory";
-
/**
* The name of the container description. This is an optional property.
*/
1.56 +2 -1 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java
Index: DefaultEmbeddor.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- DefaultEmbeddor.java 28 Apr 2002 05:51:00 -0000 1.55
+++ DefaultEmbeddor.java 2 May 2002 04:03:52 -0000 1.56
@@ -64,7 +64,7 @@
* Instantiate this to embed inside other applications.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.55 $ $Date: 2002/04/28 05:51:00 $
+ * @version $Revision: 1.56 $ $Date: 2002/05/02 04:03:52 $
*/
public class DefaultEmbeddor
extends AbstractLogEnabled
@@ -150,6 +150,7 @@
final TaskEventManager eventManager = (TaskEventManager)m_workspaceServiceManager.lookup( TaskEventManager.ROLE );
final ExecutionFrame frame =
new DefaultExecutionFrame( "",
+ new File( "." ),
getLogger(),
propStore,
m_workspaceServiceManager,
1.40 +4 -2 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java
Index: DefaultExecutor.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- DefaultExecutor.java 25 Apr 2002 11:33:35 -0000 1.39
+++ DefaultExecutor.java 2 May 2002 04:03:52 -0000 1.40
@@ -26,7 +26,7 @@
* The basic executor that just executes the tasks.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.39 $ $Date: 2002/04/25 11:33:35 $
+ * @version $Revision: 1.40 $ $Date: 2002/05/02 04:03:52 $
*/
public class DefaultExecutor
extends AbstractLogEnabled
@@ -115,7 +115,9 @@
{
// TODO - need to deactivate the context once the task has finished
// executing
- return new DefaultTaskContext( frame, taskModel.getName(), taskModel.getLocation() );
+ return new DefaultTaskContext( frame,
+ taskModel.getName(),
+ taskModel.getLocation() );
}
/**
1.3 +1 -24 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/property/DefaultPropertyStore.java
Index: DefaultPropertyStore.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/property/DefaultPropertyStore.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultPropertyStore.java 28 Apr 2002 06:06:12 -0000 1.2
+++ DefaultPropertyStore.java 2 May 2002 04:03:52 -0000 1.3
@@ -7,13 +7,11 @@
*/
package org.apache.myrmidon.components.property;
-import java.io.File;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.interfaces.oldmodel.DefaultNameValidator;
import org.apache.myrmidon.interfaces.oldmodel.NameValidator;
@@ -30,7 +28,7 @@
* </ul>
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.2 $ $Date: 2002/04/28 06:06:12 $
+ * @version $Revision: 1.3 $ $Date: 2002/05/02 04:03:52 $
* @see org.apache.myrmidon.interfaces.property.PropertyStore
*/
public class DefaultPropertyStore
@@ -96,7 +94,6 @@
throws TaskException
{
checkPropertyName( name );
- checkPropertyValid( name, value );
if( value == null )
{
@@ -199,26 +196,6 @@
{
String message = REZ.getString( "bad-property-name.error", name );
throw new TaskException( message, e );
- }
- }
-
- /**
- * Make sure property is valid if it is one of the "magic" properties.
- *
- * @param name the name of property
- * @param value the value of proeprty
- * @exception org.apache.myrmidon.api.TaskException if an error occurs
- */
- private void checkPropertyValid( final String name, final Object value )
- throws TaskException
- {
- if( TaskContext.BASE_DIRECTORY.equals( name ) && !( value instanceof File ) )
- {
- final String message =
- REZ.getString( "bad-property.error",
- TaskContext.BASE_DIRECTORY,
- File.class.getName() );
- throw new TaskException( message );
}
}
1.9 +31 -15 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultExecutionFrame.java
Index: DefaultExecutionFrame.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultExecutionFrame.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DefaultExecutionFrame.java 28 Apr 2002 06:06:13 -0000 1.8
+++ DefaultExecutionFrame.java 2 May 2002 04:03:52 -0000 1.9
@@ -13,29 +13,33 @@
import org.apache.myrmidon.interfaces.event.TaskEventManager;
import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
import org.apache.myrmidon.interfaces.property.PropertyStore;
+import java.io.File;
/**
* Frames in which tasks are executed.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.8 $ $Date: 2002/04/28 06:06:13 $
+ * @version $Revision: 1.9 $ $Date: 2002/05/02 04:03:52 $
*/
public class DefaultExecutionFrame
implements ExecutionFrame
{
private final String m_name;
+ private final File m_baseDirectory;
private final Logger m_logger;
private final PropertyStore m_propertyStore;
private final ServiceManager m_serviceManager;
private final TaskEventManager m_eventManager;
public DefaultExecutionFrame( final String name,
+ final File baseDirectory,
final Logger logger,
final PropertyStore propertyStore,
final ServiceManager serviceManager,
final TaskEventManager eventManager )
{
m_name = name;
+ m_baseDirectory = baseDirectory;
m_logger = logger;
m_propertyStore = propertyStore;
m_serviceManager = serviceManager;
@@ -54,6 +58,11 @@
return m_name;
}
+ public File getBaseDirectory()
+ {
+ return m_baseDirectory;
+ }
+
/**
* Returns the logger which is to be supplied to tasks.
*/
@@ -97,20 +106,27 @@
* @see ExecutionFrame#createChildFrame
*/
public ExecutionFrame createChildFrame( final String name,
+ final File baseDirectory,
final boolean partition )
{
+ final String newName = getName() + "/" + name;
+ File dir = baseDirectory;
+ if( null == dir )
+ {
+ dir = getBaseDirectory();
+ }
if( !partition )
{
- final String newName = m_name + "/" + name;
return new DefaultExecutionFrame( newName,
- m_logger,
- m_propertyStore,
- m_serviceManager,
- m_eventManager );
+ dir,
+ getLogger(),
+ getPropertyStore(),
+ getServiceManager(),
+ getTaskEventManager() );
}
else
{
- return createPartitionedFrame( name );
+ return createPartitionedFrame( newName, dir );
}
}
@@ -118,22 +134,22 @@
* Create a partitioned pane so that modifications of child
* elements does not effect parent objects.
*
- * @param name the relative name of frame
+ * @param newName the name of new frame
* @return the partiioned frame that is created
*/
- private ExecutionFrame createPartitionedFrame( final String name )
+ private ExecutionFrame createPartitionedFrame( final String newName,
+ final File dir )
{
- final String newName = m_name + "/" + name;
- final Logger logger = m_logger.getChildLogger( name );
final PropertyStore propertyStore =
- m_propertyStore.createChildStore();
+ getPropertyStore().createChildStore();
final DefaultServiceManager serviceManager =
- new DefaultServiceManager( m_serviceManager );
+ new DefaultServiceManager( getServiceManager() );
return new DefaultExecutionFrame( newName,
- logger,
+ dir,
+ getLogger(),
propertyStore,
serviceManager,
- m_eventManager );
+ getTaskEventManager() );
}
}
1.43 +4 -2 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java
Index: DefaultTaskContext.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- DefaultTaskContext.java 28 Apr 2002 06:06:13 -0000 1.42
+++ DefaultTaskContext.java 2 May 2002 04:03:52 -0000 1.43
@@ -28,7 +28,7 @@
* Default implementation of TaskContext.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.42 $ $Date: 2002/04/28 06:06:13 $
+ * @version $Revision: 1.43 $ $Date: 2002/05/02 04:03:52 $
*/
public class DefaultTaskContext
implements TaskContext
@@ -38,6 +38,7 @@
private final ExecutionFrame m_frame;
private final String m_name;
+ private final File m_baseDirectory;
private final String m_location;
private TaskEventManager m_eventManager;
@@ -63,6 +64,7 @@
}
m_frame = frame;
m_name = name;
+ m_baseDirectory = frame.getBaseDirectory();
m_location = location;
m_eventManager = (TaskEventManager)getService( TaskEventManager.class );
}
@@ -84,7 +86,7 @@
*/
public File getBaseDirectory()
{
- return (File)getProperty( BASE_DIRECTORY );
+ return m_baseDirectory;
}
/**
1.51 +4 -8 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java
Index: DefaultWorkspace.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- DefaultWorkspace.java 28 Apr 2002 05:04:49 -0000 1.50
+++ DefaultWorkspace.java 2 May 2002 04:03:52 -0000 1.51
@@ -17,7 +17,6 @@
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.DefaultServiceManager;
import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.metadata.ModelElement;
import org.apache.myrmidon.interfaces.deployer.Deployer;
@@ -40,7 +39,7 @@
* This is the default implementation of Workspace.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.50 $ $Date: 2002/04/28 05:04:49 $
+ * @version $Revision: 1.51 $ $Date: 2002/05/02 04:03:52 $
*/
public class DefaultWorkspace
extends AbstractLogEnabled
@@ -206,13 +205,9 @@
{
final ExecutionFrame frame =
m_frame.createChildFrame( project.getProjectName(),
+ project.getBaseDirectory(),
true );
- //Set up property store indicating BaseDirectory
- frame.getPropertyStore().
- setProperty( TaskContext.BASE_DIRECTORY,
- project.getBaseDirectory() );
-
//WARNING: Huge UGly hack on next line
//Need to fix it up so that we are using a mutable
//ServiceManager or maybe more desirably have a separate
@@ -406,8 +401,9 @@
getLogger().debug( message );
}
+ final ExecutionFrame parentFrame = entry.getFrame();
final ExecutionFrame frame =
- entry.getFrame().createChildFrame( name, false );
+ parentFrame.createChildFrame( name, null, false );
// Execute all tasks assciated with target
final ModelElement[] tasks = target.getTasks();
1.14 +12 -1 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/executor/ExecutionFrame.java
Index: ExecutionFrame.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/executor/ExecutionFrame.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ExecutionFrame.java 28 Apr 2002 05:24:43 -0000 1.13
+++ ExecutionFrame.java 2 May 2002 04:03:53 -0000 1.14
@@ -11,6 +11,7 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.myrmidon.interfaces.event.TaskEventManager;
import org.apache.myrmidon.interfaces.property.PropertyStore;
+import java.io.File;
/**
* An Execution Frame represents the scope in which tasks are executed.
@@ -22,7 +23,7 @@
* a logger.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.13 $ $Date: 2002/04/28 05:24:43 $
+ * @version $Revision: 1.14 $ $Date: 2002/05/02 04:03:53 $
*/
public interface ExecutionFrame
{
@@ -39,6 +40,13 @@
String getName();
/**
+ * Returns the directory in which the frame executes.
+ *
+ * @return the working directory of frame
+ */
+ File getBaseDirectory();
+
+ /**
* Returns the set of services to use to create, configure, and execute
* tasks.
*/
@@ -75,9 +83,12 @@
* (and child frames).</p>
*
* @param name the name of child frame relative to current frame
+ * @param baseDirectory the directory from which frame operates
+ * if null will take current frames name
* @param partition true if frame is partition frame
* @return the new child ExecutionFrame
*/
ExecutionFrame createChildFrame( String name,
+ File baseDirectory,
boolean partition );
}
1.30 +5 -5 jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java
Index: AbstractComponentTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- AbstractComponentTest.java 28 Apr 2002 05:51:00 -0000 1.29
+++ AbstractComponentTest.java 2 May 2002 04:03:53 -0000 1.30
@@ -58,7 +58,7 @@
* A base class for tests for the default components.
*
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
- * @version $Revision: 1.29 $ $Date: 2002/04/28 05:51:00 $
+ * @version $Revision: 1.30 $ $Date: 2002/05/02 04:03:53 $
*/
public abstract class AbstractComponentTest
extends AbstractContainerTestCase
@@ -228,11 +228,11 @@
final TaskEventManager eventManager = (TaskEventManager)serviceManager.lookup( TaskEventManager.ROLE );
final DefaultPropertyStore store = new DefaultPropertyStore();
- final ExecutionFrame frame
- = new DefaultExecutionFrame( "", getLogger(), store, serviceManager, eventManager );
- final TaskContext context = new DefaultTaskContext( frame, "test", "gen:///test:0:0" );
final File baseDir = new File( "." ).getAbsoluteFile();
- context.setProperty( TaskContext.BASE_DIRECTORY, baseDir );
+ final ExecutionFrame frame =
+ new DefaultExecutionFrame( "", baseDir, getLogger(), store, serviceManager, eventManager );
+ final TaskContext context =
+ new DefaultTaskContext( frame, "test", "gen:///test:0:0" );
return context;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>