From 6b6a2ee35f7f985f39c52e36be326a67791d963f Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Thu, 11 Apr 2002 02:41:24 +0000 Subject: [PATCH] Api moved to new CVS git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272351 13f79535-47bb-0310-9956-ffa450edef68 --- proposal/myrmidon/build.xml | 13 +- .../org/apache/myrmidon/api/AbstractTask.java | 75 ------ .../java/org/apache/myrmidon/api/Task.java | 43 ---- .../org/apache/myrmidon/api/TaskContext.java | 224 ------------------ .../apache/myrmidon/api/TaskException.java | 66 ------ .../myrmidon/api/metadata/ModelElement.java | 80 ------- .../myrmidon/api/metadata/Modeller.java | 29 --- .../myrmidon/api/metainfo/TaskInfo.java | 18 -- .../aspects/AbstractAspectHandler.java | 115 --------- .../myrmidon/aspects/AspectHandler.java | 51 ---- .../myrmidon/aspects/NoopAspectHandler.java | 20 -- .../listeners/AbstractProjectListener.java | 68 ------ .../listeners/ClassicProjectListener.java | 101 -------- .../listeners/DefaultProjectListener.java | 57 ----- .../apache/myrmidon/listeners/LogEvent.java | 28 --- .../listeners/NoPrefixProjectListener.java | 27 --- .../myrmidon/listeners/ProjectEvent.java | 22 -- .../myrmidon/listeners/ProjectListener.java | 65 ----- .../myrmidon/listeners/TargetEvent.java | 23 -- .../apache/myrmidon/listeners/TaskEvent.java | 23 -- 20 files changed, 5 insertions(+), 1143 deletions(-) delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/api/AbstractTask.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/api/Task.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskException.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/ModelElement.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/Modeller.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/api/metainfo/TaskInfo.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/aspects/AbstractAspectHandler.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/aspects/AspectHandler.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/aspects/NoopAspectHandler.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/listeners/AbstractProjectListener.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ClassicProjectListener.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/listeners/DefaultProjectListener.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/listeners/LogEvent.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/listeners/NoPrefixProjectListener.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectEvent.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectListener.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TargetEvent.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TaskEvent.java diff --git a/proposal/myrmidon/build.xml b/proposal/myrmidon/build.xml index 4307f355d..f4dc53404 100644 --- a/proposal/myrmidon/build.xml +++ b/proposal/myrmidon/build.xml @@ -252,7 +252,7 @@ Legal: --> - + @@ -273,11 +273,8 @@ Legal: - - - + - @@ -389,7 +386,7 @@ Legal: destdir="${gen.dir}" classpathref="project.class.path"> - + @@ -439,13 +436,13 @@ Legal: - - + Peter Donald - * @version $Revision$ $Date$ - */ -public abstract class AbstractTask - implements Task -{ - ///Variable to hold context for use by sub-classes - private TaskContext m_context; - - /** - * Retrieve context from container. - * - * @param context the context - */ - public void contextualize( final TaskContext context ) - throws TaskException - { - m_context = context; - } - - /** - * Execute task. - * This method is called to perform actual work associated with task. - * It is called after Task has been configured. - * - * @exception TaskException if an error occurs - */ - public abstract void execute() - throws TaskException; - - /** - * Convenience method for sub-class to retrieve context. - * - * @return the context - */ - protected final TaskContext getContext() - { - return m_context; - } - - /** - * Convenience method that returns the project's base directory. - */ - protected final File getBaseDirectory() - { - return getContext().getBaseDirectory(); - } - - /** - * Convenience method that locates a service for this task to use. - * - * @param serviceClass the service to locate. - * @return the service, never returns null. - * @throws TaskException if the service cannot be located. - */ - protected final Object getService( final Class serviceClass ) - throws TaskException - { - return getContext().getService( serviceClass ); - } -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/Task.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/Task.java deleted file mode 100644 index f4015a654..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/api/Task.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.api; - -/** - * This is the interface that tasks implement to be executed in Myrmidon runtime. - * - * Tasks can also choose to implement Avalon Configurable if they wish to directly - * receive the Configuration data representing the task. If this interface is - * not implemented then the container will be responsble for mapping configuration - * onto the task object. - * - * @author Peter Donald - * @version $Revision$ $Date$ - * @ant:role shorthand="task" - */ -public interface Task -{ - String ROLE = Task.class.getName(); - - /** - * Specify the context in which the task operates in. - * The Task will use the TaskContext to receive information - * about it's environment. - */ - void contextualize( TaskContext context ) - throws TaskException; - - /** - * Execute task. - * This method is called to perform actual work associated with task. - * It is called after Task has been Configured. - * - * @exception TaskException if task fails to execute - */ - void execute() - throws TaskException; -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java deleted file mode 100644 index 71083aec7..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.api; - -import java.io.File; -import java.util.Map; - -/** - * This interface represents the Context in which Task is executed. - * Like other Component APIs the TaskContext represents the communication - * path between the container and the Task. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public interface TaskContext -{ - //these are the names of properties that every TaskContext must contain - String BASE_DIRECTORY = "myrmidon.base.directory"; - String NAME = "myrmidon.task.name"; - - /** - * Retrieve Name of task. - * - * @return the name - */ - String getName(); - - /** - * Resolve a value according to the context. - * This involves evaluating the string and replacing - * ${} sequences with property values. - * - * @param value the value to resolve - * @return the resolved value - */ - Object resolveValue( String value ) - throws TaskException; - - /** - * Retrieve property for name. - * - * @param name the name of property - * @return the value of property, or null if the property has no value. - */ - Object getProperty( String name ); - - /** - * Retrieve a copy of all the properties accessible via context. - * - * @return the map of all property names to values - */ - Map getProperties() - throws TaskException; - - /** - * Retrieve a service that is offered by the runtime. - * The actual services registered and in place for the - * task is determined by the container. The returned service - * MUST implement the specified interface. - * - * @param serviceClass the interface class that defines the service - * @return an instance of the service implementing interface specified by parameter - * @exception TaskException is thrown when the service is unavailable or not supported - */ - Object getService( Class serviceClass ) - throws TaskException; - - /** - * Retrieve base directory. - * - * @return the base directory - */ - File getBaseDirectory(); - - /** - * Resolve filename. - * This involves resolving it against baseDirectory and - * removing ../ and ./ references. It also means formatting - * it appropriately for the particular OS (ie different OS have - * different volumes, file conventions etc) - * - * @param filename the filename to resolve - * @return the resolved file - */ - File resolveFile( String filename ) - throws TaskException; - - /** - * Set property value in current context. - * - * @param name the name of property - * @param value the value of property - */ - void setProperty( String name, Object value ) - throws TaskException; - - /** - * Log a debug message. - * - * @param message the message - */ - void debug( String message ); - - /** - * Log a debug message. - * - * @param message the message - * @param throwable the throwable - */ - void debug( String message, Throwable throwable ); - - /** - * Determine if messages of priority "debug" will be logged. - * - * @return true if "debug" messages will be logged - */ - boolean isDebugEnabled(); - - /** - * Log a verbose message. - * - * @param message the message - */ - void verbose( String message ); - - /** - * Log a verbose message. - * - * @param message the message - * @param throwable the throwable - */ - void verbose( String message, Throwable throwable ); - - /** - * Determine if messages of priority "verbose" will be logged. - * - * @return true if "verbose" messages will be logged - */ - boolean isVerboseEnabled(); - - /** - * Log a info message. - * - * @param message the message - */ - void info( String message ); - - /** - * Log a info message. - * - * @param message the message - * @param throwable the throwable - */ - void info( String message, Throwable throwable ); - - /** - * Determine if messages of priority "info" will be logged. - * - * @return true if "info" messages will be logged - */ - boolean isInfoEnabled(); - - /** - * Log a warn message. - * - * @param message the message - */ - void warn( String message ); - - /** - * Log a warn message. - * - * @param message the message - * @param throwable the throwable - */ - void warn( String message, Throwable throwable ); - - /** - * Determine if messages of priority "warn" will be logged. - * - * @return true if "warn" messages will be logged - */ - boolean isWarnEnabled(); - - /** - * Log a error message. - * - * @param message the message - */ - void error( String message ); - - /** - * Log a error message. - * - * @param message the message - * @param throwable the throwable - */ - void error( String message, Throwable throwable ); - - /** - * Determine if messages of priority "error" will be logged. - * - * @return true if "error" messages will be logged - */ - boolean isErrorEnabled(); - - /** - * Create a Child Context. - * This allows separate hierarchly contexts to be easily constructed. - * - * @param name the name of sub-context - * @return the created TaskContext - * @exception TaskException if an error occurs - */ - TaskContext createSubContext( String name ) - throws TaskException; -} - diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskException.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskException.java deleted file mode 100644 index ae715369a..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskException.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.api; - -/** - * TaskException thrown when a problem with tasks etc. - * It is cascading so that further embedded information can be contained. - * ie TaskException was caused by IOException etc. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class TaskException - extends Exception -{ - /** - * The Throwable that caused this exception to be thrown. - */ - private final Throwable m_throwable; - - /** - * Basic constructor for exception that does not specify a message - */ - public TaskException() - { - this( "", null ); - } - - /** - * Basic constructor with a message - * - * @param message the message - */ - public TaskException( final String message ) - { - this( message, null ); - } - - /** - * Constructor that builds cascade so that other exception information can be retained. - * - * @param message the message - * @param throwable the throwable - */ - public TaskException( final String message, final Throwable throwable ) - { - super( message ); - m_throwable = throwable; - } - - /** - * Retrieve root cause of the exception. - * - * @return the root cause - */ - public final Throwable getCause() - { - return m_throwable; - } -} - diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/ModelElement.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/ModelElement.java deleted file mode 100644 index c4fd68a39..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/ModelElement.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.api.metadata; - -/** - * A ModelElement represents the data necessary to configure - * the task or sub-object. It usually represents an XML element in a - * build file and has similar features to XML elements. - * - *

It has a set of un-ordered attributes with each attribute mapping - * a key to a value. The ModelElement can also have either a set of ordered - * sub-elements or text content (one or the other - not both).

- * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ModelElement -{ - /** - * Return an array containing all the child ModelElements - * that are contained within this ModelElement. If this method - * returns an array containing 1 or more elements then it must return null - * for getContent() method. - * - * @todo determine whether we return null or an empty array when no - * child elements. - * @return all the child ModelElements - * @see #getContent() - */ - public ModelElement[] getChildren() - { - return null; - } - - /** - * Return an array containing the names of all the attributes stored - * in this ModelElement. The user can then pass these - * parameters into the getAttribute() method of this class to get the - * value of the attribute. - * - * @return an array of the attribute names - * @see #getAttribute(String) - */ - public String[] getAttributeNames() - { - return null; - } - - /** - * Get the value of the attribute passed in. - * If no such attribute exists return null. - * - * @param name the name of the attribute to retrieve value for - * @return the value of the attribute with specified name or null - * if no such element. - */ - public String getAttribute( final String name ) - { - return null; - } - - /** - * Retrieve the content of this element if any. Will return - * null if no content available. Note it is invalid for this - * method to return a non-null value and the getChildren() - * method to return an array of 1 or more child elements. - * - * @return the content value if any, else null - * @see #getChildren() - */ - public String getContent() - { - return null; - } -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/Modeller.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/Modeller.java deleted file mode 100644 index 1f95fdc4b..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/Modeller.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.api.metadata; - -/** - * The Modeller interface specifies that the implementing object - * wishes to handle its own configuration stage. In which case the - * object is passed the ModelElement representing itself and it uses - * the element to configure itself. - * - * @author Peter Donald - * @version $Revision$ $Date$ - * @see ModelElement - */ -public interface Modeller -{ - /** - * Pass the object a read-only instance of it's own - * model. - * - * @param element the ModelElement representing object - */ - void model( ModelElement element ); -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/metainfo/TaskInfo.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/metainfo/TaskInfo.java deleted file mode 100644 index 859c78578..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/api/metainfo/TaskInfo.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.api.metainfo; - -/** - * This class represents the metadata about the task type. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class TaskInfo -{ -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/aspects/AbstractAspectHandler.java b/proposal/myrmidon/src/java/org/apache/myrmidon/aspects/AbstractAspectHandler.java deleted file mode 100644 index c1d8db691..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/aspects/AbstractAspectHandler.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.aspects; - -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.logger.Logger; -import org.apache.avalon.framework.parameters.Parameters; -import org.apache.myrmidon.api.Task; -import org.apache.myrmidon.api.TaskException; - -/** - * AspectHandler is the interface through which aspects are handled. - * - * @author Conor MacNeill - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public abstract class AbstractAspectHandler - implements AspectHandler -{ - private Parameters m_aspectParameters; - private Configuration[] m_aspectElements; - - private Task m_task; - private Logger m_logger; - private Configuration m_taskModel; - - public Configuration preCreate( final Configuration taskModel ) - throws TaskException - { - return taskModel; - } - - public void aspectSettings( final Parameters parameters, final Configuration[] elements ) - throws TaskException - { - m_aspectParameters = parameters; - m_aspectElements = elements; - } - - public void postCreate( final Task task ) - throws TaskException - { - m_task = task; - } - - public void preLogEnabled( final Logger logger ) - throws TaskException - { - m_logger = logger; - } - - public void preConfigure( final Configuration taskModel ) - throws TaskException - { - m_taskModel = taskModel; - } - - public void preExecute() - throws TaskException - { - } - - public void preDestroy() - throws TaskException - { - reset(); - } - - public boolean error( final TaskException te ) - throws TaskException - { - reset(); - return false; - } - - protected void reset() - { - m_aspectParameters = null; - m_aspectElements = null; - m_task = null; - m_logger = null; - m_taskModel = null; - } - - protected final Configuration getTaskModel() - { - return m_taskModel; - } - - protected final Task getTask() - { - return m_task; - } - - protected final Logger getLogger() - { - return m_logger; - } - - protected final Configuration[] getAspectElements() - { - return m_aspectElements; - } - - protected final Parameters getAspectParameters() - { - return m_aspectParameters; - } -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/aspects/AspectHandler.java b/proposal/myrmidon/src/java/org/apache/myrmidon/aspects/AspectHandler.java deleted file mode 100644 index dcece5851..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/aspects/AspectHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.aspects; - -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.logger.Logger; -import org.apache.avalon.framework.parameters.Parameters; -import org.apache.myrmidon.api.Task; -import org.apache.myrmidon.api.TaskException; - -/** - * AspectHandler is the interface through which aspects are handled. - * - * @author Conor MacNeill - * @author Peter Donald - * @version $Revision$ $Date$ - * @ant:role shorthand="aspect" - */ -public interface AspectHandler -{ - String ROLE = AspectHandler.class.getName(); - - Configuration preCreate( Configuration taskModel ) - throws TaskException; - - void aspectSettings( Parameters parameters, Configuration[] children ) - throws TaskException; - - void postCreate( Task task ) - throws TaskException; - - void preLogEnabled( Logger logger ) - throws TaskException; - - void preConfigure( Configuration taskModel ) - throws TaskException; - - void preExecute() - throws TaskException; - - void preDestroy() - throws TaskException; - - boolean error( TaskException te ) - throws TaskException; -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/aspects/NoopAspectHandler.java b/proposal/myrmidon/src/java/org/apache/myrmidon/aspects/NoopAspectHandler.java deleted file mode 100644 index b65301728..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/aspects/NoopAspectHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.aspects; - -/** - * A Noop aspect handler that does nothing. - * - * @author Peter Donald - * @version $Revision$ $Date$ - * @ant.type type="aspect" name="noop" - */ -public class NoopAspectHandler - extends AbstractAspectHandler -{ -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/AbstractProjectListener.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/AbstractProjectListener.java deleted file mode 100644 index 05865a2c8..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/AbstractProjectListener.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.listeners; - -/** - * Abstract listener from which to extend. This implementation provedes - * empty implementions of each of the event methods. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public abstract class AbstractProjectListener - implements ProjectListener -{ - /** - * Notify listener of projectStarted event. - */ - public void projectStarted( final ProjectEvent event ) - { - } - - /** - * Notify listener of projectFinished event. - */ - public void projectFinished( final ProjectEvent event ) - { - } - - /** - * Notify listener of targetStarted event. - */ - public void targetStarted( final TargetEvent event ) - { - } - - /** - * Notify listener of targetFinished event. - */ - public void targetFinished( final TargetEvent event ) - { - } - - /** - * Notify listener of taskStarted event. - */ - public void taskStarted( final TaskEvent event ) - { - } - - /** - * Notify listener of taskFinished event. - */ - public void taskFinished( final TaskEvent event ) - { - } - - /** - * Notify listener of log message event. - */ - public void log( final LogEvent event ) - { - } -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ClassicProjectListener.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ClassicProjectListener.java deleted file mode 100644 index e73a79bbb..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ClassicProjectListener.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.listeners; - -import java.io.PrintWriter; -import org.apache.avalon.framework.ExceptionUtil; - -/** - * Classic listener that emulates the default ant1.x listener. - * - * @author Peter Donald - * @version $Revision$ $Date$ - * @ant.type type="listener" name="classic" - */ -public class ClassicProjectListener - extends AbstractProjectListener -{ - private final PrintWriter m_printWriter; - - public ClassicProjectListener() - { - m_printWriter = new PrintWriter( System.out, true ); - } - - /** - * Notify listener of targetStarted event. - */ - public void targetStarted( final TargetEvent event ) - { - writeTargetHeader( event ); - } - - /** - * Notify listener of targetFinished event. - */ - public void targetFinished( TargetEvent event ) - { - getWriter().println(); - } - - /** - * Notify listener of log message event. - */ - public void log( final LogEvent event ) - { - writeMessage( event ); - writeThrowable( event ); - } - - /** - * Returns the PrintWriter to write to. - */ - protected PrintWriter getWriter() - { - return m_printWriter; - } - - /** - * Writes the target header. - */ - protected void writeTargetHeader( final TargetEvent event ) - { - getWriter().println( event.getTargetName() + ":" ); - } - - /** - * Writes a message - */ - protected void writeMessage( final LogEvent event ) - { - // Write the message - final String message = event.getMessage(); - final String task = event.getTaskName(); - if( null != task ) - { - getWriter().println( "\t[" + task + "] " + message ); - } - else - { - getWriter().println( message ); - } - } - - /** - * Writes a throwable. - */ - private void writeThrowable( final LogEvent event ) - { - // Write the exception, if any - final Throwable throwable = event.getThrowable(); - if( throwable != null ) - { - getWriter().println( ExceptionUtil.printStackTrace( throwable, 8, true ) ); - } - } -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/DefaultProjectListener.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/DefaultProjectListener.java deleted file mode 100644 index 7fb958d80..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/DefaultProjectListener.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.listeners; - -/** - * Default listener that emulates the Ant 1.x no banner listener. - * - * @author Peter Donald - * @version $Revision$ $Date$ - * @ant.type type="listener" name="default" - */ -public class DefaultProjectListener - extends ClassicProjectListener -{ - private boolean m_targetOutput; - - /** - * Notify listener of targetStarted event. - */ - public void targetStarted( final TargetEvent target ) - { - m_targetOutput = false; - } - - /** - * Notify listener of targetFinished event. - */ - public void targetFinished( final TargetEvent event ) - { - if( m_targetOutput ) - { - getWriter().println(); - } - } - - /** - * Notify listener of log message event. - */ - public void log( final LogEvent event ) - { - // Write the target header, if necessary - final String target = event.getTargetName(); - if( target != null && !m_targetOutput ) - { - writeTargetHeader( event ); - m_targetOutput = true; - } - - // Write the message - super.log( event ); - } -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/LogEvent.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/LogEvent.java deleted file mode 100644 index e14a58383..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/LogEvent.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.listeners; - -/** - * A log message event. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public interface LogEvent - extends TaskEvent -{ - /** - * Returns the message. - */ - String getMessage(); - - /** - * Returns the error that occurred. - */ - Throwable getThrowable(); -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/NoPrefixProjectListener.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/NoPrefixProjectListener.java deleted file mode 100644 index e7634310c..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/NoPrefixProjectListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.listeners; - -/** - * A project listener that emulated the Ant 1.x -emacs mode. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - * @ant.type type="listener" name="noprefix" - */ -public class NoPrefixProjectListener - extends DefaultProjectListener -{ - /** - * Writes a message - */ - protected void writeMessage( LogEvent event ) - { - getWriter().println( event.getMessage() ); - } -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectEvent.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectEvent.java deleted file mode 100644 index ae8a6fa49..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.listeners; - -/** - * A project level event. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public interface ProjectEvent -{ - /** - * Returns the name of the project. - */ - String getProjectName(); -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectListener.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectListener.java deleted file mode 100644 index c94c8aa18..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ProjectListener.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.listeners; - -/** - * The interface to implement if you want to receive - * notification of project status. - * - * @author Peter Donald - * @version $Revision$ $Date$ - * @ant:role shorthand="listener" - * @todo Think about having a way to indicate that a foreign project - * is being referenced, a implicit target is being referenced - * and that a library is being imported. - */ -public interface ProjectListener -{ - String ROLE = ProjectListener.class.getName(); - - /** - * Notify the listener that a project is about to start. This method - * is called for top-level projects only. - */ - void projectStarted( ProjectEvent event ); - - /** - * Notify the listener that a project has finished. This method is called - * for top-level projects only. - */ - void projectFinished( ProjectEvent event ); - - /** - * Notify the listener that a target is about to start. Note that the - * project name reported by the event may be different to that reported - * in {@link #projectStarted}. - */ - void targetStarted( TargetEvent event ); - - /** - * Notify the listener that a target has finished. - */ - void targetFinished( TargetEvent event ); - - /** - * Notify the listener that a task is about to start. - */ - void taskStarted( TaskEvent event ); - - /** - * Notify the listener that a task has finished. - */ - void taskFinished( TaskEvent event ); - - /** - * Notify listener of log message event. Note that this method may - * be called at any time, so the reported task, target, or project names - * may be null. - */ - void log( LogEvent event ); -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TargetEvent.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TargetEvent.java deleted file mode 100644 index e6d282b2a..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TargetEvent.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.listeners; - -/** - * A target level event. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public interface TargetEvent - extends ProjectEvent -{ - /** - * Returns the name of the target. - */ - String getTargetName(); -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TaskEvent.java b/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TaskEvent.java deleted file mode 100644 index 3a3360aae..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/TaskEvent.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.listeners; - -/** - * A task level event. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public interface TaskEvent - extends TargetEvent -{ - /** - * Returns the name of the task. - */ - String getTaskName(); -}