@@ -486,13 +486,30 @@ public final class IntrospectionHelper implements BuildListener {
public void setAttribute(Project p, Object element, String attributeName,
String value) throws BuildException {
AttributeSetter as
= (AttributeSetter) attributeSetters.get(attributeName);
= (AttributeSetter) attributeSetters.get(
attributeName.toLowerCase(Locale.US));
if (as == null) {
if (element instanceof DynamicConfigurator) {
if (element instanceof DynamicConfiguratorNS) {
DynamicConfiguratorNS dc = (DynamicConfiguratorNS) element;
String uriPlusPrefix =
ProjectHelper.extractUriFromComponentName(attributeName);
String uri =
ProjectHelper.extractUriFromComponentName(uriPlusPrefix);
String localName =
ProjectHelper.extractNameFromComponentName(attributeName);
String qName = ("".equals(uri)
? localName : (uri + ":" + localName));
dc.setDynamicAttribute(uri, localName, qName, value);
return;
} else if (element instanceof DynamicConfigurator) {
DynamicConfigurator dc = (DynamicConfigurator) element;
dc.setDynamicAttribute(attributeName, value);
dc.setDynamicAttribute(attributeName.toLowerCase(Locale.US) , value);
return;
} else {
if (attributeName.indexOf(':') != -1) {
return; // Ignore attribute from unknown uri's
}
String msg = getElementName(p, element)
+ " doesn't support the \"" + attributeName
+ "\" attribute.";
@@ -512,6 +529,7 @@ public final class IntrospectionHelper implements BuildListener {
throw new BuildException(t);
}
}
/**
* Adds PCDATA to an element, using the element's
@@ -574,7 +592,7 @@ public final class IntrospectionHelper implements BuildListener {
private NestedCreator getNestedCreator(
Project project, String parentUri, Object parent,
String elementName) throws BuildException {
String elementName, UnknownElement child ) throws BuildException {
String uri = ProjectHelper.extractUriFromComponentName(elementName);
String name = ProjectHelper.extractNameFromComponentName(elementName);
@@ -593,6 +611,35 @@ public final class IntrospectionHelper implements BuildListener {
if (nc == null) {
nc = createAddTypeCreator(project, parent, elementName);
}
if (nc == null && parent instanceof DynamicConfiguratorNS) {
DynamicConfiguratorNS dc = (DynamicConfiguratorNS) parent;
String qName = (child == null ? name : child.getQName());
final Object nestedElement =
dc.createDynamicElement(
(child == null ? "" : child.getNamespace()),
name, qName);
if (nestedElement != null) {
nc = new NestedCreator() {
public boolean isPolyMorphic() {
return false;
}
public Class getElementClass() {
return null;
}
public Object getRealObject() {
return null;
}
public Object create(
Project project, Object parent, Object ignore) {
return nestedElement;
}
public void store(Object parent, Object child) {
}
};
}
}
if (nc == null && parent instanceof DynamicConfigurator) {
DynamicConfigurator dc = (DynamicConfigurator) parent;
final Object nestedElement =
@@ -649,7 +696,7 @@ public final class IntrospectionHelper implements BuildListener {
*/
public Object createElement(Project project, Object parent,
String elementName) throws BuildException {
NestedCreator nc = getNestedCreator(project, "", parent, elementName);
NestedCreator nc = getNestedCreator(project, "", parent, elementName, null );
try {
Object nestedElement = nc.create(project, parent, null);
if (project != null) {
@@ -688,7 +735,7 @@ public final class IntrospectionHelper implements BuildListener {
Project project, String parentUri, Object parent, String elementName,
UnknownElement ue) {
NestedCreator nc = getNestedCreator(
project, parentUri, parent, elementName);
project, parentUri, parent, elementName, ue );
return new Creator(project, parent, nc);
}
@@ -703,6 +750,7 @@ public final class IntrospectionHelper implements BuildListener {
public boolean supportsNestedElement(String elementName) {
return nestedCreators.containsKey(elementName.toLowerCase(Locale.US))
|| DynamicConfigurator.class.isAssignableFrom(bean)
|| DynamicConfiguratorNS.class.isAssignableFrom(bean)
|| addTypeMethods.size() != 0;
}
@@ -729,6 +777,7 @@ public final class IntrospectionHelper implements BuildListener {
nestedCreators.containsKey(name.toLowerCase(Locale.US))
&& (uri.equals(parentUri))) // || uri.equals("")))
|| DynamicConfigurator.class.isAssignableFrom(bean)
|| DynamicConfiguratorNS.class.isAssignableFrom(bean)
|| addTypeMethods.size() != 0;
}