Wh开发者_运维知识库en using the Service design pattern, do you usually place the logged in user, or user scope, as a parameter to the methods of the service interface, or do you call AutheticationService.getLoggedInUser() in the service implementation.
What advantages/disadvantages do you find for each option?
Passing the parameter each time makes the service stateless (considering that nothing else is stored on the server). This is good for scalability - having multiple services allows any of them to handle any request.
Having an authentication service makes the calls less complex (and might give you other benefits) but reduces the scalability since the authentication might not be synchronized over all.
精彩评论