public ServiceAdapter getServiceAdapter(String messageType, String destinationId) throws ServiceException {
GraniteContext context = GraniteContext.getCurrentInstance();
log.debug(">> Finding serviceAdapter for messageType: %s and destinationId: %s", messageType, destinationId);
ServicesConfig servicesConfig = context.getServicesConfig();
Destination destination = servicesConfig.findDestinationById(messageType, destinationId);
if (destination == null) {
log.debug(">> No destination found: %s", destinationId);
return null;
}
Adapter adapter = destination.getAdapter();
String key = null;
if (adapter != null) {
log.debug(">> Found adapterRef: %s", adapter.getId());
key = AdapterFactory.class.getName() + '@' + destination.getId() + '.' + adapter.getId();
}
else
key = defaultAdapterClass.getName() + '@' + destination.getId();
return getServiceAdapter(adaptersCache, context, destination, key, adapter != null ? adapter.getId() : null);
}