Monday, 17 August 2015

Spring bean scopes – Web application

With this bean scope, a new bean instance will be created for each web request made by client.
As soon as request completes, bean will be out of scope and garbage collected.

Just like request scope, this ensures one instance of bean per user session. As soon as user ends its session, bean is out of scope.

global-session is something which is connected to Portlet applications. When your application works in Portlet container it is built of some amount of portlets.

Each portlet has its own session, but if you want to store variables global for all portlets in your application than you should store them in global-session.

This scope doesn’t have any special effect different from session scope in Servlet based applications.

In bean configuration file
       <bean id="demoBean" class="com.DemoBean" scope="session" />

Using annotations
public class DemoBean {
    //Some code

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...