if (!(actionObject instanceof Action)) {
throw new IllegalArgumentException(ERR_CUSTOM_ACTION_TYPE + className);
}
// Set the attribute values as properties
Action action = (Action) actionObject;
for (int i = 0; i < reader.getAttributeCount(); i++) {
String name = reader.getAttributeLocalName(i);
String value = reader.getAttributeValue(i);
String setter = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
Method method = null;
try {
method = clazz.getMethod(setter, String.class);
method.invoke(action, value);
} catch (NoSuchMethodException nsme) {
throw new XMLStreamException("No setter in class:" + className + ", for string property:" + name,
nsme);
} catch (InvocationTargetException ite) {
throw new XMLStreamException("Exception calling setter for string property:" + name + " in class:"
+ className, ite);
} catch (IllegalAccessException iae) {
throw new XMLStreamException("Cannot access setter for string property:" + name + " in class:"
+ className, iae);
}
}
// Add any body content if necessary
if (action instanceof ExternalContent) {
Node body = readNode(reader, configuration, customAction.getNamespaceURI(),
customAction.getLocalName(), new String [] {});
NodeList childNodes = body.getChildNodes();
List<Node> externalNodes = ((ExternalContent) action).getExternalNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
externalNodes.add(childNodes.item(i));
}
}
// Wire in the action and add to parent
readNamespaces(configuration, action);
action.setParent(executable);
if (parent != null) {
parent.addAction(action);
} else {
executable.addAction(action);
}