Hessian与OSGi(spring dm server) 的整合

Hessian OSGi spring dm server

 

的整合

 

一、        目录结构:

remote

         import :用来导入 hessian 服务

         export :用来导出 hessian 服务

二、        导出( export

Bundle 名: remote.export

hessian 服务器设置: (以 operator 为例)

1.       需要导入的外部 bundle (在 MANIFEST.MF 文件中)

Import-Bundle: com.springsource.com.caucho;version="[3.1.5,3.1.5]"

2.       需要导入的 package (在 MANIFEST.MF 文件中)

Import-Package: com.**.**.**.operator.service,

               com.**.**.**.operator.domain

3.       需要引入的服务(在 osgi-context.xml 文件中)

<reference id="operatorService" interface="com .**.**.**. operator.service.IOperatorService" />

4.       META-INF/spring/remote-servlet.xml 中将需要导出的服务发布为 hessian 服务

<!-- 操作员 -->

    < bean name = "/remoteOperatorService" class = "org.springframework.remoting.caucho.HessianServiceExporter" >

       < property name = "service" >

           < ref bean = "operatorService" />

       </ property >

      

       < property name = "serviceInterface" >

           < value > com.**.**.**.operator.service.IOperatorService </ value >

       </ property >

    </ bean >

5.       MANIFEST.MF 中添加设置:

Web-DispatcherServletUrlPatterns: /remoting/*

设置 hessian 请求的格式

6.       完成 hessian 服务器端的设置

 

三、        导入( import

Bundle 名: remote.imports

导入的处理有两种方式:

1.      只导入 hessian 服务并发布

import 中只需要两个包: domain interface

Domain 中放远程服务用的到对象

Interface 存放远程服务接口

                   步骤:

A.      导入 bundle com.springsource.com.caucho;version="[3.1.5,3.1.5]"

B.      module-context.xml 中建 bean

< bean id = "operatorServiceImpl"

class = "org.springframework.remoting.caucho.HessianProxyFactoryBean" >

< property name = "serviceUrl " >

< value > http://**.**.**.com:8080/**/remote/remoting/remoteOperatorService </ value >

</ property >

< property name = "serviceInterface " >

< value > com.**.**.**.remote.imports.interfaces.IOperatorService </ value >

</ property >

</ bean >

C.      osgi-context.xml 中发布服务

< service id = "operatorService" ref = " operatorServiceImpl "

               interface = " com.**.**.**.remote.imports.interfaces.IOperatorService " />

D.  完成 hessian 客户端

 

2.      导入 hessian 服务并进行封装,然后发布封装好的服务

Import 中需要四个包: domain, interface, service, service.impl

service service.impl 中对远程接口进行封装。

步骤:

A.        需要导入 bundle

com.springsource.com.caucho;version="[3.1.5,3.1.5]"

B.        module-context.xml 中建 bean

< bean id = "operatorService"

class = "org.springframework.remoting.caucho.HessianProxyFactoryBean" >

< property name = "serviceUrl " >

< value > http://**.**.**.com:8080/**/remote/remoting/remoteOperatorService </ value >

</ property >

< property name = "serviceInterface " >

< value > com.**.**.**.remote.imports.interfaces.IOperatorService </ value >

</ property >

</ bean >

C.        在包 service.impl 中调用 operatorService ,对其进行封装,然后将封装后的服务发布出去

D.        完成 hessian 服务的客户端。

 

 

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值