git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271296 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -943,7 +943,7 @@ public class Frame { | |||||
| throw new ExecutionException("The given ant:refid value '" | throw new ExecutionException("The given ant:refid value '" | ||||
| + refId + "' is not defined", model.getLocation()); | + refId + "' is not defined", model.getLocation()); | ||||
| } | } | ||||
| } else { | |||||
| } else if (nestedType != null) { | |||||
| // We need to create an instance of the class expected by the nested | // We need to create an instance of the class expected by the nested | ||||
| // element's adder method if that is possible | // element's adder method if that is possible | ||||
| if (nestedType.isInterface()) { | if (nestedType.isInterface()) { | ||||
| @@ -954,6 +954,12 @@ public class Frame { | |||||
| } | } | ||||
| typeInstance = createTypeInstance(nestedType, factory, model, null); | 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 | // is the typeInstance compatible with the type expected | ||||
| @@ -120,9 +120,12 @@ public class ScriptBase extends AbstractTask implements DeferredTask { | |||||
| try { | try { | ||||
| BSFManager manager = new BSFManager(); | BSFManager manager = new BSFManager(); | ||||
| manager.declareBean("self", this, getClass()); | |||||
| manager.declareBean("context", getContext, AntContext.class); | |||||
| // execute the script | // execute the script | ||||
| BSFEngine engine = manager.loadScriptingEngine(language); | BSFEngine engine = manager.loadScriptingEngine(language); | ||||
| engine.exec(scriptName, 0, 0, script); | engine.exec(scriptName, 0, 0, script); | ||||
| for (Iterator i = attributes.keySet().iterator(); i.hasNext(); ) { | for (Iterator i = attributes.keySet().iterator(); i.hasNext(); ) { | ||||
| String attributeName = (String)i.next(); | String attributeName = (String)i.next(); | ||||
| @@ -131,6 +134,17 @@ public class ScriptBase extends AbstractTask implements DeferredTask { | |||||
| setter.setCharAt(0, Character.toUpperCase(setter.charAt(0))); | setter.setCharAt(0, Character.toUpperCase(setter.charAt(0))); | ||||
| engine.call(null, "set" + setter, new Object[]{value}); | 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[]{}); | engine.call(null, "execute", new Object[]{}); | ||||
| } catch (BSFException e) { | } catch (BSFException e) { | ||||
| Throwable t = e; | Throwable t = e; | ||||
| @@ -95,7 +95,7 @@ public interface ComponentService { | |||||
| void addLibPath(String libraryId, URL libPath) throws ExecutionException; | 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 typeName the name by which this type will be referred | ||||
| * @param factory the library factory object to create the type | * @param factory the library factory object to create the type | ||||