熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

Spring2 提供的remote包學習筆記[2]

2022-06-13   來源: Java開源技術 

  使用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>

[]  []  []  


From:http://tw.wingwit.com/Article/program/Java/ky/201311/28951.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.