Browse Source

avoid unnecessary work

master
Matt Benson 3 years ago
parent
commit
8f57984b1b
2 changed files with 39 additions and 36 deletions
  1. +8
    -7
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  2. +31
    -29
      src/main/org/apache/tools/ant/UnknownElement.java

+ 8
- 7
src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -488,14 +488,15 @@ public class RuntimeConfigurable implements Serializable {
return;
}

// Configure the object
Object target = (wrappedObject instanceof TypeAdapter)
? ((TypeAdapter) wrappedObject).getProxy() : wrappedObject;

IntrospectionHelper ih =
IntrospectionHelper.getHelper(p, target.getClass());
ComponentHelper componentHelper = ComponentHelper.getComponentHelper(p);
if (attributeMap != null) {
// Configure the object
Object target = (wrappedObject instanceof TypeAdapter)
? ((TypeAdapter) wrappedObject).getProxy() : wrappedObject;
IntrospectionHelper ih =
IntrospectionHelper.getHelper(p, target.getClass());
ComponentHelper componentHelper = ComponentHelper.getComponentHelper(p);

for (Map.Entry<String, Object> entry : attributeMap.entrySet()) {
String name = entry.getKey();
// skip restricted attributes such as if:set


+ 31
- 29
src/main/org/apache/tools/ant/UnknownElement.java View File

@@ -339,6 +339,10 @@ public class UnknownElement extends Task {
Object parent,
RuntimeConfigurable parentWrapper)
throws BuildException {

if (children == null || children.isEmpty()) {
return;
}
if (parent instanceof TypeAdapter) {
parent = ((TypeAdapter) parent).getProxy();
}
@@ -347,38 +351,36 @@ public class UnknownElement extends Task {
Class<?> parentClass = parent.getClass();
IntrospectionHelper ih = IntrospectionHelper.getHelper(getProject(), parentClass);

if (children != null) {
Iterator<UnknownElement> it = children.iterator();
for (int i = 0; it.hasNext(); i++) {
RuntimeConfigurable childWrapper = parentWrapper.getChild(i);
UnknownElement child = it.next();
try {
if (!childWrapper.isEnabled(child)) {
if (ih.supportsNestedElement(
parentUri, ProjectHelper.genComponentName(
child.getNamespace(), child.getTag()))) {
continue;
}
// fall tru and fail in handlechild (unsupported element)
Iterator<UnknownElement> it = children.iterator();
for (int i = 0; it.hasNext(); i++) {
RuntimeConfigurable childWrapper = parentWrapper.getChild(i);
UnknownElement child = it.next();
try {
if (!childWrapper.isEnabled(child)) {
if (ih.supportsNestedElement(
parentUri, ProjectHelper.genComponentName(
child.getNamespace(), child.getTag()))) {
continue;
}
if (!handleChild(
parentUri, ih, parent, child, childWrapper)) {
if (!(parent instanceof TaskContainer)) {
ih.throwNotSupported(getProject(), parent,
child.getTag());
} else {
// a task container - anything could happen - just add the
// child to the container
TaskContainer container = (TaskContainer) parent;
container.addTask(child);
}
// fall thru and fail in handlechild (unsupported element)
}
if (!handleChild(
parentUri, ih, parent, child, childWrapper)) {
if (!(parent instanceof TaskContainer)) {
ih.throwNotSupported(getProject(), parent,
child.getTag());
} else {
// a task container - anything could happen - just add the
// child to the container
TaskContainer container = (TaskContainer) parent;
container.addTask(child);
}
} catch (UnsupportedElementException ex) {
throw new BuildException(
parentWrapper.getElementTag()
+ " doesn't support the nested \"" + ex.getElement()
+ "\" element.", ex);
}
} catch (UnsupportedElementException ex) {
throw new BuildException(
parentWrapper.getElementTag()
+ " doesn't support the nested \"" + ex.getElement()
+ "\" element.", ex);
}
}
}


Loading…
Cancel
Save