I have a play application which I am in the process of building a application that will use play framework for the front end but will also have some “worker nodes” which play will communicate with over JMS queues.
These worker nodes are meant to be light weight and therefore won’t be running the full play framework.
I’d like to embed the same models in both the play framework app and the worker nodes to make it easy to pass the objects over JMS however to use ebean in play framework I need to have the object extend play.db.ebean.Model which won’t work in the worker nodes as they aren’t running on play.
What is the best way to do this?
The play.db.ebean.Model class of Play is just an helper which provides some usefull methods (save(), update(), delete()…). They just make calls to the Ebean static methods, for instance, the save() method implementation of the
play.db.ebean.Modelclass is:You can make your model objects without inheriting from it:
But if you want to do not depend on the Ebean class, you should write other classes (aka “service” or “DAO” layer in the Java EE world) with containing your static methods:
Then, you have to package your model objects into a JAR, and add this dependency in Play and in your JMS system. But in your JMS system, don’t forget to add a depency to the JPA annotation that are imported in your model objects.