Spring Http Invoker
配置例如以下:
①web.xml配置
<servlet> <servlet-name>remote</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- 配置该Servlet随应用启动时候启动 --> <load-on-startup>1</load-on-startup> </servlet> <!-- 配置DispatcherServlet映射的url --> <servlet-mapping> <servlet-name>remote</servlet-name> <url-pattern>/remoting/*</url-pattern> </servlet-mapping>
②client.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-lazy-init="true">
<bean id="sync.BackupSearchService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://${juyuan.webservice.address}:${juyuan.webservice.port}/${juyuan.webservice.application}/remoting/backupSearchService"/>
<property name="serviceInterface" value="com.juyuan.service.IBackupSearchService"/>
</bean> </beans>
③remote.xml
<?xml version="1.0" encoding="UTF-8"? >
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter" name="/backupSearchService">
<property name="service" ref="BackupSearchService"/>
<property name="serviceInterface" value="com.juyuan.service.IBackupSearchService"/>
</bean>
<bean class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter" name="/backupStrategyService">
<property name="service" ref="BackupStrategyService"/>
<property name="serviceInterface" value="com.juyuan.service.IBackupStrategyService"/>
</bean>
</beans>
④SyncService
package com.juyuan.service.impl; import java.lang.reflect.Method;
import java.util.Date;
import com.juyuan.model.Alarms;
import com.juyuan.model.AlarmsKeys;
import com.juyuan.model.Logs;
import com.juyuan.model.LogsKeys;
import com.juyuan.service.IAlarmsService;
import com.juyuan.service.ILogsService;
import com.juyuan.support.AppCommon;
import com.juyuan.support.AppContext; /**
* add by LB 已屏蔽.若要开启同步请去掉execute里凝视的代码.
* @author LB
*
*/
public class SyncService implements Runnable{ private Method method = null;
private Object serviceObj = null;
private Object[] paramArray = null;
/**
* 同步数据通用类
* @param serviceObj 服务对象.
* @param methodName 待调用的服务方法.
* @param paramTypes 參数的类类型数组.
* @param paramArray 參数数组.(必须可以序列化)
*/
public SyncService(Object serviceObj,String methodName,Class<Object>[] paramTypes,Object[] paramArray){
try {
this.serviceObj = serviceObj;
this.paramArray = paramArray;
method = serviceObj.getClass().getMethod(methodName, paramTypes );
} catch (Exception e) { } } public void run() {
try {
method.invoke(serviceObj,paramArray);
} catch (Exception e) {
e.printStackTrace(); }
}
/**
* 运行同步
*/
public void execute(){ new Thread(this).start();
}
}
⑤调用方式:
new SyncService(this.getSyncConditionService(),"saveSearchCondition",new Class[]{DefaultSearchCondition.class},new Object[]{entity}).execute();
Spring Http Invoker的更多相关文章
- 服务调用方案(Spring Http Invoker) - 我们到底能走多远系列(40)
我们到底能走多远系列(40) 扯淡: 判断是否加可以效力于这家公司,一个很好的判断是,接触下这公司工作几年的员工,了解下生活工作状态,这就是你几年后的状态,如果满意就可以考虑加入了. 主题: 场景: ...
- Spring Http Invoker使用简介
一.Spring HTTP Invoker简介 Spring HTTP invoker 是 spring 框架中的一个远程调用模型,执行基于 HTTP 的远程调用(意味着可以通过防火墙),并使用 ja ...
- Spring HTTP invoker简介
Spring HTTP invoker简介 Spring HTTP invoker是spring框架中的一个远程调用模型,执行基于HTTP的远程调用(意味着可以通过防火墙),并使用java的序列化机制 ...
- Spring HTTP invoker 入门
一.简介 Spring开发团队意识到RMI服务和基于HTTP的服务(如,Hessian)之间的空白.一方面,RMI使用JAVA标准的对象序列化机制,很难穿透防火墙.另一方面,Hessian/Burla ...
- Spring Remoting by HTTP Invoker Example--reference
Spring provides its own implementation of remoting service known as HttpInvoker. It can be used for ...
- spring HttpInvoker相关学习资料
官方文档 spring支持的几种RPC 用Http Invoker实现RCP客户端与后台的交互 Java HttpInvoker小试 Spring注解发布RMI/HTTPInvoker/Hessian ...
- Spring Remoting: HTTP Invoker--转
原文地址:http://www.studytrails.com/frameworks/spring/spring-remoting-http-invoker.jsp Concept Overview ...
- spring源码分析之spring-web remoting模块概况及基本概念
spring-web总体分为三部分:caucho.httpinvoker.jaxws,其总体构造图如下: uml结构: 先看看网上搜索到的上述实现的原理吧:Spring RMI,Hessian/Bur ...
- Maven dependency spring-web vs spring-webmvc
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmv ...
随机推荐
- Merge Two Sorted Lists 解答
Question Merge two sorted linked lists and return it as a new list. The new list should be made by s ...
- 【转】android 物理按键
关键词:android 按键 矩阵按键 AD按键 平台信息: 内核:linux2.6/linux3.0 系统:android/android4.0 平台:S5PV310(samsung exy ...
- Xshell不能连接SSH的解决
异常处理汇总-服 务 器 http://www.cnblogs.com/dunitian/p/4522983.html 重新启动看看:/etc/init.d/ssh restart (/etc/ini ...
- hdu 5495 LCS
Problem Description You are given two sequence {a1,a2,...,an} and {b1,b2,...,bn}. Both sequences are ...
- SPOJ 130 - Rent your airplane and make money(dp+优化)
题意:有n列预定航班,从st时刻开始出发,飞行时间为d,花费为p,且同一时刻不能有两个航班,求最大的花费 对航班的开始时间(或结束时间)按升序排序,从后往前找到对应结束时间所在的航班位置(如按结束时间 ...
- PPTP协议握手流程分析
一 PPTP概述 PPTP(Point to Point Tunneling Protocol),即点对点隧道协议.该协议是在PPP协议的基础上开发的一种新的增强型安全协议,支持多协议虚拟专用网,可 ...
- js 创建html元素 渲染html元素
var p1 = document.getElementById('p1'); //添加的元素类型及属性var newNode = document.createElement("input ...
- 认证和注册,提交到App Store:
账号分为个人和公司个人付费后2天左右,收到激活邮件,可以使用 member center certificates,identifiers&profiles:certificates 认证:d ...
- 播放器音乐源之天天动听API
搜索歌曲API:http://so.ard.iyyin.com/s/song_with_out?q={0}&page={1}&size={2} {0}=需要搜索的歌曲或歌手 {1}=查 ...
- hasClass方法 动画方法说明
$(this).hasClass("selected");判断是否含有selected样式