public void afterPropertiesSet() { MessageBus messageBus = getMessageBus(); for (DestinationEventListener destinationEventListener : _globalDestinationEventListeners) { messageBus.addDestinationEventListener(destinationEventListener); } for (Destination destination : _destinations) { messageBus.addDestination(destination); } for (Map.Entry<String, List<DestinationEventListener>> destinationEventListeners : _specificDestinationEventListeners.entrySet()) { String destinationName = destinationEventListeners.getKey(); for (DestinationEventListener destinationEventListener : destinationEventListeners.getValue()) { messageBus.addDestinationEventListener(destinationName, destinationEventListener); } } for (Destination destination : _replacementDestinations) { messageBus.replace(destination); } Thread currentThread = Thread.currentThread(); ClassLoader contextClassLoader = currentThread.getContextClassLoader(); try { ClassLoader operatingClassLoader = getOperatingClassloader(); currentThread.setContextClassLoader(operatingClassLoader); for (Map.Entry<String, List<MessageListener>> messageListeners : _messageListeners.entrySet()) { String destinationName = messageListeners.getKey(); for (MessageListener messageListener : messageListeners.getValue()) { messageBus.registerMessageListener(destinationName, messageListener); } } } finally { currentThread.setContextClassLoader(contextClassLoader); } }