配置例如以下:

①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的更多相关文章

  1. 服务调用方案(Spring Http Invoker) - 我们到底能走多远系列(40)

    我们到底能走多远系列(40) 扯淡:  判断是否加可以效力于这家公司,一个很好的判断是,接触下这公司工作几年的员工,了解下生活工作状态,这就是你几年后的状态,如果满意就可以考虑加入了. 主题: 场景: ...

  2. Spring Http Invoker使用简介

    一.Spring HTTP Invoker简介 Spring HTTP invoker 是 spring 框架中的一个远程调用模型,执行基于 HTTP 的远程调用(意味着可以通过防火墙),并使用 ja ...

  3. Spring HTTP invoker简介

    Spring HTTP invoker简介 Spring HTTP invoker是spring框架中的一个远程调用模型,执行基于HTTP的远程调用(意味着可以通过防火墙),并使用java的序列化机制 ...

  4. Spring HTTP invoker 入门

    一.简介 Spring开发团队意识到RMI服务和基于HTTP的服务(如,Hessian)之间的空白.一方面,RMI使用JAVA标准的对象序列化机制,很难穿透防火墙.另一方面,Hessian/Burla ...

  5. Spring Remoting by HTTP Invoker Example--reference

    Spring provides its own implementation of remoting service known as HttpInvoker. It can be used for ...

  6. spring HttpInvoker相关学习资料

    官方文档 spring支持的几种RPC 用Http Invoker实现RCP客户端与后台的交互 Java HttpInvoker小试 Spring注解发布RMI/HTTPInvoker/Hessian ...

  7. Spring Remoting: HTTP Invoker--转

    原文地址:http://www.studytrails.com/frameworks/spring/spring-remoting-http-invoker.jsp Concept Overview ...

  8. spring源码分析之spring-web remoting模块概况及基本概念

    spring-web总体分为三部分:caucho.httpinvoker.jaxws,其总体构造图如下: uml结构: 先看看网上搜索到的上述实现的原理吧:Spring RMI,Hessian/Bur ...

  9. Maven dependency spring-web vs spring-webmvc

    <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmv ...

随机推荐

  1. hdu 5493 Queue(线段树)

    Problem Description N people numbered to N are waiting in a bank for service. They all stand in a qu ...

  2. 第八届郑州轻工业学院ACM(程序设计大赛)校内预选赛

    郑州轻工业学院有一个大赛,把几个有趣的题目分享一下.下面是题目连接,喜欢了就点点... 斗破苍穹 礼上往来 统计人数 神の数 炉石传说 Mathematics and Geometry 马拉松后记 斗 ...

  3. JDK5新特性之线程同步集合(五)

    一. 传统集合: 传统方式下的Collection在迭代集合时, 不同意对集合进行改动: public class CollectionModifyExceptionTest { public sta ...

  4. STL之nth_element()(取容器中的第n大值)

    nth_element()函数 头文件:#include<algorithm> 作用:nth_element作用为求第n大的元素,并把它放在第n位置上,下标是从0開始计数的,也就是说求第0 ...

  5. 【高精度+DP】【HDU1223】 OrderCount

    Order Count Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  6. RocketMQ与Kafka对比(18项差异)评价版

    此文是rocketmq作者vintage.wang所写,对于每项对比,后面都增加了我的观点,有不对的地方,请各位指出. 淘宝内部的交易系统使用了淘宝自主研发的Notify消息中间件,使用Mysql作为 ...

  7. CAShapeLayer + UIBezierPath

    UIBezierPath: UIBezierPath是在 UIKit 中的一个类,继承于NSObject,可以创建基于矢量的路径.使用此类可以定义常见的圆形.多边形等形状 .我们使用直线.弧(arc) ...

  8. 关于cookie的使用

    cookie的属性 domain:域名,即cookie所能使用的范围,当然当前域下可以在当前域下cookie,还有一个就是该域名的父级域名(子级的域名下是可以访问父级域名下的cookie,父级域名是不 ...

  9. 简单C# 验证类

    using System; using System.Text.RegularExpressions; namespace bobomousecom.crm { /// <summary> ...

  10. hdu 2966 In case of failure k-d树

    题目链接 给n个点, 求出每个点到离它最近的点的距离. 直接建k-d树然后查询就可以  感觉十分神奇... 明白了算法原理但是感觉代码还不是很懂... #include <bits/stdc++ ...