构建全栈式 Flex、BlazeDS 和 Spring 集成解决方案
金庸 Ematrix http://blog.csdn.net/ematrix001
构建全栈式 Flex、BlazeDS 和 Spring 集成解决方案
2
构建全栈式 Flex、BlazeDS 和 Spring 集成解决方案
第三部分 整合全部应用
在第一部分和第二部分中,我讲解了如何使用 Spring, Hibernate 和 MySQL 创建服
务器端,以及如何创建简单的 Flex UI 客户端。在这一部分中,我们将编写最终的 Flex
用户界面并通过 BlazeDS 使之与后端 Spring 进行连接,从而完成所有部分的整合。
环境需求:
Flex Builder 3
Try
Buy
BlazeDS
Download
Spring
Download
Sample files:
todolist3.zip (ZIP, 68K)
技术基础:
如果你之前使用 Flex Builder 创建过应用,那将会有一定帮助作用,但不是必须的。
最好有使用 BlazeDS 的经验。
构建全栈式 Flex、BlazeDS 和 Spring 集成解决方案
3
创建用于共享配置文件的模块
该小节所做在于避免重复拷贝配置文件。首先,我们在 todolist 下创建一个新的模
块 todolist-config,该模块用来包含配置文件 services-config.xml 和
remoting-config.xml,以后该模块将被作为资源文件打包成 zip 格式包含到 todolist-ria
和 todolist-web 两个模块。
打开 cmd,定位到 todolist 目录,运行以下命令:
进入 todolist-config 目录,删除其中 src/main/java 和 src/test。然后创建目录
src/main/resources,并在其中创建 services-config.xml,代码如下:
mvn archetype:create -DgroupId=org.epseelon.samples -DartifactId=todolist-config
构建全栈式 Flex、BlazeDS 和 Spring 集成解决方案
4
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service-include file-path="remoting-config.xml" />
</services>
<!-- Spring factory registration -->
<factories>
<factory id="spring"
class="org.epseelon.samples.todolist.controller.SpringFactory" />
</factories>
<channels>
<channel-definition id="channel-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>
</channels>
<logging>
<target class="flex.messaging.log.ConsoleTarget"
level="Error">
<properties>
<prefix>[BlazeDS]</prefix>
<includeDate>true</includeDate>
<includeTime>false</includeTime>
<includeLevel>true</includeLevel>
<includeCategory>true</includeCategory>
</properties>
<filters>
<pattern>Endpoint.*</pattern>
<pattern>Service.*</pattern>
<pattern>Message.*</pattern>
<pattern>DataService.*</pattern>
<pattern>Configuration</pattern>
</filters>
</target>
</logging>
<system>
<redeploy>
<enabled>true</enabled>
<watch-interval>20</watch-interval>
<watch-file>
{context.root}/WEB-INF/flex/services-config.xml
</watch-file>
构建全栈式 Flex、BlazeDS 和 Spring 集成解决方案
5
仍然在同一个目录 src/main/resources 中,创建 remoting-config.xml,包含如下代码:
编辑 todolist-config/pom.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="channel-amf" />
</default-channels>
<destination id="todoService">
<properties>
<factory>spring</factory>
<source>todoService</source>
</properties>
</destination>
</service>
<watch-file>
{context.root}/WEB-INF/flex/remoting-config.xml
</watch-file>
<touch-file>{context.root}/WEB-INF/web.xml</touch-file>
</redeploy>
</system>
</services-config>
- 1
- 2
- 3
前往页