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 ...
随机推荐
- PHP 表单验证 - 完成表单实例
------------------------------------------------------------------------------------------- 本节展示如何在用 ...
- php php打乱数组二维数组、多维数组
php中的shuffle函数只能打乱一维数组,有什么办法快速便捷的打乱多维数组?手册上提供了 <?php function shuffle_assoc($list) { if (!is ...
- Conquering Keokradong && Get the Containers(二分)
Conquering Keokradong Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu ...
- Hyperion Essbase BusinessRule 函数学习--2
@AVG Returns the average of all values in expList. [返回表达式列表的平均值] Syntax @AVG (SKIPNONE | SKIPMISSING ...
- java学习笔记day06---匿名内部类
1.匿名内部类:其实就是内部类的简化形式,它所体现的就是一个类或者接口的子类对象.前提: 内部类必须继承或实现外部类或接口. 格式: new 父类&接口(){}; 其实就是 ...
- 使用zeranoe的自动化脚本mingw-w64-build-3.6.4在ubutun14.04_64bit上交叉编译ffmpeg 2.5
编译期间,碰到的两个大问题,是环境变量设置问题. 先列出执行脚本是碰到的两个问题,后面给出解决方法并记录执行的命令步骤. 问题1: 编译binutils 2.5出错 ----------------- ...
- O the joy of having nothing / 아무것도 갖지않고
Chords: C G Am Em F C Dm G C G Am Em F C Am Dm G English - O the joy of having nothing and being not ...
- @init 自定义
相当于构造方法,有的时候初始化的时候有一些默认值,还有就是页面加载数据的时机问题,防止加载了页面再填数据 声明: -(instancetype)initWithName:(NSString *)aNa ...
- C#中Spli、正则表达式分解字符串详解
一.String.Split方法提供了如下6个重载函数: 名称 说明 String.Split (Char[]) 返回包含此实例中的子字符串(由指定 Char 数组的元素分隔)的 String 数组. ...
- 设置ssh免密码登录脚本(hadoop自动化部署脚本一)
设置ssh免密码登录脚本(hadoop自动化部署脚本一) 设置ssh免密码登录脚本(飞谷云大数据自动化部署脚本一) 1.#!/bin/sh2.#important note:this script i ...