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 ...
随机推荐
- windows平台vhd磁盘文件挂载
在windows平台下挂载vhd磁盘文件类似于挂载iso等文件; 使用VHDMount工具挂载VHD文件 启动Hyper-V里的外部VHD文件有点困难.如果在备份驱动上有个VHD文件,并需要从其虚拟机 ...
- java各公司笔试题集1
IBM笔试题 注:IBM笔试题一小时之内完成,题目全部用英文描述,这里用中文表述 一.名词解释 1.Eclipse 2.J2EE 3.EJB 4.Ajax 5.Web service 二.找出以下代码 ...
- java中反射学习整理
转载请注明:http://blog.csdn.net/j903829182/article/details/38405735 反射主要是指程序能够訪问.检測和改动它本身的状态或行为的一种能力. jav ...
- 用Jfree实现条形柱状图表,java代码实现
用Jfree实现条形柱状图表,java代码实现.可经经常使用于报表的制作,代码自己主动生成后能够自由查看.能够自由配置图表的各个属性,用来达到自己的要求和目的 package test1; impor ...
- linux上大量tcp端口处于TIME_WAIT的问题
今天发现网站突然无法访问,登陆webserver已经无法连接mysql,转战mysql一看,发现竟然有三千多个TIME_WAIT连接,擦,被SYN攻击了?百度&&google,发现通过 ...
- js 创建html元素 渲染html元素
var p1 = document.getElementById('p1'); //添加的元素类型及属性var newNode = document.createElement("input ...
- session之退出登陆
<span style="font-size:32px;">//使用SESSION必须先开启session session_start(); //彻底删除session ...
- vs2012 设计器 视图异常
WPF 开发/(其他xaml app 的开发) 的时候 设计视图功能非常方便 不过有时候经常遇到 设计器加载失败的情况,原因很多 很多时候是代码问题导致,设计器无法展现视图,也有sliverlig ...
- ios app相互调用
被调用app配置 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NS ...
- eclipse使用Git插件
折腾了会Git,记录一下下. 1.安装Git Help-->Install New Software 点击Add,Name随意,Location为http://download.eclips ...