1. 程式人生 > 實用技巧 >15.3使用Hessian和Burlap釋出遠端服務

15.3使用Hessian和Burlap釋出遠端服務

15.3.1使用Hessian和Burlap匯出Bean的功能
1)匯出Hessian服務
@Bean
public HessianServiceExporter hessianServiceExporterSpittrService(SpittrService spittrService){
HessianServiceExporter exporter = new HessianServiceExporter();
exporter.setService(spittrService);
exporter.setServiceInterface(SpittrService.class
);
return exporter;
}
2)配置hessian控制器(配置DispatcherServlet、處理器對映器handlermapping)
@Override
protected String[] getServletMappings() {
return new String[]{"/","*.service"};
}
@Bean
public HandlerMapping hessianMapping(){
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
Properties mappings = new
Properties();
mappings.setProperty("/spttr.service","hessianServiceExporterSpittrService");
mapping.setMappings(mappings);
return mapping;
}

15.3.2訪問Hessian/Burlap服務

@Bean
public HessianProxyFactoryBean spittrService(){
HessianProxyFactoryBean proxyFactoryBean = new HessianProxyFactoryBean();
proxyFactoryBean.setServiceUrl("http://localhost:8080/RpcServer/spttr.service");
proxyFactoryBean.setServiceInterface(SpittrService.class);
return proxyFactoryBean;
}




來自為知筆記(Wiz)