开发者社区 问答 正文

hessian 和 spring结合,url动态替换

Hessian做远程服务,大家都知道的。 如何跟spring结合,网上有很多例子,这里就不写,主要是写一下,我遇到的一个问题,不知道大家解决的办法。

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <!-- 客户端Hessian代理工厂Bean -->
    <bean id="clientSpring" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
        <!-- 请求代理Servlet路径 -->        
        <property name="serviceUrl">
<value>http://localhost:8080/HessianSpring/remote/helloSpring</value>
        </property>
        <!-- 接口定义 -->
        <property name="serviceInterface">
            <value>com.wtang.isay.Isay</value>
        </property>
    </bean>
</beans>

大家看上课,使用spring Hessian的代理工厂,创建一个 单例的对象,大家看属性,serviceUrl属性值是写死的。

展开
收起
a123456678 2016-03-18 15:37:41 3313 分享 版权
1 条回答
写回答
取消 提交回答
  • 重写HessianClientInterceptor和HessianProxyFactoryBean,用map缓存每个url对应的HessianProxy, 调用的时候动态去拿服务地址,如果map中有HessianProxy就直接用,否则就创建一个再用。

    2019-07-17 19:06:52
    赞同 展开评论