Why use singleton controllers in play 2.5?

后端 未结 2 1586
无人共我
无人共我 2020-12-16 18:57

I\'m just starting out and I dont think i understand it very well. From what I understand all controllers are created as dependencies the moment the router is created. They

2条回答
  •  感情败类
    2020-12-16 19:25

    If you have a controller that is instantiated by the router (ie. the default), then they are implicitly singletons, because the router exists only once. However if you inject the controller somewhere else, you'd still get a new instance unless it is marked as singleton.

    Source: https://github.com/playframework/playframework/issues/4508#issuecomment-127820190

提交回复
热议问题