Spring Remoting: Burlap--转
2016-05-11 09:44
411 查看
原文地址:http://www.studytrails.com/frameworks/spring/spring-remoting-burlap.jsp
Required Libraries
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
Interaction Flow
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
Burlap Server Code Package Structure
Burlap Server Source Code
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).
GreetingService.java
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).
GreetingServiceImpl.java
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)
burlap-servlet.xml
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)
web.xml
Burlap Client Code Package Structure
Burlap Client Source Code
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.
GreetingService.java
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).
TestSpringRemotingBurlap.java
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)
spring-config-client.xml
Running Sample Program
Burlap Server Sample Program
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.
Download And Automatically Run Burlap Server Sample Program
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
Burlap Client Sample Program
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.
Download And Automatically Run Burlap Client Sample Program
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
Browsing the Program
Burlap Server Sample Code
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.
Redeploying this sample program in a different web server
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.
Burlap Client Sample Code
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.
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.Required Libraries
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
Interaction Flow
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
Burlap Server Code Package Structure
Burlap Server Source Code
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).
It implements the GreetingService interface (described earlier)
Implement the getGreeting() method by sending a greeting message (see lines 6-8 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)
Create the servlet mapping for the url pattern '*.http' (see line 16 below) for Spring's DispatcherServlet (see line 10 below)
Burlap Client Source Code
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.
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).
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)
Burlap Server Sample Program
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.
Download And Automatically Run Burlap Server Sample Program
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
Burlap Client Sample Program
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.
Download And Automatically Run Burlap Client Sample Program
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
Browsing the Program
Burlap Server Sample Code
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.
Redeploying this sample program in a different web server
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.
Burlap Client Sample Code
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.
相关文章推荐
- Java泛型-类型擦除
- Spring Remoting: Hessian--转
- java命令
- java Collections集合工具类
- 64位win7环境eclipse集成svn后出现Failed to load JavaHL Library的解决办法
- springmvc的handle method 方法
- 一个刚入门的菜鸟Java之路-框架篇
- 使用JDK的native2ascii转码
- DOCTYPE声明 struts2与struts1区别
- Java unicode中文编码转换和反转
- eclipse下使用java api 进行hbase的常用的操作所需的jar包,以及如何查看java build path下的jar是否使用
- cloudsim仿真算法研究之二
- java socket编程
- Java中的抽象类和接口
- java经典编程300例
- Java垃圾回收机制
- spring 下载地址
- Flex3与java BlazeDS入门教程及其配置详解
- Yale CAS 安装配置过程指导书
- Andrdoid中对应用程序的行为拦截实现方式之----从Java层进行拦截