Reputation: 43
AFAIK, Spring beans (version 3 and above), if not specified, all are singletons. So, my concern is, for example, when using @Repository
(in classes that access database resources) or @Service
(in classes that perform validations and business logic), these objects would be available to all of the users in the application in case accessed concurrently?
Thanks in advance...
Upvotes: 4
Views: 2289
Reputation: 691755
Yes, these objects would be accessed concurrently. So they must be coded in a thread-safe way. But this is trivial to do, since they're usually stateless, except for their dependencies which are injected at startup time by Spring.
Upvotes: 6