costin 2002/12/12 16:52:18 Modified: src/main/org/apache/tools/ant ProjectHelper.java Log: Add a method to support configuration using SAX2 attributes. Changed ( at least for few now ) the default helper to the SAX2 processor. The original processor can still be used using the system property, and we can revert if we have see problems. Description4 still fails - I'll add try to fix it later, I don't think it's a big show-stopper. Revision Changes Path 1.90 +42 -1 jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java Index: ProjectHelper.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java,v retrieving revision 1.89 retrieving revision 1.90 diff -u -r1.89 -r1.90 --- ProjectHelper.java 25 Jul 2002 15:21:01 -0000 1.89 +++ ProjectHelper.java 13 Dec 2002 00:52:18 -0000 1.90 @@ -63,8 +63,10 @@ import java.util.Locale; import java.util.Vector; import org.apache.tools.ant.helper.ProjectHelperImpl; +import org.apache.tools.ant.helper.ProjectHelper2; import org.apache.tools.ant.util.LoaderUtils; import org.xml.sax.AttributeList; +import org.xml.sax.Attributes; /** * Configures a Project (complete with Targets and Tasks) based on @@ -213,7 +215,8 @@ } else { try { // Default - return new ProjectHelperImpl(); + // return new ProjectHelperImpl(); + return new ProjectHelper2(); } catch (Throwable e) { String message = "Unable to load default ProjectHelper due to " + e.getClass().getName() + ": " + e.getMessage(); @@ -308,6 +311,44 @@ } catch (BuildException be) { // id attribute must be set externally if (!attrs.getName(i).equals("id")) { + throw be; + } + } + } + } + + /** Configure a component using SAX2 attributes. + */ + public static void configure( Object target, Attributes attrs, Project project ) + throws BuildException + { + if (target instanceof TaskAdapter) { + target = ((TaskAdapter) target).getProxy(); + } + + IntrospectionHelper ih = + IntrospectionHelper.getHelper(target.getClass()); + + // Why ??? + project.addBuildListener(ih); + + for (int i = 0; i < attrs.getLength(); i++) { + // reflect these into the target + String attValue=attrs.getValue(i); + + // XXX ADD SPECIAL CASE FOR ${property} - don't convert to string + // and support ARRAYS. + // reflect these into the target + //String value = replaceProperties(attValue); + String value = replaceProperties(project, attValue, + project.getProperties()); + try { + ih.setAttribute(project, target, + attrs.getQName(i).toLowerCase(Locale.US), value); + + } catch (BuildException be) { + // id attribute must be set externally + if (!attrs.getQName(i).equals("id")) { throw be; } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>