构建flex+spring+blazeds+hibernate应用

构建flex+spring+blazeds+hibernate应用

一、建立blazeds工程
1、将blazeds.war解压到某目录,例如:myflex/;
2、建立java工程,工程名例如:MyFlex,在导向中选择 create project from existing source 并在 路径中选择 myflex/WEB-INF
3、在下一步中,将Default output folder的内容指向classes目录(MyFlex/classes)即可。

二、引入spring支持文件
1、解压flex-spring.zip
2、将/flex-spring/factory/bin/flex/samples/factories 目录下的class文件拷贝到/WEB-INF/classes/flex/samples/factories目录中
3、在/WEB-INF/flex/services-config.xml文件中注册spring factory
<factories>
<factory id="spring" class="flex.samples.factories.SpringFactory"/>
</factories>

三、应用
1、配置web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>
</listener>

2、在/WEB-INF/applicationContext.xml文件中注册spring bean;
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
<property name="url" value=" jdbc:hsqldb:hsql://localhost:9002/flexdemodb"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
<bean id="productdao" class="flex.samples.spring.store.SimpleProductDAO">
<property name="dataSource" ref="dataSource"/>
</bean>
3、配置flex remoting destination
(1)打开/WEB-INF/flex/remoting-config.xml文件
(2)添加服务的destination,例如:
<destination id="tutorial-product">
<properties>
<factory>spring</factory>
<source>productdao</source>
</properties>
</destination>
4、flex调用
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:RemoteObject id="ro" destination="tutorial-product"/>
<mx:DataGrid dataProvider="{ro.getProducts.lastResult}" width="523" height="184"/>
<mx:Button label="get data" click="ro.getProducts()" x="169" y="235"/>
</mx:Application>

你可能感兴趣的:(spring,xml,Hibernate,Web,Flex)