Announcement Announcement Module
Collapse
No announcement yet.
Are MessageSource beans supposed to be Singletons? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Are MessageSource beans supposed to be Singletons?

    Hi,

    I'm looking at the different implementations of MessageSource (ex: ResourceBundleMessageSource and ReloadableResourceBundleMessageSource) and I notice that things are coded to allow for concurrent access with synchronized blocks.

    Synchronized blocks only make sense to me if the class vars being accessed are either static, or the class is a singleton. Given that the RBMS class vars are not static, it would therefore imply that the class must be a singleton.

    However, all the examples I find declare the MessageSource bean without a scope, thereby indicating that it would be prototype.

    So I am confused. Is it supposed to be a Singleton? If not, how does this work? If so, how does it magically become a singleton if it is not declared as one?

    Thanks,

    Eric

  • #2
    However, all the examples I find declare the MessageSource bean without a scope, thereby indicating that it would be prototype.
    And that is where you are wrong.... Beans without a scope are singletons by default. (Which is also explained in the reference guide).

    Comment


    • #3
      *smack on forehead* Of course. Was too late last night as I was looking at this. Definitely makes more sense now.

      Thanks for the clarification.

      Eric

      Comment

      Working...
      X