Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 45563 invoked from network); 11 Oct 2002 18:09:48 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 11 Oct 2002 18:09:48 -0000 Received: (qmail 6094 invoked by uid 97); 11 Oct 2002 18:10:14 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 6031 invoked by uid 97); 11 Oct 2002 18:10:13 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 5957 invoked by uid 97); 11 Oct 2002 18:10:13 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 11 Oct 2002 18:09:19 -0000 Message-ID: <20021011180919.50411.qmail@icarus.apache.org> From: costin@apache.org To: jakarta-ant-cvs@apache.org Subject: cvs commit: jakarta-ant/proposal/embed/src/java/org/apache/tools/ant/helper TaskAdapter2.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N costin 2002/10/11 11:09:19 Modified: proposal/embed/src/java/org/apache/tools/ant/helper TaskAdapter2.java Log: Few changes, added few enhancements I proposed in the past. Again - this is a proposal and an experiment, all features will eventually get to a majority vote and removed or moved out of ant if it doesn't pass. Revision Changes Path 1.2 +20 -52 jakarta-ant/proposal/embed/src/java/org/apache/tools/ant/helper/TaskAdapter2.java Index: TaskAdapter2.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/embed/src/java/org/apache/tools/ant/helper/TaskAdapter2.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TaskAdapter2.java 27 Jul 2002 02:21:34 -0000 1.1 +++ TaskAdapter2.java 11 Oct 2002 18:09:19 -0000 1.2 @@ -67,72 +67,40 @@ * * @author Costin Manolache */ -public class TaskAdapter2 extends Task { - +public class TaskAdapter2 extends Task { // implements DynamicConfigurator { + /* Need to support DynamicConfigurator so that adapted tasks can + support that too. + */ + /** Object to act as a proxy for. */ private Object proxy; private String methodName="execute"; - /** - * Checks whether or not a class is suitable to be adapted by TaskAdapter. - * - * This only checks conditions which are additionally required for - * tasks adapted by TaskAdapter. Thus, this method should be called by - * Project.checkTaskClass. - * - * Throws a BuildException and logs as Project.MSG_ERR for - * conditions that will cause the task execution to fail. - * Logs other suspicious conditions with Project.MSG_WARN. - * - * @param taskClass Class to test for suitability. - * Must not be null. - * @param project Project to log warnings/errors to. - * Must not be null. - * - * @see Project#checkTaskClass(Class) - */ - public static void checkTaskClass(final Class taskClass, final Project project) { - // Any task can be used via adapter. If it doesn't have any execute() - // method, no problem - it will do nothing, but still get an 'id' - // and be registered in the project reference table and useable by other - // tasks. - - if( true ) - return; - - // don't have to check for interface, since then - // taskClass would be abstract too. - try { - final Method executeM = taskClass.getMethod( "execute", null ); - // don't have to check for public, since - // getMethod finds public method only. - // don't have to check for abstract, since then - // taskClass would be abstract too. - if(!Void.TYPE.equals(executeM.getReturnType())) { - final String message = - "return type of execute() should be void but was \""+ - executeM.getReturnType()+"\" in " + taskClass; - project.log(message, Project.MSG_WARN); - } - } catch(NoSuchMethodException e) { - final String message = "No public execute() in " + taskClass; - project.log(message, Project.MSG_ERR); - throw new BuildException(message); - } - } - private IntrospectionHelper ih; void setIntrospectionHelper( IntrospectionHelper ih ) { this.ih=ih; } - IntrospectionHelper getIntrospectionHelper() { + IntrospectionHelper getIntrospectionHelper() + { if( ih==null ) { ih = IntrospectionHelper.getHelper(target.getClass()); } return ih; } + + public void setDynamicAttribute(String name, String value) + throws BuildException + { + setAttribute( name, value ); + } + + public Object createDynamicElement(String name) throws BuildException + { + return null; + } + /** Experimental, non-public method for better 'adaptation' * @@ -174,7 +142,7 @@ setProjectM.invoke(proxy, new Object[] {project}); } } catch (NoSuchMethodException e) { - // ignore this if the class being used as a task does not have + // ignore this if the class being used as a task does not have // a set project method. } catch( Exception ex ) { log("Error setting project in " + proxy.getClass(), -- To unsubscribe, e-mail: For additional commands, e-mail: