Spring Remoting: Burlap--转
原文地址:http://www.studytrails.com/frameworks/spring/spring-remoting-burlap.jsp
Concept Overview
In the earlier tutorials we saw an introduction to Spring remoting and its support for RMI and Hessian. In this tutorial we look at another remoting protocol supported by Spring - Burlap. Burlap is an XML based protocol for web services. It has been developed by Caucho. It is similar to Hessian, the only difference being Hessian is binary and Burlap is XML. Like Hessian, Burlap needs to be hosted over HTTP. Similar to Hessian, it has a BurlapServiceExporter and a BurlapProxyFactoryBean class. Note that since Burlap is not being actively developed, its support has been deprecated since Spring 4.0.
Sample Program Overview
The sample program below is a Greeting Service and demonstrates Spring support for Burlap.
- aopalliance.jar
- commons-logging.jar
- log4j.jar
- org.springframework.aop.jar
- org.springframework.asm.jar
- org.springframework.beans.jar
- org.springframework.context.jar
- org.springframework.context.support.jar
- org.springframework.core.jar
- org.springframework.expression.jar
- org.springframework.web.jar
- org.springframework.web.servlet.jar
- hessian-3.1.5.jar
- Client sends a message call
- This message call is handled by a Burlap Proxy created by BurlapProxyFactoryBean
- The Burlap Proxy converts the call into a remote call over HTTP
- The Burlap Service Adapter created by BurlapServiceExporter intercepts the remote call over HTTP
- It forwards the method call to Service
Create the GreetingService interface as shown below.
Create a method named getGreeting() that takes a name as a parameter and returns the greeting message (see line 5 below).
1
2
3
4
5
6
|
package com.studytrails.tutorials.springremotingburlapserver; public interface GreetingService { String getGreeting(String name); } |
Create a class GreetingServiceImpl as shown below.
It implements the GreetingService interface (described earlier)
Implement the getGreeting() method by sending a greeting message (see lines 6-8 below).
1
2
3
4
5
6
7
8
9
10
|
package com.studytrails.tutorials.springremotingburlapserver; public class GreetingServiceImpl implements GreetingService{ @Override public String getGreeting(String name) { return "Hello " + name + "!" ; } } |
Create the burlap-servlet.xml file (see below).
Declare the 'greetingService' (see lines 14-15 below).
Export the 'greetingService' using Spring's BurlapServiceExporter class (see lines 17-21 below).
Note the following properties of BurlapServiceExporter class:
- service: the service class bean which shall handle the Burlap call (see line 18 below)
- serviceInterface: The interface to be used by Spring to create proxies for Burlap (see line 19 below)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<? xml version = "1.0" encoding = "UTF-8" ?> xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc = "http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/mvc < bean id = "greetingService" class = "com.studytrails.tutorials.springremotingburlapserver.GreetingServiceImpl" /> < bean name = "/greetingService.http" class = "org.springframework.remoting.caucho.BurlapServiceExporter" > < property name = "service" ref = "greetingService" /> < property name = "serviceInterface" value = "com.studytrails.tutorials.springremotingburlapserver.GreetingService" /> </ bean > </ beans > |
Create the web.xml file (see below).
Create the servlet mapping for the url pattern '*.http' (see line 16 below) for Spring's DispatcherServlet (see line 10 below)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" < web-app > < display-name >Spring Remoting: Burlap Server</ display-name > < servlet > < servlet-name >burlap</ servlet-name > < servlet-class >org.springframework.web.servlet.DispatcherServlet</ servlet-class > < load-on-startup >1</ load-on-startup > </ servlet > < servlet-mapping > < servlet-name >burlap</ servlet-name > < url-pattern >*.http</ url-pattern > </ servlet-mapping > </ web-app > |
Create the GreetingService interface as shown below.
Copy the GreetingService interface created for Burlap Server (described above) and paste it in Burlap Client source code while retaining the java package structure.
Note: For reference, the source code is shown below.
1
2
3
4
5
6
|
package com.studytrails.tutorials.springremotingburlapserver; public interface GreetingService { String getGreeting(String name); } |
Create a class TestSpringRemotingBurlap shown below to test Spring Burlap Remoting.
Load spring configuration file (see line 11 below)
Get a reference to GreetingService using the bean name 'greetingService' (see line 12 below)
Call the GreetingService.getGreting() method by passing the name 'Alpha' (see line 13 below)
Print the greeting message (see line 14 below).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
package com.studytrails.tutorials.springremotingburlapclient; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.studytrails.tutorials.springremotingburlapserver.GreetingService; public class TestSpringRemotingBurlap { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext( "spring-config-client.xml" ); GreetingService greetingService = (GreetingService)context.getBean( "greetingService" ); String greetingMessage = greetingService.getGreeting( "Alpha" ); System.out.println( "The greeting message is : " + greetingMessage); } } |
Create the spring-config-client.xml file (see below).
Declare the 'greetingService' using Spring's BurlapProxyFactoryBean class (see lines 13-16 below).
Note the following properties of BurlapProxyFactoryBean class:
- serviceUrl : refers the URL of the remote service (see line 14 below).
Note URL part 'greetingService' corresponds to bean name property of BurlapServiceExporter bean defined in burlap-servlet.xml (defined earlier) - serviceInterface: The interface to be used by Spring to create proxies for Burlap (see line 15 below)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<? xml version = "1.0" encoding = "UTF-8" ?> xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:aop = "http://www.springframework.org/schema/aop" xsi:schemaLocation=" < bean id = "greetingService" class = "org.springframework.remoting.caucho.BurlapProxyFactoryBean" > < property name = "serviceUrl" value = "http://localhost:8080/springremotingburlapserver/greetingService.http" /> < property name = "serviceInterface" value = "com.studytrails.tutorials.springremotingburlapserver.GreetingService" /> </ bean > </ beans > |
This sample program has been packaged as a jar installer which will copy the source code (along with all necessary dependencies)on your machine and automatically run the program for you as shown in the steps below. To run the sampleprogram, you only need Java Runtime Environment (JRE) on your machine and nothing else.
- Save the springremotingburlapserver-installer.jar on your machine
- Execute/Run the jar using Java Runtime Environment
(Alternatively you can go the folder containing the springremotingburlapserver-installer.jar and execute the jar using java -jar springremotingburlapserver-installer.jar command)
- You will see a wizard page as shown below
- Enter the location of the directory where you want the program to install and run (say, C:\Temp)
- The installer will copy the program on your machine and automatically execute it. The expected output indicating that the program has run successfully on your machine is shown in the image below.
This shows that the Burlap Server program has run successfully on your machine
This sample program has been packaged as a jar installer which will copy the source code (along with all necessary dependencies)on your machine and automatically run the program for you as shown in the steps below. To run the sampleprogram, you only need Java Runtime Environment (JRE) on your machine and nothing else.
- Save the springremotingburlapclient-installer.jar on your machine
- Execute/Run the jar using Java Runtime Environment
(Alternatively you can go the folder containing the springremotingburlapclient-installer.jar and execute the jar using java -jar springremotingburlapclient-installer.jar command)
- You will see a wizard page as shown below
- Enter the location of the directory where you want the program to install and run (say, C:\Temp)
- The installer will copy the program on your machine and automatically execute it. The expected output indicating that the program has run successfully on your machine is shown in the image below.
This shows that the Burlap Client program has run successfully on your machine
This source code for this program is downloaded in the folder specified by you (say, C:\Temp) as an eclipse project called springremotingburlapserver . All the required libraries have also been downloaded and placed in the same location. You can open this project from Eclipe IDE and directly browse the source code. See below for details of the project structure.
The WAR file for this example is available as springremotingburlapserver.war in the download folder specified by you earlier (e.g. C:\Temp). The path for the WAR file is <DOWNLOAD_FOLDER_PATH>/springremotingburlapserver/dist/springremotingburlapserver.war.
This WAR file can be deployed in any webserver of your choice and example can be executed.
This source code for this program is downloaded in the folder specified by you (say, C:\Temp) as an eclipse project called springremotingburlapclient . All the required libraries have also been downloaded and placed in the same location. You can open this project from Eclipe IDE and directly browse the source code. See below for details of the project structure.
Spring Remoting: Burlap--转的更多相关文章
- Spring Remoting: Remote Method Invocation (RMI)--转
原文地址:http://www.studytrails.com/frameworks/spring/spring-remoting-rmi.jsp Concept Overview Spring pr ...
- Spring Remoting: HTTP Invoker--转
原文地址:http://www.studytrails.com/frameworks/spring/spring-remoting-http-invoker.jsp Concept Overview ...
- Lingo (Spring Remoting) : Passing client credentials to the server
http://www.jroller.com/sjivan/entry/lingo_spring_remoting_passing_client Lingo (Spring Remoting) : P ...
- Spring Remoting: Hessian--转
原文地址:http://www.studytrails.com/frameworks/spring/spring-remoting-hessian.jsp Concept Overview The p ...
- Asynchronous calls and remote callbacks using Lingo Spring Remoting
http://www.jroller.com/sjivan/entry/asynchronous_calls_and_callbacks_using Asynchronous calls and re ...
- Spring Remoting by HTTP Invoker Example--reference
Spring provides its own implementation of remoting service known as HttpInvoker. It can be used for ...
- spring remoting源码分析--Hessian分析
1. Caucho 1.1 概况 spring-remoting代码的情况如下: 本节近分析caucho模块. 1.2 分类 其中以hession为例,Hessian远程服务调用过程: Hessian ...
- Spring Remoting: Hessian
- spring源码分析之spring-web remoting模块概况及基本概念
spring-web总体分为三部分:caucho.httpinvoker.jaxws,其总体构造图如下: uml结构: 先看看网上搜索到的上述实现的原理吧:Spring RMI,Hessian/Bur ...
随机推荐
- 纯css制作带三角border篇(兼容所有浏览器)
今天帅哥给你们介绍下,如何用 border 来制作三角. html 代码如下: 复制代码 代码如下: <div class="arrow-up"></div> ...
- spark spark ziliao important
http://book.51cto.com/art/201408/448416.htm 一.如何实现多台机器的ssh无密码登录 当我们在配置多台计算,使之可以相互使用无密码登录-ssh,之前都是一台一 ...
- 谈一谈PHP的代码重构
随着 PHP 从一种简单的脚本语言转变为一种成熟的编程语言,一个典型的 PHP 应用程序的代码库的复杂性也随之增大.为了控制对这些应用程序的支持和维护,我们可以使用各种测试工具来自动化该流程.其中一种 ...
- 用DOS批处理实现FTP自动上传、下载、清理文件
用DOS批处理实现FTP自动上传.下载.清理文件 最近好像特别的忙,好久没来写点东西了,今天写了一个利用批处理程序完成FTP自动上传.下载.清理文件的程序.赶紧 记录下来,以备日后之用.功能介绍:自动 ...
- RPM -U 升级机制探索
今天被RPM升级机制狠狠的阴了一把,差点没过来,趁着热乎赶紧记录下来,已被后用. RPM包有升级机制(Upgrade), 使用-U 参数.这点我之前略有耳闻,知道的并不详细. 先说说案例:半年前我们r ...
- mysql-5.7.15-winx64免安装版配置
1.拷到硬盘根目录下; 2.在 bin 平行目录下新建 data 文件夹: 3. 修改 my-default.ini 文件,添加 basedir = C:\mysql-5.7.15-winx64d ...
- View 以Diaglog 方式展示
OutAdmissionBookingEditor admissionBookingEditor = this.LayoutManager.OpenDialog<OutAdmissionBook ...
- OpenCV仿射变换+投射变换+单应性矩阵
本来想用单应性求解小规模运动的物体的位移,但是后来发现即使是很微小的位移也会带来超级大的误差甚至错误求解,看起来这个方法各种行不通,还是要匹配知道深度了以后才能从三维仿射变换来入手了,纠结~ esti ...
- Android SDK镜像的介绍使用
由于一些原因,Google相关很多服务都无法访问,所以在很多时候我们SDK也无法升级,当然通过技术手段肯定可以解决,但是比较麻烦,而且下载速度也不怎么样. 这里笔者介绍一个国内的Android镜像站, ...
- js中“==”与"==="的区别
首先,== equality 等同,=== identity 恒等. ==, 两边值类型不同的时候,要先进行类型转换,再比较. ===,不做类型转换,类型不同的一定不等. 一言以蔽之:==先转换类型再 ...