How to send messages from a service class using MessageManager?

I want to send a message from my CreateProjectService. That way, any time a new project is created from anywhere, the projects Grid will get refreshed.

Unfortunately, CollaborationEngine is not automatically available as a Spring Bean and I can’t create one because, “‘CollaborationEngine()’ is not public in ‘com. vaadin. collaborationengine. CollaborationEngine’. Cannot be accessed from outside package”

The docs around System Connection Context make it seem like this is possible, but I don’t understand how.

Are there any demos out there I can read?

One solution is to make you CreateProjectService implement VaadinServiceInitListener (assuming the service is exposed as Spring bean) and get CollaborationEngine instance in the serviceInit() method.

    @Component
    private static class MyService implements VaadinServiceInitListener {

        @Override
        public void serviceInit(ServiceInitEvent event) {
            CollaborationEngine ce = CollaborationEngine.getInstance(event.getSource());
            SystemConnectionContext systemContext = ce.getSystemContext();
        }
    }
2 Likes