Sometime it's necessary to extends a framework. Sometimes it's necessary to hook into the request/response lifecycle, for example for a parameter binding or to write a security module. How could this be done in the playframework 1.x?
There are two ways to extend play 1.x. First you can write your own module. This is described in detail here. This is useful if you want provide a library such as iText or provide a special authentication mechanism.
The second way is to write a PlayPlugin
. This is often done in modules but it's not a necessary condition. To write a PlayPlugin
requires two steps:
PlayPlugin
and override some of its methods, for example called myPackage.MyPlugin
.play.plugins
and putting it into the classpath. The file must contain a line like 1003:myPackage.MyPlugin
.The number defines the order in which the plugins are called. I recommend to use ids > 1000. If you want it to load before a framework plugin, look here (The ids are valid since 1.1.1).
That's it. To get a feeling of what you can do with a Plugin see the javadoc. You can hook into:
Unfortunately the javadoc documentation is minimal, but don't hesitate to look into the code of the playframework itself. It's easy to understand and gives you good ideas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With