diff --git a/proposal/sandbox/embed/RuntimeConfigurable2.java b/proposal/sandbox/embed/RuntimeConfigurable2.java index f369d9eea..1e594d1cc 100644 --- a/proposal/sandbox/embed/RuntimeConfigurable2.java +++ b/proposal/sandbox/embed/RuntimeConfigurable2.java @@ -58,6 +58,7 @@ import org.apache.tools.ant.helper.*; import java.util.Enumeration; import java.util.Locale; import java.util.Vector; +import java.util.Hashtable; import org.xml.sax.AttributeList; import org.xml.sax.Attributes; import org.xml.sax.helpers.AttributeListImpl; @@ -98,6 +99,8 @@ public class RuntimeConfigurable2 extends RuntimeConfigurable { super( proxy, elementTag ); wrappedObject = proxy; this.elementTag = elementTag; + if( proxy instanceof Task ) + ((Task)proxy).setRuntimeConfigurableWrapper( this ); } /** @@ -280,7 +283,6 @@ public class RuntimeConfigurable2 extends RuntimeConfigurable { 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")) { @@ -329,7 +331,19 @@ public class RuntimeConfigurable2 extends RuntimeConfigurable { return sb.toString(); } + + static Hashtable propertySources=new Hashtable(); + + public static interface ProjectPropertySource { + + public String getProperty( Project project, String key ); + + } + public static void addPropertySource( String ns, ProjectPropertySource src ) { + propertySources.put( ns, src ); + } + /** Use the reference table to generate values for ${} substitution. * To preserve backward compat ( as much as possible ) we'll only process @@ -343,20 +357,6 @@ public class RuntimeConfigurable2 extends RuntimeConfigurable { * bean:idName.propertyName - we get the idName and call the getter for the property. */ static String processReference( Project project, String name ) { - if( name.startsWith("dom:") ) { - name=name.substring( 4 ); - int idx=name.indexOf(":"); - if( idx<0 ) return null; - - String objName=name.substring( 0, idx ); - String path=name.substring( idx ); - System.out.println("XXX dom: " + objName + " " + path ); - - Object v=project.getReference( objName ); - if( v==null ) return null; - - } - if( name.startsWith( "toString:" )) { name=name.substring( "toString:".length()); Object v=project.getReference( name ); @@ -364,26 +364,16 @@ public class RuntimeConfigurable2 extends RuntimeConfigurable { return v.toString(); } - if( name.startsWith( "bean:" )) { - name=name.substring( "toString:".length()); - int idx=name.indexOf(":"); - if( idx<0 ) return null; - - String objName=name.substring( 0, idx ); - String path=name.substring( idx ); - System.out.println("XXX bean: " + objName + " " + path ); + int idx=name.indexOf(":"); + if( idx<0 ) return null; - Object v=project.getReference( objName ); - if( v==null ) return null; - - return v.toString(); - } + String ns=name.substring( 0, idx ); + String path=name.substring( idx ); + ProjectPropertySource ps=(ProjectPropertySource)propertySources.get( ns ); + if( ps == null ) + return null; - - // If everything else fails, use toString() - return null; + return ps.getProperty( project, path ); } - - } diff --git a/proposal/sandbox/embed/ant-sax2.jar b/proposal/sandbox/embed/ant-sax2.jar new file mode 100644 index 000000000..8aa825610 Binary files /dev/null and b/proposal/sandbox/embed/ant-sax2.jar differ diff --git a/proposal/sandbox/embed/build.xml b/proposal/sandbox/embed/build.xml new file mode 100644 index 000000000..4df8bef51 --- /dev/null +++ b/proposal/sandbox/embed/build.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proposal/sandbox/embed/org.apache.tools.ant.ProjectHelper b/proposal/sandbox/embed/org.apache.tools.ant.ProjectHelper new file mode 100644 index 000000000..3a148062a --- /dev/null +++ b/proposal/sandbox/embed/org.apache.tools.ant.ProjectHelper @@ -0,0 +1 @@ +org.apache.tools.ant.helper.ProjectHelperImpl2