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

  • Force reinitalise / creationg of Bean on usage ?

    Hi,

    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

    Code:
    <beans>
    
    	<bean id="nwsvc"
    		class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"
    		abstract="false" singleton="true" lazy-init="default"
    		dependency-check="default">
    		<property name="serviceInterface"
    			value="com.shota.service.MyNewsService" />
    		<property name="serviceUrl"
    			value="http://@[email protected]/news/nService" />
    		<property name="httpInvokerRequestExecutor">
    			<ref bean="requestExecutor" />
    		</property>
    	</bean>
    
    	<bean id="requestExecutor"
    		class="com.shota.http.MYHttpInvokerRequestExecutor"
    		abstract="false" singleton="true" lazy-init="true"
    		dependency-check="default">
    		<property name="httpClient">
    			<bean
    				class="com.shota.http.HttpClientFactoryBean"
    				abstract="false" singleton="true" lazy-init="default"
    				autowire="default" dependency-check="default">
    
    			</bean>
    		</property>
    
    	</bean>
    
    	<bean id="gatherService"
    		class="com.shota.example.service.gatherServiceImpl">
    		<property name="svc">
    			<ref bean="nwsvc" />
    		</property>
    	</bean>
    
    	<bean name="/gather"
    		class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
    		<property name="serviceInterface"
    			value="com.shota.example.service.gatherService" />
    		<property name="service" ref="gatherService" />
    	</bean>
    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

    Thanks,

    shota

  • #2
    Have you looked at the new scopes in 2.0?
    http://www.springframework.org/docs/...y-scopes-other
    http://www.infoq.com/articles/spring-2-intro

    Comment

    Working...
    X