一 前期:
引用
spring-flex-1.0.1.RELEASE
Java 5 or higher
Spring 2.5.6 or higher(需要spring.jar和spring_mvc.jar)
Adobe BlazeDS 3.2 or higher (war包下的WEB-INF文件夹)
把相关jar放入WEB-INF/lib
然后添加BlazeDS到web项目中(可参考前一篇BlazeDS)
二 详细步骤(参考spring-flex-1.0.1.RELEASE 的refrence)
要点:
引用
1.springMVC拦截请求(web.xml文件)
2.配置spring的配置文件(设置拦截处理的beans),映射
3.编写并配置要映射为RemoteObject的bean
4.修改services-config.xml(重要)
1.springMVC拦截请求(web.xml文件)
这里制定了spring的配置文件为
/WEB-INF/config/web-application-config.xml
<!-- 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>/WEB-INF/config/web-application-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map all /messagbroker requests to the DispatcherServlet for handling -->
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
2.配置spring的配置文件(设置拦截处理的beans),映射
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:flex="http://www.springframework.org/schema/flex"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/flex
http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">
<!--这里有三种方法配置处理请求的flex MessageBroker-- 任意选择其中一种-->
<!--方法一 可以指定services- config.xml文件位置 -->
<bean id="_messageBroker" class="org.springframework.flex.core.MessageBrokerFactoryBean" >
<property name="servicesConfigPath"
value="classpath*:services- config.xml" />
</bean>
<!--方法二 这里需要引入一个json的包(具体我忘了),否则报错
<flex:message-broker services-config-path="classpath*:services-config.xml"/>
-->
<!--方法3 也需要引入json包,否则报错 默认在/WEB-INF/flex/services-config.xml -->
<flex:message-broker/>
-->
<!--============ mapping ============-->
<!-- Maps request paths at /* to the BlazeDS MessageBroker -->
<!--这里的_messageBroker为上面那个bean的id-->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/*=_messageBroker
</value>
</property>
</bean>
<!-- Dispatches requests mapped to a MessageBroker -->
<bean class="org.springframework.flex.servlet.MessageBrokerHandlerAdapter"/>
</beans>
3.编写并配置要映射为RemoteObject的bean
(有3种方法,可参考包自带的参考文献)
<bean id="helloWorldService" class="HelloWorld"></bean>
<flex:remoting-destination ref="helloWorldService" />
这样一个destination id为“helloWorldService”的RemoteObject就好了
4.修改services-config.xml(重要 非官方)
花了我一天时间,参考文献的也不想,后来乱使成功了
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>
还要在<services>中加入
<default-channels>
<channel ref="my-amf" />
</default-channels>
然后删掉remoting-config.xml里面上面那段,问我为什么我不知道,反正不怎么做
客户端一调用就fault(对象已拿到)但不存在channel之类的错误
最后客户端
<mx:RemoteObject id="helloRO" destination="helloWorldService" result="resultHandler(event)" fault="faultHandler(event)"/>
分享到:
相关推荐
Spring BlazeDS Integration 1.0.0
Spring BlazeDS Integration,Flex通过remoteObject与java通讯,附带例子 文档
使用flex 4.5 + Spring 3.0 + Hibernate 3.3 + Cairngorm 2.2.1 + BlazeDS 3.3.0 + Spring BlazeDS Integration 1.0.3整合出的一个登录的小demo·
Java 服务器端技术Spring BlazeDS Integration.docx,看了启示很多
NULL 博文链接:https://depravedangel.iteye.com/blog/883636
NULL 博文链接:https://madfroghe.iteye.com/blog/935337
NULL 博文链接:https://chenhuiggggg.iteye.com/blog/1994009
flex3不能直接与服务器资源进行交换,借助BlazeDS 工具达到,flex3与服务器资源进行交换的目的
详解spring BlazeDS 与 flex 集成应用,希望对各位大栳有用
Flex技术本身和Java就有很强的关联性,它提供了一个基于Eclipse的IDE和BlazeDS.BlazeDS是个基于服务端的Java远程调用和Web消息的一个开源的技术。...在2008年末,Spring社区已经着手Spring BlazeDS整合的项目。
blazeds4整合spring3 这是我新近研究的方法 与整合spring2.5以下的方法有不同了,...用remoteObject做的helloWorld。 适合新手入门和老手改用spring3来做项目。 如要交流可以加我:48724810 by焚香槟榔...2010/12/18
Flex Spring BlazeDS整个web工程,其中FlexServer是整合后的myeclipse web project工程,FlexText是Flex测试工程。在tomcat中运行测试无误。
Spring MVC+BlazeDS+Flex框架实践
flex页面源码 博文链接:https://jhaij.iteye.com/blog/832478
Spring BlazeDS Integration
spring+blazeDS+flex4整合的例子,项目可以直接运行,jar包都齐全 模拟数据库返回的list 在页面上 输出
本文档阐述了BlazeDS整合Flex示例,包括开发环境、开发依赖库、创建Java工程、Flex客户端程序
Flex+blazeDS+Spring官方Demo,环境搭建,内含十几个例子,从易到难,包括spring消息,spring安全,注解方式和非注解配置文件方式,十分好用。内含有tomcat,可直接启动并运行用户手册。