Search code examples
javaannotationsscopespring-3

Where are valid values defined for @Scope in web-aware and portal spring contexts?


The following allows the declaration of a singleton bean in Spring 3.0:

@Bean
@Scope(BeanDefinition.SCOPE_SINGLETON)
private void setBean1(Bean1 b1) {
    this.b1 = b1;
}

But, BeanDefinition does not define scopes values for request, session and global session. Where are these defined? Else, should I use @Scope("request"), @Scope("session") and @Scope("global session")?


Solution

  • You can use string literals if you want (though global session would be "globalSession").

    Alternatively, you can use constants defined in WebApplicationContext.