I would like to embed a Play based application in my own system, similar to what I am capable to do with Jetty. To simplify – instead of running start script I would prefer to have a start() method.
To be a little bit more descriptive let’s assume that I have this scenario:
- I got a complex system based on my own code, which is responsible for messaging, event processing, etc.
- Part of that system uses Morphia mappings (MongoDB ORM), which can be reused by Play application
- At this moment the application is started by Java Service Wrapper and runs as a daemon
- I would like to extend this system by adding Play app and it’s all dependencies to my own application and call some method to start the application with underlying protocol stack (Netty)
Is this scenario possible at all?
You can launch a Play server programmatically using the
NettyServerclass:https://github.com/playframework/Play20/blob/2.0.4/framework/src/play/src/main/scala/play/core/server/NettyServer.scala
Like: