Which is the default scope of a Spring 4 @Service
?
Does it make sense designing a Service implementation to store info about the current logged user (according to the current HTTP session), through class attributes (also by using the final
modifier)?
Spring's default scope is singleton.
singleton is the default scope in spring, so just leave your bean definitions as they are, without explicitly specifying the scope attribute. You can read more about scopes in the spring docs.
Singleton Scope:By default, the scope of a bean is a singleton.
The Spring Framework supports the following five scopes, three of which are available only if you use a web-aware ApplicationContext. Sr.No. This scopes the bean definition to a single instance per Spring IoC container (default). This scopes a single bean definition to have any number of object instances.
Which is the default scope of a Spring 4 @Service?
The default scope is singleton
It is reasonable to design a Service implementation in order to store some info, related to the current logged user (according to the current HTTP session)
Yes. In that case, the service will have to have the scope "session". See http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#beans-factory-scopes-other
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