For pure code organization purposes, I consider creating many controllers in my application. I found no special overhead created by a controller object. On a quick inspection of play's source, it does not seem to spawn any especially thick objects that would incur a lot of memory consumption per each controller.
However I wonder whether sessions seamlessly cross across controllers, or are they bound in some way to the boundaries of a controller. I also consider using secure social in case it matters.
Thanks!
There is no reason to think that sessions would not work seamlessly across different controllers. Play is designed to be as stateless as possible, so controllers shouldn't be keeping any sort of state that might make sessions behave differently.
For example, there is really no difference between:
object Users extends Controller {
def read(id: Long) = Action { ??? }
def create() = Action { ??? }
}
and
object ReadUsers extends Controller {
def read(id: Long) = Action { ??? }
}
object CreateUsers extends Controller {
def create() = Action { ??? }
}
Obviously, this isn't the ideal organizational structure we're looking for, but it conveys my point. Controllers should be organized in a manner that you think is best for your code. The only time session data might be treated differently is if your controller object mixes in different traits, or uses different Action
types. I'm not very familiar with SecureSocial, but the choice of library shouldn't really be relevant.
Unless you are storing data in vars within a controller (or something similar), you should be okay.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments