git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272351 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -252,7 +252,7 @@ Legal: | |||||
| --> | --> | ||||
| <patternset refid="myrmidon-launcher.include"/> | <patternset refid="myrmidon-launcher.include"/> | ||||
| <patternset refid="myrmidon-api.include"/> | |||||
| <patternset refid="myrmidon-framework.include"/> | |||||
| <patternset refid="myrmidon-container.include"/> | <patternset refid="myrmidon-container.include"/> | ||||
| <patternset refid="ant1.todo.include"/> | <patternset refid="ant1.todo.include"/> | ||||
| <patternset refid="selftest.include"/> | <patternset refid="selftest.include"/> | ||||
| @@ -273,11 +273,8 @@ Legal: | |||||
| <include name="org/apache/myrmidon/launcher/**" /> | <include name="org/apache/myrmidon/launcher/**" /> | ||||
| </patternset> | </patternset> | ||||
| <patternset id="myrmidon-api.include"> | |||||
| <include name="org/apache/myrmidon/api/**" /> | |||||
| <include name="org/apache/myrmidon/aspects/**" /> | |||||
| <patternset id="myrmidon-framework.include"> | |||||
| <include name="org/apache/myrmidon/interfaces/**" /> | <include name="org/apache/myrmidon/interfaces/**" /> | ||||
| <include name="org/apache/myrmidon/listeners/**" /> | |||||
| <include name="org/apache/myrmidon/framework/**" /> | <include name="org/apache/myrmidon/framework/**" /> | ||||
| </patternset> | </patternset> | ||||
| @@ -389,7 +386,7 @@ Legal: | |||||
| destdir="${gen.dir}" | destdir="${gen.dir}" | ||||
| classpathref="project.class.path"> | classpathref="project.class.path"> | ||||
| <fileset dir="${java.dir}"> | <fileset dir="${java.dir}"> | ||||
| <patternset refid="myrmidon-api.include"/> | |||||
| <patternset refid="myrmidon-framework.include"/> | |||||
| </fileset> | </fileset> | ||||
| </antlib-descriptor> | </antlib-descriptor> | ||||
| @@ -439,13 +436,13 @@ Legal: | |||||
| <patternset refid="myrmidon-container.include"/> | <patternset refid="myrmidon-container.include"/> | ||||
| </antlib-jar> | </antlib-jar> | ||||
| <antlib-jar jarfile="${build.lib}/myrmidon-api.jar" | |||||
| <antlib-jar jarfile="${build.lib}/myrmidon-framework.jar" | |||||
| basedir="${build.classes}" | basedir="${build.classes}" | ||||
| manifest="${manifest.dir}/myrmidon-api.mf" | manifest="${manifest.dir}/myrmidon-api.mf" | ||||
| rolesDescriptor="${gen.dir}/builtin-ant-roles.xml" | rolesDescriptor="${gen.dir}/builtin-ant-roles.xml" | ||||
| descriptor="${gen.dir}/builtin-ant-descriptor.xml" | descriptor="${gen.dir}/builtin-ant-descriptor.xml" | ||||
| servicesDescriptor="${manifest.dir}/core-services.xml" > | servicesDescriptor="${manifest.dir}/core-services.xml" > | ||||
| <patternset refid="myrmidon-api.include"/> | |||||
| <patternset refid="myrmidon-framework.include"/> | |||||
| </antlib-jar> | </antlib-jar> | ||||
| <antlib-jar jarfile="${build.lib}/ant1_todo.jar" | <antlib-jar jarfile="${build.lib}/ant1_todo.jar" | ||||
| @@ -1,75 +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; | |||||
| /** | |||||
| * This is the class that Task writers should extend to provide custom tasks. | |||||
| * | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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 ); | |||||
| } | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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; | |||||
| } | |||||
| @@ -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 <em>Context</em> in which Task is executed. | |||||
| * Like other Component APIs the TaskContext represents the communication | |||||
| * path between the container and the Task. | |||||
| * | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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 | |||||
| * <b>MUST</b> 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; | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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; | |||||
| } | |||||
| } | |||||
| @@ -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. | |||||
| * | |||||
| * <p>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).</p> | |||||
| * | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public class ModelElement | |||||
| { | |||||
| /** | |||||
| * Return an array containing all the child <code>ModelElement</code>s | |||||
| * that are contained within this <code>ModelElement</code>. 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 <code>ModelElement</code>s | |||||
| * @see #getContent() | |||||
| */ | |||||
| public ModelElement[] getChildren() | |||||
| { | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * Return an array containing the names of all the attributes stored | |||||
| * in this <code>ModelElement</code>. 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; | |||||
| } | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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 ); | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public class TaskInfo | |||||
| { | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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; | |||||
| } | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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; | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @version $Revision$ $Date$ | |||||
| * @ant.type type="aspect" name="noop" | |||||
| */ | |||||
| public class NoopAspectHandler | |||||
| extends AbstractAspectHandler | |||||
| { | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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 ) | |||||
| { | |||||
| } | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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 ) ); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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 ); | |||||
| } | |||||
| } | |||||
| @@ -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 <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public interface LogEvent | |||||
| extends TaskEvent | |||||
| { | |||||
| /** | |||||
| * Returns the message. | |||||
| */ | |||||
| String getMessage(); | |||||
| /** | |||||
| * Returns the error that occurred. | |||||
| */ | |||||
| Throwable getThrowable(); | |||||
| } | |||||
| @@ -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 <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||||
| * @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() ); | |||||
| } | |||||
| } | |||||
| @@ -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 <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public interface ProjectEvent | |||||
| { | |||||
| /** | |||||
| * Returns the name of the project. | |||||
| */ | |||||
| String getProjectName(); | |||||
| } | |||||
| @@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @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 ); | |||||
| } | |||||
| @@ -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 <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public interface TargetEvent | |||||
| extends ProjectEvent | |||||
| { | |||||
| /** | |||||
| * Returns the name of the target. | |||||
| */ | |||||
| String getTargetName(); | |||||
| } | |||||
| @@ -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 <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public interface TaskEvent | |||||
| extends TargetEvent | |||||
| { | |||||
| /** | |||||
| * Returns the name of the task. | |||||
| */ | |||||
| String getTaskName(); | |||||
| } | |||||