How does the Play Framework function?

前端 未结 3 749
无人及你
无人及你 2021-01-02 04:48

I love Play!. Compared to other enterprise Java frameworks, it\'s incredibly simple for the developer to use. But, how does it do that? What makes the edit-refresh cycle pos

相关标签:
3条回答
  • 2021-01-02 05:12

    Play uses the Eclipse compiler to compile code at run-time.

    Take a look at the following class, that is used by Play to perform the necessary compilation at run time.

    https://github.com/playframework/play/blob/master/framework/src/play/classloading/ApplicationCompiler.java

    0 讨论(0)
  • 2021-01-02 05:22

    I've compared Play(+Scala) to Lift+mvn scala:cc+JRebel. Play is much better experience. Now, I know the reason:

    Play is stateless. So, it can unload the Controller, forget all the fields and load+initialize it again. JRebel is aimed to be much more generic. It assumes that the state is important, so it sometimes (frequently?) fails, because it can't preserve the state in some cases.

    0 讨论(0)
  • 2021-01-02 05:27

    This is the marvelous magic of runtime compilation/classloaders and javassist...

    But don't forget that in prod environment, it's not like Groovy that basically recompiles your scripts into Java classes at runtime (unless you precompile your scripts naturally). In prod, Play! runs with real compiled classes so it's as efficient as classic java code. Moreover, it's not like Spring or other frameworks that uses lots of AOP with lots of overhead between your function call and your real business code.

    IMO, it's a really clever design ;)

    0 讨论(0)
提交回复
热议问题