peholmst/vaadin4spring

Question related to @EnableEventBus

Opened this issue · 2 comments

I am using 2.0.0.RELEASE.

I have seen that you did not use @EnableEventBus at your eventbus-sample.

instead you used:
@Autowired
EventBus.ApplicationEventBus applicationEventBus;

/**

  • Forward {@link org.springframework.context.ApplicationEvent}s to the {@link org.vaadin.spring.events.EventBus.ApplicationEventBus}.
    */
    @bean
    ApplicationContextEventBroker applicationContextEventBroker() {
    return new ApplicationContextEventBroker(applicationEventBus);
    }

Is that the preferred way?

Also, I could not make @EventBusListenerMethod annotation make work.

When I mark my methods with that annotation (for example @EventBusListenerMethod(scope = EventScope.UI, filter = LoginEventFilter.class) ), even if event published successfully, method is never invoked.

if it is possible, can you give an example.

Looks like EventBusListenerMethodFilter filter method is changed. When I change my Filters as below example, @EventBusListenerMethod annotated methods called fine.

import org.vaadin.spring.events.Event;
import org.vaadin.spring.events.EventBusListenerMethodFilter;

public class BrowserResizeEventFilter implements EventBusListenerMethodFilter {
  @Override
  public boolean filter(Event<?> event) {

    if (BrowserResizeEvent.class.isAssignableFrom(event.getPayload().getClass()))
      return true;
    else
      return false;
  }
}

So, looks like everything works fine. I appreciate if you still explain @EnableEventBus annotation and where/when to use it.