Springsource与Adobe合作发布了Spring与BlazeDS集成的项目Spring BlazeDS Integration,通过Spring BlazeDS Integration可以把Spring的Bean暴露为BlazeDS的Flex Remoting Service,这样Flex客户端就能够通过AMF调用Spring 暴露出来的Bean,有效简化BlazeDS配置及开发难度。
配置好BlazeDS的开发环境
创建com.yeeach.HelloWorldService,内容如下:
package com.yeeach;
public class HelloWorldService {
public String hello(String var1) {
return "hello " + var1;
}
public String world(String var1) {
return "world " + var1;
}
}
修改web.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Spring BlazeDS Integration Samples</display-name>
<description>Spring BlazeDS Integration Sample Application</description>
<!– Http Flex Session attribute and binding listener support –>
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
<!– The front controller of this Spring Web application, responsible for handling all application requests –>
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/applicationContext*.xml
classpath*:/applicationContext.xml
/WEB-INF/applicationContext*.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!– Map all *.spring requests to the DispatcherServlet for handling –>
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/spring/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>
修改flex/services-config.xml,内容如下
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service-include file-path="remoting-config.xml" />
<service-include file-path="proxy-config.xml" />
<default-channels>
<channel ref="my-amf"/>
</default-channels>
</services>
<channels>
<channel-definition id="my-streaming-amf" class="mx.messaging.channels.StreamingAMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/spring/messagebroker/streamingamf" class="flex.messaging.endpoints.StreamingAMFEndpoint"/>
</channel-definition>
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/spring/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>
<channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
<endpoint url="https://{server.name}:{server.port}/{context.root}/spring/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
<properties>
<add-no-cache-headers>false</add-no-cache-headers>
</properties>
</channel-definition>
<channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/spring/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>true</polling-enabled>
<polling-interval-seconds>4</polling-interval-seconds>
</properties>
</channel-definition>
<channel-definition id="my-http" class="mx.messaging.channels.HTTPChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/spring/messagebroker/http" class="flex.messaging.endpoints.HTTPEndpoint"/>
</channel-definition>
<channel-definition id="my-secure-http" class="mx.messaging.channels.SecureHTTPChannel">
<endpoint url="https://{server.name}:{server.port}/{context.root}/spring/messagebroker/httpsecure" class="flex.messaging.endpoints.SecureHTTPEndpoint"/>
<properties>
<add-no-cache-headers>false</add-no-cache-headers>
</properties>
</channel-definition>
</channels>
<logging>
<target class="flex.messaging.log.ConsoleTarget" level="info">
<properties>
<prefix>[BlazeDS] </prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>true</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>Endpoint.*</pattern>
<pattern>Service.*</pattern>
<pattern>Configuration</pattern>
</filters>
</target>
</logging>
</services-config>
修改flex/remoting-config.xml,内容如下
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
class="flex.messaging.services.RemotingService">
<adapters>
<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
</adapters>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
</service>
分享到:
相关推荐
Spring BlazeDS Integration,Flex通过remoteObject与java通讯,附带例子 文档
构建全栈式Flex、BlazeDS和Spring集成解决方案。 构建全栈式Flex、BlazeDS和Spring集成解决方案
构建全栈式Flex、BlazeDS和Spring集成解决方案–第二部分 编写to-do list服务器端.pdf
Flex、BlazeDS和Spring集成解决方案案例todolist1
构建全栈式Flex、BlazeDS和Spring集成解决方案
构建全栈式Flex、BlazeDS和Spring集成解决方案!
构建全栈式Flex、BlazeDS和Spring集成解决方案–第一部分 创建Maven Flex模块
Maven构建全栈式Flex、BlazeDS和Spring集成解决方案–第一部分_创建Maven_Flex模块
构建全栈式Flex、BlazeDS和Spring集成解决方案–第三部分 整合全部应用.pdf
Maven构建全栈式Flex、BlazeDS和Spring集成解决方案–第三部分_整合全部应用
Maven构建全栈式Flex、BlazeDS和Spring集成解决方案–第二部分_编写to-do_list服务器端
Flex blazeds-spring Flex blazeds-spring Flex blazeds-spring Flex blazeds-spring Flex blazeds-spring Flex blazeds-spring
flex blazeds spring集成。该DEMO演示FLEX如何通过SPRING控制通信。
使用flex 4.5 + Spring 3.0 + Hibernate 3.3 + Cairngorm 2.2.1 + BlazeDS 3.3.0 + Spring BlazeDS Integration 1.0.3整合出的一个登录的小demo·
与整合spring2.5以下的方法有不同了,(看过一些教程觉得不是很好,用起来不顺手) 最终参考了官方的sample,得到了这个不错的整合方法。 把要用blazeds公开给flex的java方法配置在flex-servlet.xml中 把spring整合...
前言:本讲是继【第三讲:WEB项目-集成Flex3+BlazeDS3.2+Spring2.5.6】后,介绍另外一种集成方式; 集成方式二:采用Spring侦听配置模式 目标:实现集成方式二 优点: 1、一个应用可以满足多种请求 2、易于集成...