Announcement Announcement Module
Collapse
No announcement yet.
HttpInvoker changing service URL at runtime Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HttpInvoker changing service URL at runtime

    Hi,

    what would be the strategy to change the URL of a remote service at runtime ? Actually, I have a client which needs to connect to many remote services implemented as HttpInvoker services. They are not known by advance and I haven't found any solution to change the URL of the services.

    <bean id="blfacadeservice" class="org.springframework.remoting.httpinvoker.Ht tpInvokerProxyFactoryBean">
    <property name="serviceUrl">
    <value>http://remote:7001/blfacade.service</value>
    </property>
    <property name="serviceInterface">
    <value>com.XXX.domain.BLService</value>
    </property>
    </bean>

    If my bean blfacadeservice is injected in another bean or if i retrieve it manually with ApplicationContext and try to upcast it to org.springframework.remoting.httpinvoker.HttpInvok erProxyFactory class it fails. I thought of applicationContext listener to change the URL of my singleton bean but I still face class cast exceptions.

    Any ideas ?

    Thanks,
    bengali

  • #2
    Re: HttpInvoker changing service URL at runtime

    Ok I have found a way (in the documentation) to get the underlying beanFactory 's bean prepending its name with &.
    It's not very clean but it works:

    ApplicationContext ctx = new ClassPathXmlApplicationContext("com/XXX/monitor/service/applicationContext.xml");
    HttpInvokerProxyFactoryBean httpinvoker = (HttpInvokerProxyFactoryBean)ctx.getBean("&blfacad eservice");
    httpinvoker.setServiceUrl("http://remotehost:7001/test/blfacade.service");

    BLService blService = (BLService)ctx.getBean("blfacadeservice");

    Comment

    Working...
    X