Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding Play application in custom system

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?

like image 648
Łukasz Rżanek Avatar asked May 14 '12 01:05

Łukasz Rżanek


1 Answers

You can launch a Play server programmatically using the NettyServer class:
https://github.com/playframework/Play20/blob/2.0.4/framework/src/play/src/main/scala/play/core/server/NettyServer.scala

Like:

NettyServer.createServer(new File("/path/to/app"))
like image 200
James Ward Avatar answered Nov 24 '22 03:11

James Ward