Is there a scope in spring?

I saw the application area on the next blog. It's true?

http://www.concretepage.com/spring/spring-bean-scope-example-using-scope-annotation-and-xml-for-singleton-prototype-request-session-global-session-and-application-scope- with-scoped-proxy

Because, in my surfing, I found out that spring has only less than 5 areas. Please correct me if I am wrong.

  • Singleton
  • Prototype
  • Request
  • Session
  • Global session
+6
source share
2 answers

There is a section in the white paper related to bean areas:

Basically, they define the following:

singleton ( ) bean IoC Spring.

bean .

bean HTTP-; HTTP- bean, bean. - Spring ApplicationContext.

bean HTTP. - Spring ApplicationContext.

globalSession bean HTTP. . - Spring ApplicationContext.

bean ServletContext. - Spring ApplicationContext.

WebSocket bean WebSocket. - Spring ApplicationContext.


, Spring 3.0 , , , :

Spring 3.0, , . . SimpleThreadScope. , . " ".

, , :


Application scope :

Spring AppPreferences bean appPreferences bean . apppreferences bean ServletContext, ServletContext.

Spring singleton bean:

a Spring singleton bean, : singleton per ServletContext, Spring "ApplicationContext" ( ), , , ServletContext

, XML:

<bean id="apps" class="com.App" scope="application"/>

:

@ApplicationScope
@Component
public class App {
    // ...
}
+9

All Articles