}
@Override
protected void processResponse(Exchange exchange, InputStream responseEntity,
SalesforceException exception, AsyncCallback callback) {
final XStream localXStream = xStream.get();
try {
// do we need to un-marshal a response
if (responseEntity != null) {
final Class<?> responseClass = exchange.getProperty(RESPONSE_CLASS, Class.class);
Object response;
if (responseClass != null) {
// its ok to call this multiple times, as xstream ignores duplicate calls
localXStream.processAnnotations(responseClass);
final String responseAlias = exchange.getProperty(RESPONSE_ALIAS, String.class);
if (responseAlias != null) {
// extremely dirty, need to flush entire cache if its holding on to an old alias!!!
final CachingMapper mapper = (CachingMapper) localXStream.getMapper();
try {
if (mapper.realClass(responseAlias) != responseClass) {
mapper.flushCache();
}
} catch (CannotResolveClassException ignore) {
}
localXStream.alias(responseAlias, responseClass);
}
response = responseClass.newInstance();
localXStream.fromXML(responseEntity, response);
} else {
// return the response as a stream, for getBlobField
response = responseEntity;
}
exchange.getOut().setBody(response);