Back Forum Reply New

session scoped-proxy using the spring DTD

Hello,

As I'm using an old Websphere 5.0 with poor XML support, I cannot use the Spring schemas to build my context configuration.

I'd like to setup a session-scoped bean. I've setup this configuration :

Code: lt;bean id=quot;contextequot; class=quot;org..aop.scope.ScopedProxyFactoryBeanquot;       singleton=quot;falsequot;gt;    lt;property name=quot;targetBeanNamequot; value=quot;__contextequot;/gt; lt;/beangt;
lt;bean id=quot;__contextequot; class=quot;sfr.hamlet.modele.implementations.Contextequot;   singleton=quot;falsequot;gt;...lt;/beangt;
Where can I set the quot;sessionquot; scope in such a config, as the Spring DTD doesn't declare the scope attribute for bean element ? Is there any property in ScopedProxyFactoryBean hierarchy for this ?

I've made a test by setting a scope=quot;sessionquot; attribute to my bean. This is not valid according to the DTD but this seems to be valid as my beandefinition is added with expected scope in BeanDefinitionDocumentReader.

But I always get a new instance when invoking my scoped-bean. It worked fine with the schema-based configuration. Any idea ?

The problem is that setting scope=quot;sessionquot; to the target bean has no effect, and setting it to the proxy is overriden to scope=prototype.Root bean: class [org..aop.scope.ScopedProxyFactoryBe  an]; scope=prototype; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [applicationContext-metier.xml]

Replacing singleton=false with scope=session on the factorybean definition does make the BeanDefinition have the expected scope=session , but doesn't make all work : The scoped object is the factory, and a new instance is created for every access to the beanFactory.

Using this bean definition solves this issue :

Code:  lt;bean id=quot;contextequot; class=quot;org..aop.scope.ScopedProxyFactoryBeanquot;       singleton=quot;truequot;gt;    lt;property name=quot;targetBeanNamequot; value=quot;__contextequot;/gt; lt;/beangt;
lt;bean id=quot;__contextequot; class=quot;sfr.hamlet.modele.implementations.Contextequot;       scope=quot;sessionquot;gt;...
...That is invalid according to Spring DTD.
Will the DTD be updated for 2.0 final ?

OK, I just discoverd the new Spring 2.0 DTD that solves this.
¥
Back Forum Reply New