protected Object getBodyAsString(Message in) {
if (in == null) {
return null;
}
StreamCache newBody = null;
try {
newBody = in.getBody(StreamCache.class);
if (newBody != null) {
in.setBody(newBody);
}
} catch (NoTypeConversionAvailableException ex) {
// ignore, in not of StreamCache type
}
Object answer = null;
try {
answer = in.getBody(String.class);
} catch (NoTypeConversionAvailableException ex) {
answer = in.getBody();
}
if (newBody != null) {
// Reset the InputStreamCache
newBody.reset();
}
return answer;
}