// check for situation where the operation comes from a customization-class
// annotation
final Object instance = resolveAsExpression(bindingContext, bindings, operationInfo.getInstanceName());
if (instance instanceof XMLDCElement) {
XMLDCElement xmldce = (XMLDCElement) instance;
if (xmldce.hasMethod(methodName, action.getParamsMap())) {
// TODO: logging
logger.fine("invoking @Operation method {0} on {1}, new Object[]{methodName, instance}");
Object result = xmldce.invokeMethod(methodName, action.getParamsMap());
logger.fine("returning {0}", result);
processResult(result, bindingContext, action);
return true; // true to indicate we handled the operation
}
}
// see if invoked method is any one of ours
DataControlDefinitionNode invokedDef = null;
for (DataControlDefinitionNode defNode : getDCDefinition().getDefinitionNodes()) {
if (defNode.getDatacontrolOperation().equals(methodName)) {
logger.fine("dataControl {0} is handling the {0} datacontrol operation", new Object[] {
mName, methodName });
invokedDef = defNode;
break;
}
}
if (invokedDef == null) {
return false; // false means we did not handle this call
}
// determine StructureDefinition we should return
final String beanClassName =
getDCDefinition().getReturnStructName(getDCDefinition().getStructure(), invokedDef);
final StructureDefinition structDef = getDCDefinition().findStructure(beanClassName);
if (structDef == null) {
throw new IllegalStateException("StructureDefinition " + beanClassName +
" not found in the DataControl Definition: " + getDCDefinition().getName());
}
// build DataRequest (clone dynamicParams so we don't alter the ones from binding layer)
Map<String, Object> mutableParamValues =
new LinkedHashMap<String, Object>((Map<String, Object>) action.getParamsMap());
DataRequest dataRequest = new DataRequestImpl(structDef, mutableParamValues, invokedDef);
// get root XML element from dataProvider
final DataProvider dataProvider = invokedDef.getProviderInstance(DataProvider.class);
Element element = dataProvider.getRootElement(dataRequest);
if (logger.isFine() && !(dataProvider instanceof WSDataProvider)) {
// TODO: look at root data-provider not most outer provider(filter)
// TODO: shouldn't each filter log the element at finest so we can see work of each filter
// WSDataProvider takes care of its own logging
logger.fine("data-provider {0} returned XML:\n{1}", new Object[] {
dataProvider.getClass().getName(), Utils.xmlNodeToString(Utils.toXMLNode(element)) });
}
// create XMLDCElement from XML element
if (element == null) {
// returning null would cause refresh issues once parameters change and the DC no
// longer returns null
element = new EmptyElementProvider().getRootElement(dataRequest);
}
final XMLDCElement xmldce = new XMLDCElement(this, structDef, element);
// write XMLDCElement result to the binding layer
processResult(xmldce, map, action);
return true; // true means we handled this call