Spring中HttpInvoker远程方法调用总结
Spring为各种远程訪问技术的集成提供了工具类。Spring远程支持是由普通(Spring)POJO实现的,这使得开发具有远程訪问功能的服务变得相当easy。
眼下,Spring支持四种远程技术:
- 远程方法调用(RMI)。
通过使用 RmiProxyFactoryBean 和 RmiServiceExporter。Spring同一时候支持传统的RMI(使用java.rmi.Remote接口和java.rmi.RemoteException)和通过RMI调用器实现的透明远程调用(支持不论什么Java接口)。
- Spring的HTTP调用器。Spring提供了一种特殊的同意通过HTTP进行Java串行化的远程调用策略。支持随意Java接口(就像RMI调用器)。相相应的支持类是 HttpInvokerProxyFactoryBean和 HttpInvokerServiceExporter。
- Hessian。
通过 HessianProxyFactoryBean 和 HessianServiceExporter。能够使用Caucho提供的基于HTTP的轻量级二进制协议来透明地暴露服务。
- Burlap。 Burlap是Caucho的另外一个子项目,能够作为Hessian基于XML的替代方案。Spring提供了诸如 BurlapProxyFactoryBean 和 BurlapServiceExporter 的支持类。
- JAX RPC。
Spring通过JAX-RPC为远程Web服务提供支持。
- JMS(待实现)。
public interface IRemoteService {
public void startRmote();
}
RemoteServiceImpl.java
public class RemoteServiceImpl implements IRemoteService {
@Override
public void startRmote() {
// TODO Auto-generated method stub
System.out.println("this is remote --------------------------------");
}
}
2、在web.xml下建立一个testRemote-servlet.xml文件。
配置暴露给client的接口实现类信息
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans> <bean name="remote" class="com.frame.rmote.RemoteServiceImpl" />
<bean name="/remoteservice"
class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service" ref="remote" />
<property name="serviceInterface" value="com.frame.rmote.IRemoteService" />
</bean> </beans>
<servlet>
<servlet-name>testRemote</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>testRemote</servlet-name>
<url-pattern>/testRemoting/*</url-pattern>
</servlet-mapping>
服务端配置完成
public interface IRemoteService {
public void startRmote();
}
2、在applicationContext.xml中配置调用服务端的接口
<bean id="iRemoteTest"
class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://localhost:8080/Frame/testRemoting/remoteservice" />
<property name="serviceInterface" value="mf.newrise.test.IRemoteService" />
</bean>
public class TestRemote {
public static void main(String[] args) {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
IRemoteService service = (IRemoteService) applicationContext.getBean("iRemoteTest")
service.startRemote();
}
}
Spring中HttpInvoker远程方法调用总结的更多相关文章
- Java学习之路-Spring的HttpInvoker学习
Hessian和Burlap都是基于HTTP的,他们都解决了RMI所头疼的防火墙渗透问题.但当传递过来的RPC消息中包含序列化对象时,RMI就完胜Hessian和Burlap了. 因为Hessian和 ...
- Velocity初探小结--Velocity在spring中的配置和使用
最近正在做的项目前端使用了Velocity进行View层的数据渲染,之前没有接触过,草草过了一遍,就上手开始写,现在又回头细致的看了一遍,做个笔记. velocity是一种基于java的模板引擎技术, ...
- Spring中Bean的作用域、生命周期
Bean的作用域.生命周期 Bean的作用域 Spring 3中为Bean定义了5中作用域,分别为singleton(单例).protot ...
- Spring中Bean的实例化
Spring中Bean的实例化 在介绍Bean的三种实例化的方式之前,我们首先需要介绍一下什么是Bean,以及Bean的配置方式. 如果 ...
- 模拟实现Spring中的注解装配
本文原创,地址为http://www.cnblogs.com/fengzheng/p/5037359.html 在Spring中,XML文件中的bean配置是实现Spring IOC的核心配置文件,在 ...
- Spring中常见的bean创建异常
Spring中常见的bean创建异常 1. 概述 本次我们将讨论在spring中BeanFactory创建bean实例时经常遇到的异常 org.springframework.beans.fa ...
- Spring中配置数据源的4种形式
不管采用何种持久化技术,都需要定义数据源.Spring中提供了4种不同形式的数据源配置方式: spring自带的数据源(DriverManagerDataSource),DBCP数据源,C3P0数据源 ...
- spring中InitializingBean接口使用理解
InitializingBean接口为bean提供了初始化方法的方式,它只包括afterPropertiesSet方法,凡是继承该接口的类,在初始化bean的时候会执行该方法. 测试程序如下: imp ...
- Quartz 在 Spring 中如何动态配置时间--转
原文地址:http://www.iteye.com/topic/399980 在项目中有一个需求,需要灵活配置调度任务时间,并能自由启动或停止调度. 有关调度的实现我就第一就想到了Quartz这个开源 ...
随机推荐
- websphere中的会话超时设置 和 web应用中web.xml中session-timeout关系
Tomcat默认的会话的超时时间设置 设置Tomcat session有效期的三种方式有: 1.在tomcat/conf/web.xml中修改session-timeout的值,该设置是TOMCAT全 ...
- js重置form表单
CreateTime--2017年7月19日10:37:11Author:Marydon js重置form表单 需要使用的方法:reset() 示例: HTML部分 <form id=&qu ...
- python处理xls、xlsx格式excle
一.windows下读取xls格式文件,所需模块xlrd.xlw 1.下载安装包 xlrd地址:https://pypi.org/project/xlrd/#files xlwt地址:https:// ...
- oracle将一个表中字段的值赋值到另一个表中字段(批量)
面积表中数据错误,现将面积表中的sfmj字段的值改为居民信息表中匹配字段的值 update (select s.name name1,s2.name name2 from simple s,simpl ...
- RPM卸载
安全地卸载 rpm卸载软件包,并不是简单地将原来安装的文件逐个删除,那样做的话,可能会出现这样或那样的问题.如,a软件包依靠b软件包做某些工作,若b软件包卸载了,则a软件包就不能正常运行了.rpm为用 ...
- git团队协作流程
创建项目,在github上增加一个repository,在要提交的工程目录下打开git bash,执行git init 命令,用于初始化,可使用git status 查看git状态,然后使用git a ...
- Lintcode---线段树查询(区间最大值)
对于一个有n个数的整数数组,在对应的线段树中, 根节点所代表的区间为0-n-1, 每个节点有一个额外的属性max,值为该节点所代表的数组区间start到end内的最大值. 为SegmentTree设计 ...
- spine findBone
spBone* bone=skeletonAnimationNode->findBone("boneName"); CCPoint boneWorldPos=ccp(bone ...
- Java并发编程(一):并发与高并发等基础概念
并发概念 同时拥有两个或者多个线程,如果程序在单核处理器上运行,多个线程将交替地换入或者换出内存,这些线程是同时存在的,每个线程都处于执行过程中的某个状态.如果运行在多核处理器上,程序中的每个线程都将 ...
- Atitit.故障排除系列---NoClassDefFoundError NoClassDefFoundError ClassNotFoundException
Atitit.故障排除系列---NoClassDefFoundError NoClassDefFoundError ClassNotFoundException 1. java.lang.Class ...