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

Jérôme Verstrynge picture Jérôme Verstrynge · Jul 1, 2012 · Viewed 7.5k times · Source

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")?

Answer

axtavt picture axtavt · Jul 1, 2012

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

Alternatively, you can use constants defined in WebApplicationContext.