Announcement Announcement Module
No announcement yet.
Force reinitalise / creationg of Bean on usage ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Force reinitalise / creationg of Bean on usage ?


    I've been banging my head with this problem for a while and can't see what I'm doing wrong - I know what I'm trying to achieve is really simple and I'm more than likely missing something thats really simple.

    I have a pojo which has a reference to a remote bean. The bean is a proxyed via SpringHTTPInvoker. I have the springhttpinvoker part working so my pojo can make calls to the remote bean. What I can't get to work is pass across some properties that are only available once a user has called a pojo method. To provide some background what I want to do is get some properties from the thread local object which is only populated once a request has been received by the pojo.

    The architecture is Client app -> webapp 1(pojo) -->webapp 2. (remote bean)

    What seems to be happening is the httpinvoker and custom httpclient bean are created at webapp1's setup in tomcat and are not re-initalised when a request is received from the client, which is where I expect the thread local to have the right values.

    My servlet.xml is as follows

    	<bean id="nwsvc"
    		abstract="false" singleton="true" lazy-init="default"
    		<property name="serviceInterface"
    			value="com.shota.service.MyNewsService" />
    		<property name="serviceUrl"
    			value="http://@[email protected]/news/nService" />
    		<property name="httpInvokerRequestExecutor">
    			<ref bean="requestExecutor" />
    	<bean id="requestExecutor"
    		abstract="false" singleton="true" lazy-init="true"
    		<property name="httpClient">
    				abstract="false" singleton="true" lazy-init="default"
    				autowire="default" dependency-check="default">
    	<bean id="gatherService"
    		<property name="svc">
    			<ref bean="nwsvc" />
    	<bean name="/gather"
    		<property name="serviceInterface"
    			value="com.shota.example.service.gatherService" />
    		<property name="service" ref="gatherService" />
    I tried using lazy-init = true, but from my understanding if a bean that is referencing one of my beans is not lazy initalized like my gather bean above then this property has no effect.

    All I really want to happen is for the httpclient property in my requestexecutor bean to be re-initalised before the remoting call.

    Can anyone help me with this ?

    Any comment / thought are most welcome



  • #2
    Have you looked at the new scopes in 2.0?