How to decouple vaadin frontend and java backend?


I’m evaluating vaadin/vaadin-with-spring as a framework for our new user administration. We have a backend written in java and running already on an application server.

Ideally we’d like to undeploy/redeploy the frontend more often than the backend, thus it will not be placed in the same war file than the backend. Anyhow we’d like to minimize the code that has to be written for plain data transfer between the backend and vaadin frontend. Both applications may run on the same machine.

Question: how could we achieve this best? SOAP, REST, JSON, what else? Could you give a recommendation?

Thanks a lot,

I assume when you say ‘frontend’ then this is Vaadin code, also running server-side.

Since it may only run on the same machine (NOT: must), you have already stated the need for inter-process communication without shared memory on one (Java Virtual) machine.

As REST is usually used for ‘calling methods’, often with C-R-U-D semantics, this does not seem to be the perfect match for plain data transfer. And you would need to find a data encapsulation (say, XML or JSON) anyway.

SOAP then is yet another standardized way for remote procedure calls. Data encapsulation is usually XML, but why use SOAP when you can use plain XML? XML tends to become a little large and unreadable though.

My recommendation would therefore be using plain JSON (not: JSON-RPC), and to use a library compatible with JSR 353 to encode and decode the data.

M, it sounds like the project I am working on right now has a similar setup as what you are after. The only difference is that we are not using Spring, but instead our backend is built on JavaEE stuff like EJBs and CDI. But I believe the concept would still work for you. We currently have a Vaadin frontend that gets deployed in a war file called “vaddin-web.war”. Our backend is in a war file called “services.war” that gets deployed to the same application server (Jboss in this case) as the vaadin-web.war file. In this setup, you don’t need to us SOAP or REST, because you can inject your spring services/beans into your vaadin front end. You might need some bridge code, so that your spring beans in your services.war is made available to inject into your vaadin front end war.

Anyway, hope this gives you some ideas.

Thank you both for your insight.

@Daniel Nelson: could you give an example how I could inject services from the backend into the frontend if both are deployed in separate war files (ie are probably different projects)? My setup is exactly like yours.

M, I don’t have much Spring experience so I couldn’t quickly give you any type of working example. I did a search and I think something described at this
could get you started in exploring your options.