}
// If the component implements the MessageExchangeListener,
// the delivery can be made synchronously, so we don't need
// to bother with transactions
MessageExchangeListener listener = getExchangeListener();
if (listener != null) {
me.handleAccept();
if (LOG.isTraceEnabled()) {
LOG.trace("Received: " + me);
}
// Call input listeners
ExchangeListener[] l = (ExchangeListener[]) container.getListeners(ExchangeListener.class);
ExchangeEvent event = new ExchangeEvent(me, ExchangeEvent.EXCHANGE_ACCEPTED);
for (int i = 0; i < l.length; i++) {
try {
l[i].exchangeAccepted(event);
} catch (Exception e) {
LOG.warn("Error calling listener: " + e.getMessage(), e);
}
}
// Set the flag the the exchange was delivered using push mode
// This is important for transaction boundaries
me.setPushDeliver(true);
// Deliver the exchange
ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(component.getComponent().getClass().getClassLoader());
listener.onMessageExchange(me);
} finally {
Thread.currentThread().setContextClassLoader(old);
}
// TODO: handle delayed exchange notifications
return;