To implement the Web services mapper, a technical developermust
extend the
com.ibm.btt.base.ws.WSMapperConverter class
and override the following two methods:
- public Object mapContextToObject(Context ctx)
- public void mapObjectToContext(Object obj, Context ctx)
The
public Object mapContextToObject(Context ctx) method
transforms the data from an object to a
WebSphere® Multichannel Bank Transformation
Toolkit context
for an inbound message. Because the WSMapperConverter already handles
the default data type objects in this method, the extension just needs
to take care of new data type objects. The following is a sample code
to convert the
XMLGregorianCalendar type object to
data in context.
public Object mapContextToObject(Context ctx)
throws DSEInvalidRequestException, DSEInvalidArgumentException,
DSEInvalidClassException {
String javaClazz = getJavaClass();
Object o = null;
String from = (String)getFrom().getValue();
if (!isPrimitive() && javaClazz != null) {
if (XMLGregorianCalendar.class.getName().equals(javaClazz)) {
//extend conversion
o = mapCtxtoCalendar(ctx,from);
} else {// use default BTT conversion
return super.mapContextToObject(ctx);
}
}
return o;
}
The
public void mapObjectToContext(Object obj, Context
ctx) method transforms the data from a
WebSphere Multichannel Bank Transformation
Toolkit context
to an object for an outbound message. The following is a sample code
to convert data in a context to
XMLGregorianCalendar type
object.
public void mapObjectToContext(Object obj, Context ctx)
throws DSEInvalidRequestException, DSEInvalidArgumentException,
DSEInvalidClassException {
String javaClazz = getJavaClass();
if (!isPrimitive() && javaClazz != null) {// non-primitive
if (XMLGregorianCalendar.class.getName().equals(javaClazz)) {
//extend conversion
mapCalendarToContext(obj,ctx);
} else {// use default BTT conversion
super.mapObjectToContext(obj, ctx);
}
}
}