diff --git a/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java b/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java index 39a5e057b..41c593aef 100644 --- a/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java +++ b/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java @@ -943,7 +943,7 @@ public class Frame { throw new ExecutionException("The given ant:refid value '" + refId + "' is not defined", model.getLocation()); } - } else { + } else if (nestedType != null) { // We need to create an instance of the class expected by the nested // element's adder method if that is possible if (nestedType.isInterface()) { @@ -954,6 +954,12 @@ public class Frame { } typeInstance = createTypeInstance(nestedType, factory, model, null); + } else { + throw new ExecutionException("The type of the <" + + nestedElementName + "> nested element is not known. " + + "Please specify by the type using the \"ant:type\" " + + "attribute or provide a reference to an instance with " + + "the \"ant:id\" attribute"); } // is the typeInstance compatible with the type expected diff --git a/proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptBase.java b/proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptBase.java index 2af7b619f..d7c2e0248 100644 --- a/proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptBase.java +++ b/proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptBase.java @@ -120,9 +120,12 @@ public class ScriptBase extends AbstractTask implements DeferredTask { try { BSFManager manager = new BSFManager(); - + manager.declareBean("self", this, getClass()); + manager.declareBean("context", getContext, AntContext.class); + // execute the script BSFEngine engine = manager.loadScriptingEngine(language); + engine.exec(scriptName, 0, 0, script); for (Iterator i = attributes.keySet().iterator(); i.hasNext(); ) { String attributeName = (String)i.next(); @@ -131,6 +134,17 @@ public class ScriptBase extends AbstractTask implements DeferredTask { setter.setCharAt(0, Character.toUpperCase(setter.charAt(0))); engine.call(null, "set" + setter, new Object[]{value}); } + + Iterator i = nestedElementNames.iterator(); + Iterator j = nestedElements.iterator(); + while (i.hasNext()) { + String nestedName = (String)i.next(); + Object nestedElement = j.next(); + StringBuffer adder = new StringBuffer(nestedName); + adder.setCharAt(0, Character.toUpperCase(adder.charAt(0))); + engine.call(null, "add" + adder, new Object[]{nestedElement}); + } + engine.call(null, "execute", new Object[]{}); } catch (BSFException e) { Throwable t = e; diff --git a/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java b/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java index b35e571d5..8942e801b 100644 --- a/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java +++ b/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java @@ -95,7 +95,7 @@ public interface ComponentService { void addLibPath(String libraryId, URL libPath) throws ExecutionException; /** - * Experimental - define a new type + * Define a new type * * @param typeName the name by which this type will be referred * @param factory the library factory object to create the type