Patterns

  • Scope != Pattern
  • Spring Uses Them
  • Course(s): Design Patterns in Java


----------------------------------------------------------------

Scopes

  • Valid in any configuration
        Singleton
        Prototype
  • Valid only in web-aware Spring projects
        Request
        Session
        Global

-------------------------------------------------------------------

Singleton

  • One Instantiation
  • Default Bean Scope
  • Single instance per Spring container


---------------------------------------------------------------------

Singleton - Java Config

  • @Scope
  • Requires AOP jar

Bean Scopes


Demo

applicatonContext.xml

Bean Scopes

default: singleton

Bean Scopes

prototype

Bean Scopes

Using a Constant Demo
Bean Scopes


-------------------------------------------------------------------------------

Singleton - XML Config

  • scope="singleton"
Bean Scopes



---------------------------------------------------------------------------------

Prototype

  • Per request
  • Guaranteed unique
  • Opposite of Singletion


-------------------------------------------------------------------------

Web Scopes

  • Introduction to Spring MVC course
  • Request
  • Session
  • GlobalSession

----------------------------------------------------------------------------------------------------------------

Summary

  • Scopes
        Singleton
        Prototype
  • Web Scopes
        Request
        Session
        GlobalSession


------------------------------------------------------------------

Properties
https://blog.csdn.net/u012596785/article/details/79865454









相关文章: