JavaEE集成Flex4

Flex集成J2EE
Flex,Spring2.5或更高,BlazeDS

[b]Spring BlazeDS Integration 是什么?[/b]
Spring BlazeDS Integration 是 SpringSource 的开源项目,用于整合 Spring 与 BlazeDS。

[b]为什么需要 Spring BlazeDS Integration?[/b]
不使用 Spring BlazeDS Integration 同样可以整合 Spring 与 BlazeDS。但这种整合方式不自然,需要额外维护一个 BlazeDS 配置文件,Spring BlazeDS Integration 会改善这种处境。

[b]Spring BlazeDS Integration 需要的软件环境:[/b]
Java 5 或更高
Spring 2.5.6 或更高
BlazeDS 3.2 或更高

[b]Spring BlazeDS Integration 特征[/b]
MessageBroker(BlazeDS 的核心组件)被配置为 Spring 管理的 Bean
Flex 客户端发出的 HTTP 消息通过 Spring 的 DispatcherServlet 路由给 MessageBroker
Remote objects 以 Spring 的方式配置在 Spring 配置文件内


第一步
1 需要准备spring3.0 lib文件
org.springframework.aop-3.0.2.RELEASE.jar
org.springframework.asm-3.0.2.RELEASE.jar
org.springframework.beans-3.0.2.RELEASE.jar
org.springframework.context-3.0.2.RELEASE.jar
org.springframework.core-3.0.2.RELEASE.jar
org.springframework.expression-3.0.2.RELEASE.jar
org.springframework.web.servlet-3.0.2.RELEASE.jar
org.springframework.web-3.0.2.RELEASE.jar


2 准备spring依赖包
org.aopalliance 内的 com.springsource.org.aopalliance-1.0.0.jar
edu.emory.mathcs.backport 内的 com.springsource.edu.emory.mathcs.backport-3.0.0.jar
net.sourceforge.cglib 内的 com.springsource.net.sf.cglib-2.2.0.jar


3 Spring BlazeDS Integration(Spring对于BlazeDS的支持jar文件)
org.springframework.flex-1.0.3.RELEASE.jar


第二步
修改现有web项目中的web.xml文件结构
<servlet>
<servlet-name>MyFlexApp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/web-application-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MyFlexApp</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>


第三步
配置 web-application-config.xml (将该文件修改为以下形式)
<?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-3.0.xsd
http://www.springframework.org/schema/flex
http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">

<flex:message-broker />
</beans>


第四步
定义 Bean,并用 remoting-destination tag 把它Spring的服务层暴露给Flex
<bean id="employeeServiceDest" class="com.sample.EmployeeService">
<flex:remoting-destination />
</bean>


第五步 删除多余的 Flex 配置文件
只留下service-config.xml文件
将service-config.xml 配置文件从以下格式改为
原有配置
<services>
<service-include file-path="remoting-config.xml" />
<service-include file-path="proxy-config.xml" />
<service-include file-path="messaging-config.xml" />
</services>
改为以下配置
<services>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
</services>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值