beautypg.com

IBM WebSphere Adapters User Manual

Page 176

background image

//Added for Faults

funcDesc.setName(operation.toLowerCase() + queryDataDesc.getBOName());

getLogUtils().trace(LogLevel.FINEST,

CLASSNAME, "getXMLListFunctions", "Setting input data description
to: " + queryDataDesc.getName().toString() + " for function: "
+ funcDesc.getName()); //$NON-NLS-1$

funcDesc.setInputDataDescription(queryDataDesc);
funcDesc.setOutputDataDescription(containerDataDesc);

JDEInteractionSpec iSpec = new JDEInteractionSpec();
WBISingleValuedPropertyImpl maxCount = (WBISingleValuedPropertyImpl)pg.getProperty(JDEESDProperties.MAXRECORDS);
if (maxCount.getValue() == null)

iSpec.setMaxRecords(((Integer) maxCount.getPropertyType().getDefaultValue()).intValue());

else

iSpec.setMaxRecords(((Integer) maxCount.getValue()).intValue());

WBISingleValuedPropertyImpl timeoutProp = (WBISingleValuedPropertyImpl)pg.getProperty(JDEESDProperties.ISPECTIMEOUT);
if (timeoutProp.getValue() != null && ((Integer) timeoutProp.getValue()).intValue()>0){

iSpec.setTimeout(((Integer) timeoutProp.getValue()).intValue());

}

iSpec.setFunctionName(operation);
funcDesc.setInteractionSpec(iSpec);
functionDescriptions.add(funcDesc);

}

...
}

private void addFaultsToXMLListDataDescriptionBasedOnOperationName(

WBIOutboundFunctionDescriptionImpl funcDesc, String operationName)
throws MetadataException {

// Define XSDs for faults supported by this adapter.
try {

// During implementation - add faults based on the operationName
// parameter. For ex an operation may have more than one fault.
// And so the below logic will have to be using conditions
// if(operationName.equals("CREATE")) {} then do this etc.

JDEXMLListFaultDataDescription fdesc1 = new JDEXMLListFaultDataDescription();
JDEXMLListFaultDataDescription fdesc2 = new JDEXMLListFaultDataDescription();

BusinessObjectDefinition bo = FaultBOUtil.createDuplicateRecordBO();
URI uri = new URI("./" + FaultBOUtil.DUPLICATE_RECORD_NAME //$NON-NLS-1$

+ EMDConstants.XSD);

fdesc1.put(FaultBOUtil.FAULT_TARGET_NS, uri, bo.serialize());
fdesc1.setGenericDataBindingClassName("com.ibm.j2ca.extension.emd.runtime.WBIFaultDataBindingImpl");
fdesc1.setFaultName(FaultBOUtil.DUPLICATE_RECORD_NAME);

bo = FaultBOUtil.createMatchesExceededLimitBO();
uri = new URI("./" + FaultBOUtil.MATCHES_EXCEEDED_LIMIT_NAME //$NON-NLS-1$

+ EMDConstants.XSD);

fdesc2.put(FaultBOUtil.FAULT_TARGET_NS, uri, bo.serialize());
fdesc2.setGenericDataBindingClassName("com.ibm.j2ca.extension.emd.runtime.WBIFaultDataBindingImpl");
fdesc2.setFaultName(FaultBOUtil.MATCHES_EXCEEDED_LIMIT_NAME);

FaultDataDescription desc[] = new FaultDataDescription[] { fdesc1,

fdesc2 };

funcDesc.setFaultSelectorClassname("com.ibm.j2ca.extension.emd.runtime.WBIFaultSelectorImpl");
funcDesc.setFaultDataDescriptions(desc);

} catch (Exception e) {

throw new MetadataException(

"Unable to create fault BO definitions " + e.getMessage(), e); //$NON-NLS-1$

}

}

The following example shows code for implementing FaultDataDescription in the
JDEXMLListFaultDataDescription class:

170

WebSphere Adapters: WebSphere Adapter Toolkit User Guide