0

I have a Spring Boot project with Vaadin, I would like to integrate the Vaadin4Spring EventBus framework:

https://github.com/peholmst/vaadin4spring/tree/master/spring-vaadin-eventbus

The author says:

Please note, that the Event Bus API changed in version 0.0.5

However, if I add the Maven dependency inside my pom.xml:

    ...
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-vaadin-eventbus</artifactId>
        <version>LATEST</version>
    </dependency>
    ...

Maven downloads the 0.0.4.RELEASE version. I have tried to explicitly set the following versions:

    ...
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-vaadin-eventbus</artifactId>
        <version>0.0.5</version>
    </dependency>
    ...

    ...
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-vaadin-eventbus</artifactId>
        <version>0.0.5.RELEASE</version>
    </dependency>
    ...

    ...
    <dependency>
        <groupId>org.vaadin.spring</groupId>
        <artifactId>spring-vaadin-eventbus</artifactId>
        <version>0.0.5-SNAPSHOT</version>
    </dependency>
    ...

I also tried to set the entire Spring4Vaadin addon as a dependency:

<dependency>
  <groupId>org.vaadin.spring</groupId>
  <artifactId>spring-boot-vaadin</artifactId>
  <version>LATEST</version>
</dependency>
...


<dependency>
  <groupId>org.vaadin.spring</groupId>
  <artifactId>spring-boot-vaadin</artifactId>
  <version>0.0.5</version>
</dependency>
...

<dependency>
  <groupId>org.vaadin.spring</groupId>
  <artifactId>spring-boot-vaadin</artifactId>
  <version>0.0.5-SNAPSHOT</version>
</dependency>    
...

<dependency>
  <groupId>org.vaadin.spring</groupId>
  <artifactId>spring-boot-vaadin</artifactId>
  <version>0.0.5.RELEASE</version>
</dependency>

But neither of them worked.

Basically, I cannot do this:

 @Autowired
 EventBus.ApplicationEventBUs appEventBus;

 @Autowired
 EventBus.UIEventBus UIEventBus;
 ...

Because, as said in the README.md on GitHub:

Please note, that the Event Bus API changed in version 0.0.5. From now on, you have to declare which event bus to inject by using a specific interface (previously, everything was EventBus and you used an annotation to specify which bus to get). The reasons for this change were

So in the version 0.0.4.RELEASE (which Maven sees as LATEST), the inner interfaces ApplicationEventBus and UIEventBus are not defined.

So, how can I use the true latest version of the addon?

tonix
  • 6,671
  • 13
  • 75
  • 136
  • The [version 0.0.4.RELEASE](http://search.maven.org/#search|ga|1|spring-vaadin-eventbus) is the newest on Maven Central. – khmarbaise Feb 28 '15 at 20:57
  • @khmarbaise How can I use the inner interfaces then? Download the sources and compile? – tonix Feb 28 '15 at 21:01
  • 1
    It looks like this is the only possibility cause the maintainers haven't published yet a new version on Central...may be giving a issue hint in the project might speed up the process.. – khmarbaise Mar 01 '15 at 13:41
  • Yeah, I did like you are saying, now version `0.0.5-SNAPSHOT` is the one to go with. – tonix Mar 01 '15 at 17:49

1 Answers1

0

Putting the answer I put in the vaadin forums, over here as well:

Vaadin addons has a nice Event Bus implementation. Check https://github.com/peholmst/vaadin4spring/tree/master/samples/eventbus-sample

I have done this using a spring enabled (NOT spring boot) Vaadin application, but it might work without Spring as well I guess, Short steps: 1. Add the following dependency

<dependency>
    <groupId>org.vaadin.spring.addons</groupId>
    <artifactId>vaadin-spring-addon-eventbus</artifactId>
    <version>0.0.7.RELEASE</version>
</dependency>
  1. Import EventBusConfiguration.class into your Spring configuration (may not be required if Spring Boot is used with @EnableAutoConfiguration)

  2. Wire in appropriate event bus (check doumentations for different types available), here I am using one that works per UI instance:

    
    @Autowired
    private EventBus.UIEventBus uiEventBus;
    
  3. Publish event as required, eg:

    
    uiEventBus.publish(this, new RefreshMainViewEvent(this, "Usage details updated"));
     
  4. Subscribe to event in the other component class

    
    @PostConstruct
    public void afterPropertiesSet() {
    uiEventBus.subscribe(this, false); }
  5. Add the action to be done on event (in the same class here) :

    
    @EventBusListenerMethod
    public void closeSymmUsageWindow(RefreshMainViewEvent event) {
        logger.debug("Received {}", event);
        //blah
    }
    
Deepak
  • 3,648
  • 1
  • 22
  • 17