In Spring there is always one instance of a singleton bean per container
The
J2EE specification introduces the concept of
session. A session is associsciated with a user session. Since, HTTP is stateless, the web containers use either cookies or url parameters to identify that the requests coming in belong to an user that the server has seen before. In Spring, in a web application, a
session scoped bean is tied to the HTTP Session. SO, there is an instance of the bean per HTTP session.
With Portlets, J2EE introduces the concept of
Portlet Session. A web application contains portlets. Each portlet is given access to a Portlet Session. A Portlet Session works very similarly to HTTP Session, except that the Portlet Session has 2 scopes;
Portlet Scope and
Application scope. If you use Spring in an portlet application, then a
session scoped bean is tied to the Portlet Scope. A
global session scoped bean is tied to the application scope
Now, I'm pretty sure that both session scoped beans and globabl session scoped beans are tied to the underlying Portlet Session. So, if you have 2 Spring containers inside a portlet, they will end up sharing the beans. I'm pretty sure, but not certain. You might want to try it out to make sure. I'm looking at the Spring's code
here and it looks to be that the bean is simply retreived from the underlying PortletSession.
I'm pretty sure global session scoped beans are one per global session, and not one per global session per container