配置例如以下:

①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. Vanya and Scales(思维)

    Vanya and Scales time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  2. WAS下获取包路径下所有类

    最近做javaweb项目的混淆工作,用到proguard,该工具混淆.jar文件比较方便,故把所有项目代码和配置文件打成jar包, 生成的jar包经过proguard处理后,再次打包(解决progua ...

  3. App Store不能下载一直等待中的两种解决办法

    1,重启手机,之后确认是否得到改善 2,重启不行,更改WiFi的dns为114.114.114.114或者223.5.5.5 或 223.6.6.6,再重启手机 ps:我是第二种方法

  4. CentOS 6.5下Percona Xtrabackup的安装错误解决方案

    1.下载最新版的Xtracbackup 2.安装 yum install perl-DBIyum install perl-DBD-MySQLyum install perl-Time-HiResyu ...

  5. SQL语句函数详解__sql聚合函数

    函数是一种有零个或多个参数并且有一个返回值的程序.在SQL中Oracle内建了一系列函数,这些函数都可被称为SQL或PL/SQL语句,函数主要分为两大类:单行函数.组函数 本文将讨论如何使用单行函数及 ...

  6. 转:C#整数三种强制类型转换int、Convert.ToInt32()、int.Parse()的区别

    1.int适合简单数据类型之间的转换,C#的默认整型是int32(不支持bool型); 2.int.Parse(string sParameter)是个构造函数,参数类型只支持string类型; 3. ...

  7. 加密html

    2009年4月4日 周六 22:18 <HTML> <HEAD> <meta http-equiv="Content-Type" content=&q ...

  8. [STOI2014]舞伴(dp)

    STOI是汕头OI...无聊翻到了去年的比赛题目,就写然后自己测了一下. 其实我很想吐槽为什么题目名是perm,perm好像和舞伴完全无关.. dp(x,s)=∑dp(x-1,s-{i}))(0< ...

  9. jeasyui制作计划-搭建php运行环境

    1.参考链接: http://jingyan.baidu.com/article/154b46315242b328ca8f4101.html http://jingyan.baidu.com/arti ...

  10. shopnc 商家中心添加打印商品二维码功能

    需求中提到需要增加每一件商品可以打印,用于线下体验店实体商品的二维码标签,客人可以根据手机扫二维码功能进行购买 任务描述: 1.如附件实现”批量打印标签“和单个商品”打印“标签功能. 2.标签有两种” ...