java

位置:IT落伍者 >> java >> 浏览文章

Spring2 提供的remote包学习笔记[2]


发布日期:2020年12月12日
 
Spring2 提供的remote包学习笔记[2]

使用Spring 发布 RMI服务示例

服务器端配置:

<bean id=bookService class=comxmatthewspringremoteBookService>

</bean>

<bean class=orgspringframeworkremotingrmiRmiServiceExporter>

<! does not necessarily have to be the same name as the bean to be exported >

<property name=serviceName value=bookService/>

<property name=service ref=bookService/>

<property name=serviceInterface value=comxmatthewspringremoteIBookService/>

<property name=registryPort value=/>

</bean>

客户端配置:

<bean class=comxmatthewspringremoteclientBookQueryService>

<property name=bookService ref=bookService/>

</bean>

<bean id=bookService class=orgspringframeworkremotingrmiRmiProxyFactoryBean>

<property name=serviceUrl value=rmi://localhost:/bookService/>

<property name=serviceInterface value=comxmatthewspringremoteIBookService/>

</bean>

Hessian提供一种基于HTTP的二进制远程协议它是由Caucho创建的可以在 http://wwwcauchocom 找到更多有关Hessian的信息

首为使用Hessian需要为其配置Spring 的 DispatcherServlet把下面的配置加入到webxml中

<servlet>

<servletname>remoting</servletname>

<servletclass>orgspringframeworkwebservletDispatcherServlet</servletclass>

<loadonstartup></loadonstartup>

</servlet>

<servletmapping>

<servletname>remoting</servletname>

<urlpattern>/remoting/*</urlpattern>

</servletmapping>

服务器端配置:

<bean id=bookService class=comxmatthewspringremoteBookService>

</bean>

<bean name=/bookService class=orgspringframeworkremotingcauchoHessianServiceExporter>

<property name=service ref=bookService/>

<property name=serviceInterface value=comxmatthewspringremoteIBookService/>

</bean>

客户端配置:

<bean class=comxmatthewspringremoteclientBookQueryService>

<property name=bookService ref=bookService/>

</bean>

<bean id=bookService class=orgspringframeworkremotingcauchoHessianProxyFactoryBean>

<property name=serviceUrl value=http://localhost:/bookService/>

<property name=serviceInterface value=comxmatthewspringremoteIBookService/>

</bean>

[] [] []

               

上一篇:Spring2 提供的remote包学习笔记[3]

下一篇:Spring2 提供的remote包学习笔记[1]