@Override public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) { return (this.delegateApplicationEvents && ((SmartApplicationListener) this.localRegistry).supportsEventType(eventType)); }
@Override @SuppressWarnings("unchecked") public boolean supportsEventType(ResolvableType eventType) { if (this.delegate instanceof SmartApplicationListener) { Class<? extends ApplicationEvent> eventClass = (Class<? extends ApplicationEvent>) eventType.resolve(); return (eventClass != null && ((SmartApplicationListener) this.delegate).supportsEventType(eventClass)); } else { return (this.declaredEventType == null || this.declaredEventType.isAssignableFrom(eventType)); } }
@Override @SuppressWarnings("unchecked") public boolean supportsEventType(ResolvableType eventType) { if (this.delegate instanceof SmartApplicationListener) { Class<? extends ApplicationEvent> eventClass = (Class<? extends ApplicationEvent>) eventType.resolve(); return (eventClass != null && ((SmartApplicationListener) this.delegate).supportsEventType(eventClass)); } else { return (this.declaredEventType == null || this.declaredEventType.isAssignableFrom(eventType)); } }
public void onApplicationEvent(ApplicationEvent event) { if (event == null) { return; } for (SmartApplicationListener listener : listeners) { Object source = event.getSource(); if (source != null && listener.supportsEventType(event.getClass()) && listener.supportsSourceType(source.getClass())) { listener.onApplicationEvent(event); } } }
public void onApplicationEvent(ApplicationEvent event) { if (event == null) { return; } for (SmartApplicationListener listener : listeners) { Object source = event.getSource(); if (source != null && listener.supportsEventType(event.getClass()) && listener.supportsSourceType(source.getClass())) { listener.onApplicationEvent(event); } } }
@Test public void supportsEventTypeWithSmartApplicationListener() { SmartApplicationListener smartListener = mock(SmartApplicationListener.class); GenericApplicationListenerAdapter listener = new GenericApplicationListenerAdapter(smartListener); ResolvableType type = ResolvableType.forClass(ApplicationEvent.class); listener.supportsEventType(type); verify(smartListener, times(1)).supportsEventType(ApplicationEvent.class); }
@Test public void processEventSourceTypeNotSupported() { when(delegate.supportsEventType(event.getClass())).thenReturn(true); listener.onApplicationEvent(event); verify(delegate, never()).onApplicationEvent(any(ApplicationEvent.class)); }
@Test public void processEventSuccess() { when(delegate.supportsEventType(event.getClass())).thenReturn(true); when(delegate.supportsSourceType(event.getSource().getClass())).thenReturn(true); listener.onApplicationEvent(event); verify(delegate).onApplicationEvent(event); }
@Override public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) { return (this.delegateApplicationEvents && ((SmartApplicationListener) this.localRegistry).supportsEventType(eventType)); }
@Override public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) { return (this.delegateApplicationEvents && ((SmartApplicationListener) this.localRegistry).supportsEventType(eventType)); }
@Override public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) { return (this.delegateApplicationEvents && ((SmartApplicationListener) this.localRegistry).supportsEventType(eventType)); }
public void onApplicationEvent(ApplicationEvent event) { if (event == null) { return; } for (SmartApplicationListener listener : listeners) { Object source = event.getSource(); if (source != null && listener.supportsEventType(event.getClass()) && listener.supportsSourceType(source.getClass())) { listener.onApplicationEvent(event); } } }
/** * Determine whether the given listener supports the given event. * <p> * The default implementation detects the {@link SmartApplicationListener} * interface. In case of a standard {@link ApplicationListener}, a * {@link GenericApplicationListenerAdapter} will be used to introspect the * generically declared type of the target listener. * * @param listener * the target listener to check * @param eventType * the event type to check against * @param sourceType * the source type to check against * @return whether the given listener should be included in the candidates * for the given event type */ protected boolean supportsEvent(ApplicationListener listener, Class<? extends ApplicationEvent> eventType, Class sourceType) { SmartApplicationListener smartListener = (listener instanceof SmartApplicationListener ? (SmartApplicationListener) listener : new GenericApplicationListenerAdapter(listener)); return (smartListener.supportsEventType(eventType) && smartListener.supportsSourceType(sourceType)); }
/** * Determine whether the given listener supports the given event. * <p> * The default implementation detects the {@link SmartApplicationListener} * interface. In case of a standard {@link ApplicationListener}, a * {@link GenericApplicationListenerAdapter} will be used to introspect the * generically declared type of the target listener. * * @param listener * the target listener to check * @param eventType * the event type to check against * @param sourceType * the source type to check against * @return whether the given listener should be included in the candidates * for the given event type */ protected boolean supportsEvent(ApplicationListener listener, Class<? extends ApplicationEvent> eventType, Class sourceType) { SmartApplicationListener smartListener = (listener instanceof SmartApplicationListener ? (SmartApplicationListener) listener : new GenericApplicationListenerAdapter(listener)); return (smartListener.supportsEventType(eventType) && smartListener.supportsSourceType(sourceType)); }