1. 什么是BlazeDS? 简单的说,BlazeDS是一种服务端使用java进行web通信的技术,其可以使开发人员方便地连接到后端分布式数据,推送数据到Flex或AIR应用,为RIA(rich Internet application)提供更好的体验。 很多的RIA(rich Internet application)应用需要更好的数据连接、通信模式。BlazeDS中的远程调用,可以重用服务端已有的java代码,通过配置实现Flash客户端和服务端的Java方法通信。并且,使用AMF(active message format)二进制通信格式,提高了执行效率,比以往的基于文本格式(如:XML、SOAP)的快了10倍。 BlazeDS的具体功能,可以查看Adobe的wiki: http://opensource.adobe.com/wiki/display/blazeds/Features blazeDS下载 2. 什么是Spring BlazeDS Integration? 简单的理解,就是把spring的bean暴露成BlazeDS服务。 在Spring BlazeDS Integration之前,BlazeDS要访问spring的bean,得自己写代码。 通过Spring BlazeDS Integration,当Flash来访问服务端时,spring会把请求转发给Flex message broker。同时,我们把spring中的一些bean暴露成Flex remoting service,那么Flash就能调用到spring中暴露成Flex remoting service的bean。很像spring暴露Hessian。 Spring BlazeDS Integration下载 3. 运行Spring BlazeDS Integration的要求 Java 5 或以上 Spring 2.5 或以上 Adobe BlazeDS 3.2 或以上 4. 如何配置(极大部分参考spring官方文档) a. 首先,我们得配置Spring DispatcherServlet。这个类在spring-webmvc.jar中。 在web.xml文件中,加入如下servlet:
Spring MVC Dispatcher Servlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
/WEB-INF/config/web-application-config.xml
1
我们将把spring bean配置在web-application-config.xml文件里面。 b.接着,我们得把MessageBroker 配置到spring里面。如下:
MessageBrokerFactoryBean在Spring WebApplicationContext中必须声明成一个bean,上面的是最简单的形式。 MessageBrokerFactoryBean将会去寻找BlazeDS的配置文件(默认位置为/WEB-INF/flex/services-config.xml),当然我们可以用servicesConfigPath这个属性去重置这个值,如:
c. 把请求映射到MessageBroker。 在web.xml文件中,加入如下配置。所有messagebroker下的请求都会被映射。
Spring MVC Dispatcher Servlet
/messagebroker/*
在web-application-config.xml中,加入:
/*=mySpringManagedMessageBroker
而在spring中,HandlerMapping通过MessageBrokerHandlerAdapter把请求映射到Spring-managed MessageBroker。 注意:在BlazeDS配置文件services-config.xml中,配置的url不能错,下面就有messagebroker。
false
具体关于BlazeDS的配置,可以看BlazeDS documentation(http://livedocs.adobe.com/blazeds/1/blazeds_devguide/)。 d. 暴露spring bean为Flex remoting。 配置remoting-config.xml,这个文件的位置可以在services-config.xml中配置。 如:
……
……
remoting-config.xml的最简单配置如下:
(注意:在未来的Spring BlazeDS Integration版中,将不会用到remoting-config.xml这个配置文件。) 使用FlexRemotingServiceExporter 现在假设我们有一个bean
要暴露成Flex remoting。 则可以这样做:
这里的id,将会默认被作为Flex remoting destination的id,所以在Flash客户端中调用时,假如没有被重置,那么得用spring bean的id的值来作为Flash调用时的 destination的值。 5. 上面就是整个服务器端的配置。附件里面是一个非常简单的demo,包括Flex项目和java web项目(web项目没有jar包,得自己导入)。 spring_bladeds_jboss spring_bladeds_flex
spring blazeDS Integration简单介绍
最新推荐文章于 2024-08-04 22:13:06 发布