Object context,
MessageInterceptor messageInterceptor) {
if (description == null) {
throw new LoggedRuntimeException("Cannot find Resource description. " +
"Invalid Resource !!", log);
}
if (value == null) {
return false;
}
if (propertyOutputAdapter.adaptOutput(description, value, context, messageInterceptor)) {
return true;
}
Object targetNode = ResourceDescriptionEvaluator.evaluateExpression(description,
context,
messageInterceptor);
if (targetNode == null) {
ReturnValue returnValue = messageInterceptor.extractPayload(context);
targetNode = returnValue.getValue();
}
if (value instanceof OMElement) {
return false;
}
if (!(targetNode instanceof OMElement)) {
throw new LoggedRuntimeException("The target node should have been an OMNode", log);
}
OMElement targetOMNode = (OMElement) targetNode;
boolean baseType = ClassHelper.isWrapperType(value.getClass().getName());
// if the type is basic , then set it as a text
if (baseType) {
targetOMNode.setText(String.valueOf(value));
} else {
// If the custom object provide the string that represents it's
// internal data as a XML,then it will be used to replace the target node
String methodName = "toXML";
OMElement result = null;
Method method = null;
try {
method = value.getClass().getMethod(methodName);
} catch (NoSuchMethodException ignored) {
}
if (method != null) {
try {
Object xml = method.invoke(value);
if (xml instanceof String) {
result = OMElementHelper.getInstance().toOM((String) xml);
} else if (xml instanceof OMElement) {
result = (OMElement) xml;
}
} catch (InvocationTargetException e) {
throw new LoggedRuntimeException("Error invoking toXML() method " +
e.getMessage(),
e, log);
} catch (IllegalAccessException e) {
throw new LoggedRuntimeException("Error invoking toXML() method " +
e.getMessage(),
e, log);
}
} else {