JPAContainer Entity Provider as a WS


I need to implement some web project involving web app and WS development for my studies. Vaadin suits me a lot. In order to get deeper into things I am going to use JPA in the project and Vaadin JPAContainer. I have one question - it is said in the manual that Entity Provider might be exported as a WS using HTTP. Could you provide a really brief outline or a strategy of how it could be implemented?

Thanx in advance!

Disclaimer: I have not tried this.

The idea in the read-only case would be to simply provide a web service exposing the functionality of the interface EntityProvider. You can do this with any standard WS library, making sure anything that goes through can be properly serialized, but don’t forget security.

Your application can then either call the methods directly or create a JPAContainer using a proxy version of the EntityProvider interface. The proxy can be very thin (just forward the method calls over the WS) or do more like caching.

For mutable (read-write) providers, your web service needs to expose MutableEntityProvider as well as provide a notification mechanism from the provider to the containers using it so that they would be notified of each others’ changes. See how MutableLocalEntityProvider sends EntityProviderChangeEvents - you probably need a little more code in the proxy using some callback mechanism to make this works, with the related cleanup of callback registrations etc.

For more efficiency, you could also have a local caching “hub” entity provider per client VM and entity type. This would be the only EntityProvider there that connects to the remote WS, proxies method calls and listens to notifications from the remote provider, and forwards change events to all local interested parties.

Hi, Henri,

Thanks a lot for the rapid and so much helpful response, now I see the direction =) This seems to be a quite interesting thing to implement.

Thanx again.