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









相关文章:

  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2022-02-02
  • 2021-07-03
  • 2022-02-24
  • 2021-06-01
  • 2022-02-16
猜你喜欢
  • 2021-09-15
  • 2021-12-04
  • 2022-01-24
  • 2021-09-16
  • 2022-12-23
  • 2021-11-16
  • 2022-01-15
相关资源
相似解决方案