@@ -1,5 +1,5 @@
/*
/*
* Copyright 2000-2004 The Apache Software Foundation
* Copyright 2000-2005 The Apache Software Foundation
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
@@ -89,11 +89,10 @@ public class RuntimeConfigurable implements Serializable {
*
*
* @param proxy The element to configure. Must not be <code>null</code>.
* @param proxy The element to configure. Must not be <code>null</code>.
* @param elementTag The tag name generating this element.
* @param elementTag The tag name generating this element.
* Should not be <code>null</code>.
*/
*/
public RuntimeConfigurable(Object proxy, String elementTag) {
public RuntimeConfigurable(Object proxy, String elementTag) {
setProxy(proxy);
setProxy(proxy);
this.elementTag = elementTag ;
setElementTag(elementTag) ;
// Most likely an UnknownElement
// Most likely an UnknownElement
if (proxy instanceof Task) {
if (proxy instanceof Task) {
((Task) proxy).setRuntimeConfigurableWrapper(this);
((Task) proxy).setRuntimeConfigurableWrapper(this);
@@ -105,7 +104,7 @@ public class RuntimeConfigurable implements Serializable {
*
*
* @param proxy The element to configure. Must not be <code>null</code>.
* @param proxy The element to configure. Must not be <code>null</code>.
*/
*/
public void setProxy(Object proxy) {
public synchronized void setProxy(Object proxy) {
wrappedObject = proxy;
wrappedObject = proxy;
proxyConfigured = false;
proxyConfigured = false;
}
}
@@ -116,7 +115,7 @@ public class RuntimeConfigurable implements Serializable {
*
*
* @param creator the creator object.
* @param creator the creator object.
*/
*/
void setCreator(IntrospectionHelper.Creator creator) {
synchronized void setCreator(IntrospectionHelper.Creator creator) {
this.creator = creator;
this.creator = creator;
}
}
@@ -126,7 +125,7 @@ public class RuntimeConfigurable implements Serializable {
*
*
* @return the object whose configure is held by this instance.
* @return the object whose configure is held by this instance.
*/
*/
public Object getProxy() {
public synchronized Object getProxy() {
return wrappedObject;
return wrappedObject;
}
}
@@ -134,7 +133,7 @@ public class RuntimeConfigurable implements Serializable {
* Get the polymorphic type for this element.
* Get the polymorphic type for this element.
* @return the ant component type name, null if not set.
* @return the ant component type name, null if not set.
*/
*/
public String getPolyType() {
public synchronized String getPolyType() {
return polyType;
return polyType;
}
}
@@ -142,7 +141,7 @@ public class RuntimeConfigurable implements Serializable {
* Set the polymorphic type for this element.
* Set the polymorphic type for this element.
* @param polyType the ant component type name, null if not set.
* @param polyType the ant component type name, null if not set.
*/
*/
public void setPolyType(String polyType) {
public synchronized void setPolyType(String polyType) {
this.polyType = polyType;
this.polyType = polyType;
}
}
@@ -153,7 +152,7 @@ public class RuntimeConfigurable implements Serializable {
* @param attributes List of attributes defined in the XML for this
* @param attributes List of attributes defined in the XML for this
* element. May be <code>null</code>.
* element. May be <code>null</code>.
*/
*/
public void setAttributes(AttributeList attributes) {
public synchronized void setAttributes(AttributeList attributes) {
this.attributes = new AttributeListImpl(attributes);
this.attributes = new AttributeListImpl(attributes);
for (int i = 0; i < attributes.getLength(); i++) {
for (int i = 0; i < attributes.getLength(); i++) {
setAttribute(attributes.getName(i), attributes.getValue(i));
setAttribute(attributes.getName(i), attributes.getValue(i));
@@ -166,7 +165,7 @@ public class RuntimeConfigurable implements Serializable {
* @param name the name of the attribute.
* @param name the name of the attribute.
* @param value the attribute's value.
* @param value the attribute's value.
*/
*/
public void setAttribute(String name, String value) {
public synchronized void setAttribute(String name, String value) {
if (name.equalsIgnoreCase(ProjectHelper.ANT_TYPE)) {
if (name.equalsIgnoreCase(ProjectHelper.ANT_TYPE)) {
this.polyType = value;
this.polyType = value;
} else {
} else {
@@ -179,13 +178,22 @@ public class RuntimeConfigurable implements Serializable {
}
}
}
}
/**
* Delete an attribute. Not for the faint of heart.
* @param name the name of the attribute to be removed.
*/
public synchronized void removeAttribute(String name) {
attributeNames.remove(name);
attributeMap.remove(name);
}
/**
/**
* Return the attribute map.
* Return the attribute map.
*
*
* @return Attribute name to attribute value map.
* @return Attribute name to attribute value map.
* @since Ant 1.6
* @since Ant 1.6
*/
*/
public Hashtable getAttributeMap() {
public synchronized Hashtable getAttributeMap() {
return (attributeMap == null)
return (attributeMap == null)
? EMPTY_HASHTABLE : new Hashtable(attributeMap);
? EMPTY_HASHTABLE : new Hashtable(attributeMap);
}
}
@@ -197,7 +205,7 @@ public class RuntimeConfigurable implements Serializable {
* @return An AttributeList representing the attributes defined in the
* @return An AttributeList representing the attributes defined in the
* XML for this element. May be <code>null</code>.
* XML for this element. May be <code>null</code>.
*/
*/
public AttributeList getAttributes() {
public synchronized AttributeList getAttributes() {
return attributes;
return attributes;
}
}
@@ -207,7 +215,7 @@ public class RuntimeConfigurable implements Serializable {
* @param child The child element wrapper to add to this one.
* @param child The child element wrapper to add to this one.
* Must not be <code>null</code>.
* Must not be <code>null</code>.
*/
*/
public void addChild(RuntimeConfigurable child) {
public synchronized void addChild(RuntimeConfigurable child) {
children = (children == null) ? new ArrayList() : children;
children = (children == null) ? new ArrayList() : children;
children.add(child);
children.add(child);
}
}
@@ -220,7 +228,7 @@ public class RuntimeConfigurable implements Serializable {
* @return The child wrapper at position <code>index</code> within the
* @return The child wrapper at position <code>index</code> within the
* list.
* list.
*/
*/
RuntimeConfigurable getChild(int index) {
synchronized RuntimeConfigurable getChild(int index) {
return (RuntimeConfigurable) children.get(index);
return (RuntimeConfigurable) children.get(index);
}
}
@@ -229,7 +237,7 @@ public class RuntimeConfigurable implements Serializable {
* @return an enumeration of the child wrappers.
* @return an enumeration of the child wrappers.
* @since Ant 1.6
* @since Ant 1.6
*/
*/
public Enumeration getChildren() {
public synchronized Enumeration getChildren() {
return (children == null) ? new CollectionUtils.EmptyEnumeration()
return (children == null) ? new CollectionUtils.EmptyEnumeration()
: Collections.enumeration(children);
: Collections.enumeration(children);
}
}
@@ -240,7 +248,10 @@ public class RuntimeConfigurable implements Serializable {
* @param data Text to add to the wrapped element.
* @param data Text to add to the wrapped element.
* Should not be <code>null</code>.
* Should not be <code>null</code>.
*/
*/
public void addText(String data) {
public synchronized void addText(String data) {
if (data.length() == 0) {
return;
}
characters = (characters == null)
characters = (characters == null)
? new StringBuffer(data) : characters.append(data);
? new StringBuffer(data) : characters.append(data);
}
}
@@ -254,14 +265,12 @@ public class RuntimeConfigurable implements Serializable {
* @param count The number of characters to read from the array.
* @param count The number of characters to read from the array.
*
*
*/
*/
public void addText(char[] buf, int start, int count) {
public synchronized void addText(char[] buf, int start, int count) {
if (count == 0) {
if (count == 0) {
return;
return;
}
}
if (characters == null) {
characters = new StringBuffer(count);
}
characters.append(buf, start, count);
characters = ((characters == null)
? new StringBuffer(count) : characters).append(buf, start, count);
}
}
/**
/**
@@ -272,12 +281,16 @@ public class RuntimeConfigurable implements Serializable {
* @return the text content of this element.
* @return the text content of this element.
* @since Ant 1.6
* @since Ant 1.6
*/
*/
public StringBuffer getText() {
if (characters != null) {
return characters;
} else {
return new StringBuffer(0);
}
public synchronized StringBuffer getText() {
return (characters == null) ? new StringBuffer(0) : characters;
}
/**
* Set the element tag.
* @param elementTag The tag name generating this element.
*/
public synchronized void setElementTag(String elementTag) {
this.elementTag = elementTag;
}
}
/**
/**
@@ -286,7 +299,7 @@ public class RuntimeConfigurable implements Serializable {
* @return The tag name of the wrapped element. This is unlikely
* @return The tag name of the wrapped element. This is unlikely
* to be <code>null</code>, but may be.
* to be <code>null</code>, but may be.
*/
*/
public String getElementTag() {
public synchronized String getElementTag() {
return elementTag;
return elementTag;
}
}
@@ -330,7 +343,7 @@ public class RuntimeConfigurable implements Serializable {
* to invalid attributes or children, or text being added to
* to invalid attributes or children, or text being added to
* an element which doesn't accept it.
* an element which doesn't accept it.
*/
*/
public void maybeConfigure(Project p, boolean configureChildren)
public synchronized void maybeConfigure(Project p, boolean configureChildren)
throws BuildException {
throws BuildException {
String id = null;
String id = null;
@@ -384,27 +397,28 @@ public class RuntimeConfigurable implements Serializable {
Enumeration e = getChildren();
Enumeration e = getChildren();
while (e.hasMoreElements()) {
while (e.hasMoreElements()) {
RuntimeConfigurable child = (RuntimeConfigurable) e.nextElement();
RuntimeConfigurable child = (RuntimeConfigurable) e.nextElement();
if (child.wrappedObject instanceof Task) {
Task childTask = (Task) child.wrappedObject;
childTask.setRuntimeConfigurableWrapper(child);
}
if ((child.creator != null) && configureChildren) {
child.maybeConfigure(p);
child.creator.store();
continue;
}
/*
* backwards compatibility - element names of nested
* elements have been all lower-case in Ant, except for
* tasks in TaskContainers.
*
* For TaskContainers, we simply skip configuration here.
*/
String tag = child.getElementTag().toLowerCase(Locale.US);
if (configureChildren && ih.supportsNestedElement(tag)) {
child.maybeConfigure(p);
ProjectHelper.storeChild(p, target, child.wrappedObject, tag);
synchronized (child) {
if (child.wrappedObject instanceof Task) {
Task childTask = (Task) child.wrappedObject;
childTask.setRuntimeConfigurableWrapper(child);
}
if ((child.creator != null) && configureChildren) {
child.maybeConfigure(p);
child.creator.store();
continue;
}
/*
* backwards compatibility - element names of nested
* elements have been all lower-case in Ant, except for
* tasks in TaskContainers.
*
* For TaskContainers, we simply skip configuration here.
*/
String tag = child.getElementTag().toLowerCase(Locale.US);
if (configureChildren && ih.supportsNestedElement(tag)) {
child.maybeConfigure(p);
ProjectHelper.storeChild(p, target, child.wrappedObject, tag);
}
}
}
}
}