conor 02/02/12 05:23:20
Modified: proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution
Frame.java
proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script
ScriptBase.java
proposal/mutant/src/java/common/org/apache/ant/common/service
ComponentService.java
Log:
Add in nested element processing for scriptdefs
Revision Changes Path
1.3 +7 -1
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
Index: Frame.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -u -r1.2 -r1.3
--- Frame.java 11 Feb 2002 15:42:18 -0000 1.2
+++ Frame.java 12 Feb 2002 13:23:20 -0000 1.3
@@ -943,7 +943,7 @@
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 @@
}
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
1.2 +15 -1
jakarta-ant/proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptBase.java
Index: ScriptBase.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -u -r1.1 -r1.2
--- ScriptBase.java 11 Feb 2002 15:42:18 -0000 1.1
+++ ScriptBase.java 12 Feb 2002 13:23:20 -0000 1.2
@@ -120,9 +120,12 @@
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 @@
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;
1.6 +1 -1
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java
Index: ComponentService.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -u -r1.5 -r1.6
--- ComponentService.java 11 Feb 2002 15:42:19 -0000 1.5
+++ ComponentService.java 12 Feb 2002 13:23:20 -0000 1.6
@@ -95,7 +95,7 @@
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
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>