org.vaadin.spring.events.EventBus Java Examples
The following examples show how to use
org.vaadin.spring.events.EventBus.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScopedEventBus.java From vaadin4spring with Apache License 2.0 | 6 votes |
/** * @param scope the scope of the events that this event bus handles. * @param parentEventBus the parent event bus to use, may be {@code null}; */ public ScopedEventBus(EventScope scope, EventBus parentEventBus) { eventScope = scope; this.parentEventBus = parentEventBus; if (parentEventBus != null) { if (AopUtils.isJdkDynamicProxy(parentEventBus)) { logger.debug("Parent event bus [{}] is proxied, trying to get the real EventBus instance", parentEventBus); try { this.parentEventBus = (EventBus) ((Advised) parentEventBus).getTargetSource().getTarget(); } catch (Exception e) { logger.error("Could not get target EventBus from proxy", e); throw new RuntimeException("Could not get parent event bus", e); } } logger.debug("Using parent event bus [{}]", this.parentEventBus); this.parentEventBus.subscribe(parentListener); } }
Example #2
Source File: VaadinEventBusAwareProcessor.java From vaadin4spring with Apache License 2.0 | 5 votes |
private void invokeAwareInterfaces(Object bean) { if (bean instanceof EventBusAware) { if (bean instanceof EventBusAware.ApplicationEventBusAware) { ((EventBusAware.ApplicationEventBusAware) bean).setApplicationEventBus(this.applicationContext.getBean(EventBus.ApplicationEventBus.class)); } if (bean instanceof EventBusAware.SessionEventBusAware) { ((EventBusAware.SessionEventBusAware) bean).setSessionEventBus(this.applicationContext.getBean(EventBus.SessionEventBus.class)); } if (bean instanceof EventBusAware.UIEventBusAware) { ((EventBusAware.UIEventBusAware) bean).setUIEventBus(this.applicationContext.getBean(EventBus.UIEventBus.class)); } } }
Example #3
Source File: ScopedEventBusIntegrationTest.java From vaadin4spring with Apache License 2.0 | 5 votes |
@Test void testDifferentUIReturnsDifferentUIEventBus() { EventBus.UIEventBus uiBus = applicationContext.getBean(EventBus.UIEventBus.class); UI.setCurrent(createMockUI()); EventBus.UIEventBus uiBus2 = applicationContext.getBean(EventBus.UIEventBus.class); assertNotEquals(uiBus, uiBus2, "Different UIs should return different UIEventBuses"); }
Example #4
Source File: ScopedEventBusIntegrationTest.java From vaadin4spring with Apache License 2.0 | 5 votes |
@Test void testSameSessionDifferentUIReturnsSameSessionEventBus() { EventBus.SessionEventBus sessionBus = applicationContext.getBean(EventBus.SessionEventBus.class); UI.setCurrent(createMockUI()); EventBus.SessionEventBus sessionBus2 = applicationContext.getBean(EventBus.SessionEventBus.class); assertEquals(sessionBus, sessionBus2, "Same session different UIs should return same SessionEventBus"); }
Example #5
Source File: ScopedEventBusIntegrationTest.java From vaadin4spring with Apache License 2.0 | 5 votes |
@Test void testDifferentSessionsReturnDifferentSessionEventBuses() { EventBus.SessionEventBus sessionBus = applicationContext.getBean(EventBus.SessionEventBus.class); VaadinSession.setCurrent(new TestSession()); EventBus.SessionEventBus sessionBus2 = applicationContext.getBean(EventBus.SessionEventBus.class); assertNotEquals(sessionBus, sessionBus2, "Different sessions should return different SessionEventBuses"); }
Example #6
Source File: ScopedEventBusIntegrationTest.java From vaadin4spring with Apache License 2.0 | 5 votes |
@Test void sameApplicationDifferentUIReturnsSameApplicationEventBus() { EventBus.ApplicationEventBus applicationBus = applicationContext.getBean(EventBus.ApplicationEventBus.class); UI.setCurrent(createMockUI()); EventBus.ApplicationEventBus applicationBus2 = applicationContext.getBean(EventBus.ApplicationEventBus.class); assertEquals(applicationBus, applicationBus2, "ApplicationEventBus should always be the same"); }
Example #7
Source File: ScopedEventBusIntegrationTest.java From vaadin4spring with Apache License 2.0 | 5 votes |
@Test void sameApplicationDifferentSessionReturnsSameApplicationEventBus() { EventBus.ApplicationEventBus applicationBus = applicationContext.getBean(EventBus.ApplicationEventBus.class); VaadinSession.setCurrent(new TestSession()); EventBus.ApplicationEventBus applicationBus2 = applicationContext.getBean(EventBus.ApplicationEventBus.class); assertEquals(applicationBus, applicationBus2, "ApplicationEventBus should always be the same"); }
Example #8
Source File: ApplicationContextEventBrokerTest.java From vaadin4spring with Apache License 2.0 | 5 votes |
@Test public void testOnApplicationEvent() { ApplicationEvent event = new ApplicationEvent(this) { private static final long serialVersionUID = 7475015652750718692L; @Override public Object getSource() { return "mySource"; } }; EventBus eventBus = mock(EventBus.class); new ApplicationContextEventBroker(eventBus).onApplicationEvent(event); verify(eventBus).publish("mySource", event); }
Example #9
Source File: SpringSecurityErrorHandler.java From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 | 5 votes |
public static void doDefault(ErrorEvent event) { Throwable t = event.getThrowable(); if (t instanceof SocketException) { // Most likely client browser closed socket getLogger().info( "SocketException in CommunicationManager." + " Most likely client (browser) closed socket."); return; } t = findRelevantThrowable(t); /* * Handle SpringSecurity */ if (t instanceof AccessDeniedException) { EventBus eventBus = SpringApplicationContext.getEventBus(); eventBus.publish(EventScope.UI, eventBus, new AccessDeniedEvent(t)); getLogger().log(Level.FINE, "Access is denied", t); return; } // Finds the original source of the error/exception AbstractComponent component = findAbstractComponent(event); if (component != null) { // Shows the error in AbstractComponent ErrorMessage errorMessage = AbstractErrorMessage .getErrorMessageForException(t); component.setComponentError(errorMessage); } // also print the error on console getLogger().log(Level.SEVERE, "", t); }
Example #10
Source File: SecuredNavigator.java From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 | 5 votes |
public SecuredNavigator(UI ui, ViewDisplay display, SpringViewProvider viewProvider, Security security, EventBus eventBus) { super(ui, display); this.security = security; this.viewProvider = viewProvider; this.eventBus = eventBus; addProvider(this.viewProvider); }
Example #11
Source File: AbstractNotificationView.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
/** * Constructor. * * @param eventBus * the ui event bus * @param notificationUnreadButton * the notificationUnreadButton */ public AbstractNotificationView(final EventBus.UIEventBus eventBus, final NotificationUnreadButton notificationUnreadButton) { this.eventBus = eventBus; this.notificationUnreadButton = notificationUnreadButton; this.viewUnreadNotifcations = new AtomicInteger(0); skipUiEventsCache = CacheBuilder.newBuilder().expireAfterAccess(10, SECONDS).build(); if (doSubscribeToEventBus()) { eventBus.subscribe(this); } }
Example #12
Source File: AbstractFileTransferHandler.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
AbstractFileTransferHandler(final ArtifactManagement artifactManagement, final VaadinMessageSource i18n, final Lock uploadLock) { this.artifactManagement = artifactManagement; this.i18n = i18n; this.eventBus = SpringContextHelper.getBean(EventBus.UIEventBus.class); this.artifactUploadState = SpringContextHelper.getBean(ArtifactUploadState.class); this.uiNotification = SpringContextHelper.getBean(UINotification.class); this.uploadLock = uploadLock; }
Example #13
Source File: SpringApplicationContext.java From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 | 4 votes |
public static EventBus getEventBus() { return ctx.getBean(EventBus.class); }
Example #14
Source File: SignUpPresenter.java From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 | 4 votes |
@Autowired public SignUpPresenter(SignUpView view, EventBus eventBus) { super(view, eventBus); getView().setPresenterHandlers(this); }
Example #15
Source File: HiddenAdminPresenter.java From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 | 4 votes |
@Autowired public HiddenAdminPresenter(HiddenAdminView view, EventBus eventBus) { super(view, eventBus); }
Example #16
Source File: AdminPresenter.java From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 | 4 votes |
@Autowired public AdminPresenter(AdminView view, EventBus eventBus) { super(view, eventBus); }
Example #17
Source File: HomePresenter.java From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 | 4 votes |
@Autowired public HomePresenter(HomeView view, EventBus eventBus) { super(view, eventBus); getView().setPresenterHandlers(this); }
Example #18
Source File: UserPresenter.java From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 | 4 votes |
@Autowired public UserPresenter(UserView view, EventBus eventBus) { super(view, eventBus); getView().setPresenterHandlers(this); }
Example #19
Source File: ScopedEventBusIntegrationTest.java From vaadin4spring with Apache License 2.0 | 4 votes |
@Test void sameApplicationReturnsSameApplicationEventBus() { EventBus.ApplicationEventBus applicationBus = applicationContext.getBean(EventBus.ApplicationEventBus.class); EventBus.ApplicationEventBus applicationBus2 = applicationContext.getBean(EventBus.ApplicationEventBus.class); assertEquals(applicationBus, applicationBus2, "ApplicationEventBus should always be the same"); }
Example #20
Source File: SignInPresenter.java From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 | 4 votes |
@Autowired public SignInPresenter(SignInView view, EventBus eventBus) { super(view, eventBus); getView().setPresenterHandlers(this); }
Example #21
Source File: AbstractTagLayout.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
protected EventBus.UIEventBus getEventBus() { return eventBus; }
Example #22
Source File: ScopedEventBusIntegrationTest.java From vaadin4spring with Apache License 2.0 | 4 votes |
@Test void testSameSessionReturnsSameSessionEventBus() { EventBus.SessionEventBus sessionBus = applicationContext.getBean(EventBus.SessionEventBus.class); EventBus.SessionEventBus sessionBus2 = applicationContext.getBean(EventBus.SessionEventBus.class); assertEquals(sessionBus, sessionBus2, "Same session should return same SessionEventBus"); }
Example #23
Source File: ScopedEventBusIntegrationTest.java From vaadin4spring with Apache License 2.0 | 4 votes |
@Test void testNoUIThrowsBeanCreationException() { UI.setCurrent(null); assertThrows(BeanCreationException.class, () -> applicationContext.getBean(EventBus.UIEventBus.class)); }
Example #24
Source File: EventBusListenerWrapper.java From vaadin4spring with Apache License 2.0 | 4 votes |
EventBusListenerWrapper(EventBus owningEventBus, EventBusListener<?> listenerTarget, String topic, boolean includingPropagatingEvents) { super(owningEventBus, listenerTarget, topic, includingPropagatingEvents); payloadType = GenericTypeResolver.resolveTypeArgument(listenerTarget.getClass(), EventBusListener.class); Assert.notNull(payloadType, "Could not resolve payload type"); }
Example #25
Source File: TargetBulkUpdateWindowLayout.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
/** * @return the eventBus */ public EventBus.UIEventBus getEventBus() { return eventBus; }
Example #26
Source File: AbstractFilterButtons.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
protected EventBus.UIEventBus getEventBus() { return eventBus; }
Example #27
Source File: AbstractFilterHeader.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
protected EventBus.UIEventBus getEventBus() { return eventBus; }
Example #28
Source File: AbstractGridComponentLayout.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
protected EventBus.UIEventBus getEventBus() { return eventBus; }
Example #29
Source File: AbstractTable.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
protected EventBus.UIEventBus getEventBus() { return eventBus; }
Example #30
Source File: AbstractNotificationView.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
public EventBus.UIEventBus getEventBus() { return eventBus; }