New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] [2.4.0] Controller defined as singleton object in ScalaActions.md #4508

Closed
wsargent opened this Issue May 20, 2015 · 6 comments

Comments

Projects
None yet
5 participants
@wsargent
Member

wsargent commented May 20, 2015

https://playframework.com/documentation/2.4.x/ScalaActions

A Controller is nothing more than a singleton object that generates Action values.

A controller isn't a Scala singleton object any more in 2.4.x -- it's a class that's injected.

@marcospereira

This comment has been minimized.

Show comment
Hide comment
@marcospereira

marcospereira May 20, 2015

Member

Both are supported. I think that using a object is the default.

Member

marcospereira commented May 20, 2015

Both are supported. I think that using a object is the default.

@marcospereira

This comment has been minimized.

Show comment
Hide comment
@marcospereira

marcospereira May 20, 2015

Member

Ok, the code snippet is inconsistent and we don't have documentation for both object and classes with dependency injection.

Member

marcospereira commented May 20, 2015

Ok, the code snippet is inconsistent and we don't have documentation for both object and classes with dependency injection.

@benmccann benmccann added this to the 2.4.0 milestone May 20, 2015

@jroper

This comment has been minimized.

Show comment
Hide comment
@jroper

jroper May 20, 2015

Member

I don't think we necessarily need to document objects - the recommended approach, and the only possible way in a future version of Play, is to use classes. Newly created projects use classes, not objects, and the documentation is most important for new users on new projects, adding documentation for objects introduces noise, and the value from the noise is questionable.

Member

jroper commented May 20, 2015

I don't think we necessarily need to document objects - the recommended approach, and the only possible way in a future version of Play, is to use classes. Newly created projects use classes, not objects, and the documentation is most important for new users on new projects, adding documentation for objects introduces noise, and the value from the noise is questionable.

@jroper jroper modified the milestone: 2.4.0 Jun 18, 2015

@dvic

This comment has been minimized.

Show comment
Hide comment
@dvic

dvic Jul 25, 2015

@jroper but the injected controller instances are by default singletons, right?

dvic commented Jul 25, 2015

@jroper but the injected controller instances are by default singletons, right?

@jroper

This comment has been minimized.

Show comment
Hide comment
@jroper

jroper Aug 5, 2015

Member

Not really - if using Guice, each time the controller is injected into something, a new instance will be created by default. That said, the router is a singleton, and so by association, the controllers it invokes are singleton. But if you inject a controller somewhere else, it will be instantiated newly for that component.

Member

jroper commented Aug 5, 2015

Not really - if using Guice, each time the controller is injected into something, a new instance will be created by default. That said, the router is a singleton, and so by association, the controllers it invokes are singleton. But if you inject a controller somewhere else, it will be instantiated newly for that component.

@marcospereira

This comment has been minimized.

Show comment
Hide comment
@marcospereira
Member

marcospereira commented Feb 20, 2016

See PR #5700.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment