package com.huashun.api.hessian;
import java.util.List;
import com.huashun.api.hessian.domain.BaseDataVo;
/**
*
* @author LiuQing
* @see 基本数据接口
* @version 1.0
* 2014-9-25 下午6:01:10
*/
public interface IBaseDataApi {
/**
* 查询所有行政区
* @return List<BaseData>
*/
public List<BaseDataVo> queryByAllRegion();
/**
* 依据行政区检索所属小区信息数据集
* @param id 行政区编
* @return
*/
public List<BaseDataVo> queryQuartersByRegionId(Integer id);
}
package com.huashun.api.hessian.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.huashun.api.hessian.IBaseDataApi;
import com.huashun.api.hessian.domain.BaseDataVo;
import com.huashun.api.mybatis.mappers.BaseDataMapper;
/**
*
* @author LiuQing
* @see
* @version 1.0
* 2014-9-26 上午9:13:08
*/
@Service("baseDataApi")
public class BaseDataApiImpl implements IBaseDataApi {
@Resource
private BaseDataMapper baseDataMapper;
@Override
public List<BaseDataVo> queryByAllRegion() {
return baseDataMapper.queryByAllRegion();
}
@Override
public List<BaseDataVo> queryQuartersByRegionId(Integer id) {
return this.baseDataMapper.queryQuartersByRegionId(id);
}
}
package com.huashun.api.hessian.domain;
import java.io.Serializable;
/**
*
* @author LiuQing
* @see 基础数据接口
* @version 1.0
* 2014-9-26 上午9:04:17
*/
public class BaseDataVo implements Serializable {
private static final long serialVersionUID = -1472316551814130927L;
//编号
private Integer id;
//名称
private String name;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Spring配置
<bean name ="/baseData" class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="baseDataApi" /> <property name="serviceInterface" value="com.huashun.api.hessian.IBaseDataApi" /> </bean>
使用caucho原生API调用(Spring 略)
public static void main(String[] args) throws Exception {
HessianProxyFactory factory = new HessianProxyFactory();
IBaseDataApi api = (IBaseDataApi) factory.create(IBaseDataApi.class, "http://192.168.0.250:8080/HuaShunService/hessian/baseData");
for (BaseDataVo vo:api.queryQuartersByRegionId(3)) {
System.out.println(vo);
}
}