List of usage examples for org.springframework.context ApplicationListener getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.mule.module.spring.events.MuleEventMulticaster.java
/** * Method is used to dispatch events to listeners registered with the * EventManager or dispatches events to Mule depending on the type and state of * the event received. If the event is not a Mule event it will be dispatched to * any listeners registered that are NOT MuleEventListeners. If the event is a * Mule event and there is no source event attached to it, it is assumed that the * event was dispatched by an object in the context using context.publishEvent() * and will be dispatched by Mule. If the event does have a source event attached * to it, it is assumed that the event was dispatched by Mule and will be * delivered to any listeners subscribed to the event. * * @param e the application event received by the context *//* w w w. ja va2 s . c o m*/ public void multicastEvent(ApplicationEvent e) { MuleApplicationEvent muleEvent = null; // if the context gets refreshed we need to reinitialise if (e instanceof ContextRefreshedEvent) { try { registerMulticasterComponent(); } catch (MuleException ex) { throw new MuleRuntimeException(SpringMessages.failedToReinitMule(), ex); } } else if (e instanceof ContextClosedEvent) { if (!muleContext.isDisposing() && !muleContext.isDisposed()) { muleContext.dispose(); } return; } else if (e instanceof MuleApplicationEvent) { muleEvent = (MuleApplicationEvent) e; // If there is no Mule event the event didn't originate from Mule // so its an outbound event if (muleEvent.getMuleEventContext() == null) { try { dispatchEvent(muleEvent); } catch (ApplicationEventException e1) { exceptionListener.exceptionThrown(e1); } return; } } for (Iterator iterator = listeners.iterator(); iterator.hasNext();) { ApplicationListener listener = (ApplicationListener) iterator.next(); if (muleEvent != null) { // As the asynchronous listener wraps the real listener we need // to check the type of the wrapped listener, but invoke the Async // listener if (listener instanceof AsynchronousEventListener) { AsynchronousEventListener asyncListener = (AsynchronousEventListener) listener; if (asyncListener.getListener() instanceof MuleSubscriptionEventListener) { if (isSubscriptionMatch(muleEvent.getEndpoint(), ((MuleSubscriptionEventListener) asyncListener.getListener()).getSubscriptions())) { asyncListener.onApplicationEvent(muleEvent); } } else if (asyncListener.getListener() instanceof MuleEventListener) { asyncListener.onApplicationEvent(muleEvent); } else if (!(asyncListener.getListener() instanceof MuleEventListener)) { asyncListener.onApplicationEvent(e); } // Synchronous MuleEvent listener Checks } else if (listener instanceof MuleSubscriptionEventListener) { if (isSubscriptionMatch(muleEvent.getEndpoint(), ((MuleSubscriptionEventListener) listener).getSubscriptions())) { listener.onApplicationEvent(muleEvent); } } else if (listener instanceof MuleEventListener) { listener.onApplicationEvent(muleEvent); } } else if (listener instanceof AsynchronousEventListener && !(((AsynchronousEventListener) listener).getListener() instanceof MuleEventListener)) { listener.onApplicationEvent(e); } else if (!(listener instanceof MuleEventListener)) { listener.onApplicationEvent(e); } else { // Finally only propagate the Application event if the // ApplicationEvent interface is explicitly implemented for (int i = 0; i < listener.getClass().getInterfaces().length; i++) { if (listener.getClass().getInterfaces()[i].equals(ApplicationListener.class)) { listener.onApplicationEvent(e); break; } } } } }