Announcement Announcement Module
Collapse
No announcement yet.
session scoped-proxy using the spring DTD Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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:
      <bean id="contexte" class="org.springframework.aop.scope.ScopedProxyFactoryBean"
            singleton="false">
         <property name="targetBeanName" value="__contexte"/>
      </bean>
    
      <bean id="__contexte" class="sfr.hamlet.modele.implementations.Contexte"
        singleton="false">...</bean>
    Where can I set the "session" 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 ?

  • #2
    I've made a test by setting a scope="session" 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 ?

    Comment


    • #3
      The problem is that setting scope="session" to the target bean has no effect, and setting it to the proxy is overriden to scope=prototype.


      Root bean: class [org.springframework.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]

      Comment


      • #4
        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.

        Comment


        • #5
          Using this bean definition solves this issue :
          Code:
             <bean id="contexte" class="org.springframework.aop.scope.ScopedProxyFactoryBean"
                  singleton="true">
               <property name="targetBeanName" value="__contexte"/>
            </bean>
          
            <bean id="__contexte" class="sfr.hamlet.modele.implementations.Contexte"
                  scope="session">...
          ...That is invalid according to Spring DTD.
          Will the DTD be updated for 2.0 final ?

          Comment


          • #6
            OK, I just discoverd the new Spring 2.0 DTD that solves this.

            Comment

            Working...
            X