以前在项目中使用Flex+spring+hibernate+mysql+blaze DS作为系统框架,今天抽时间把这个框架的搭建步骤做一个说明,以便下次开发使用。
开发工具使用的eclipse +flashbuider插件版本,具体的安装方法,请参照我另一篇文章,flex+java环境搭建.
开发环境和项目创建好之后,就开始整合spring和flex。
首先,在web.xml中加上flex session的监听器
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
<? xml version = "1.0" encoding = "UTF-8" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> < web-app >
< display-name >xxx</ display-name >
< description >xxx</ description >
< context-param >
< param-name >webAppRootKey</ param-name >
< param-value >webapp.xxx</ param-value >
</ context-param >
< context-param >
< param-name >log4jConfigLocation</ param-name >
< param-value >classpath:log4j.properties</ param-value >
</ context-param >
<!-- Http Flex Session attribute and binding listener support -->
< listener >
< listener-class >flex.messaging.HttpFlexSession</ listener-class >
</ listener >
< listener >
< listener-class >org.springframework.web.util.Log4jConfigListener</ listener-class >
</ listener >
< servlet >
< servlet-name >MessageBrokerServlet</ servlet-name >
< servlet-class >org.springframework.web.servlet.DispatcherServlet</ servlet-class >
< init-param >
< param-name >contextConfigLocation</ param-name >
< param-value >/WEB-INF/applicationContext.xml</ param-value >
</ init-param >
< load-on-startup >1</ load-on-startup >
</ servlet >
<!-- MessageBroker Servlet
<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<display-name>MessageBrokerServlet</display-name>
<servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
-->
< servlet >
< servlet-name >RDSDispatchServlet</ servlet-name >
< display-name >RDSDispatchServlet</ display-name >
< servlet-class >flex.rds.server.servlet.FrontEndServlet</ servlet-class >
< init-param >
< param-name >useAppserverSecurity</ param-name >
< param-value >false</ param-value >
</ init-param >
< init-param >
< param-name >messageBrokerId</ param-name >
< param-value >_messageBroker</ param-value >
</ init-param >
< load-on-startup >10</ load-on-startup >
</ servlet >
< servlet-mapping id = "RDS_DISPATCH_MAPPING" >
< servlet-name >RDSDispatchServlet</ servlet-name >
< url-pattern >/CFIDE/main/ide.cfm</ url-pattern >
</ servlet-mapping >
< servlet-mapping >
< servlet-name >MessageBrokerServlet</ servlet-name >
< url-pattern >/messagebroker/*</ url-pattern >
</ servlet-mapping >
< welcome-file-list >
< welcome-file >login.html</ welcome-file >
< welcome-file >login.htm</ welcome-file >
</ welcome-file-list >
< mime-mapping >
< extension >doc</ extension >
< mime-type >application/msword</ mime-type >
</ mime-mapping >
< mime-mapping >
< extension >xls</ extension >
< mime-type >application/msexcel</ mime-type >
</ mime-mapping >
< mime-mapping >
< extension >pdf</ extension >
< mime-type >application/pdf</ mime-type >
</ mime-mapping >
< mime-mapping >
< extension >zip</ extension >
< mime-type >application/zip</ mime-type >
</ mime-mapping >
< mime-mapping >
< extension >rar</ extension >
< mime-type >application/rar</ mime-type >
</ mime-mapping >
< mime-mapping >
< extension >txt</ extension >
< mime-type >application/txt</ mime-type >
</ mime-mapping >
< mime-mapping >
< extension >chm</ extension >
< mime-type >application/mshelp</ mime-type >
</ mime-mapping >
< mime-mapping >
< extension >mp3</ extension >
< mime-type >audio/x-mpeg</ mime-type >
</ mime-mapping >
<!-- for WebSphere deployment, please uncomment -->
<!--
<resource-ref>
<description>Flex Messaging WorkManager</description>
<res-ref-name>wm/MessagingWorkManager</res-ref-name>
<res-type>com.ibm.websphere.asynchbeans.WorkManager</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
-->
</ web-app >
|
整个web.xml文件内容如上,可以直接使用,里面具体内容不做描述,如有不明白地方,可以直接百度。
下面是spring的applicationContext.xml配置文件,包含数据库的配置,事物的配置,直接贴出整个文件源码。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
<? xml version = "1.0" encoding = "UTF-8" ?>
< beans xmlns = "http://www.springframework.org/schema/beans" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:context = "http://www.springframework.org/schema/context"
xmlns:aop = "http://www.springframework.org/schema/aop"
xmlns:tx = "http://www.springframework.org/schema/tx"
xmlns:flex = "http://www.springframework.org/schema/flex"
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
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
< context:annotation-config />
< context:component-scan base-package = "cn.ccb.yn.acms" />
< flex:message-broker >
< flex:exception-translator ref = "flexExcetiionTranslator" />
< flex:message-service default-channels = "my-amf" />
</ flex:message-broker >
< bean id = "flexExcetiionTranslator" class = "cn.wgy.common.util.FlexExcetiionTranslator" />
< bean id = "AppDataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method = "close" >
< property name = "driverClass" value = "${jdbc.driverClassName}" />
< property name = "jdbcUrl" value = "${jdbc.url}" />
< property name = "user" value = "${jdbc.username}" />
< property name = "password" value = "${jdbc.password}" />
< property name = "minPoolSize" value = "1" />
< property name = "maxPoolSize" value = "25" />
< property name = "maxIdleTime" value = "180" />
</ bean >
< context:property-placeholder location = "classpath:jdbc.properties" />
<!-- 读取数据库配置文件结束 -->
< bean id = "transactionManager"
class = "org.springframework.orm.hibernate3.HibernateTransactionManager" >
< property name = "sessionFactory" >
< ref bean = "sessionFactory" />
</ property >
< property name = "nestedTransactionAllowed" value = "true" ></ property >
</ bean >
< aop:config >
< aop:advisor id = "managerTx" pointcut = "execution(* cn.wgy..*.ucc.*.*(..))"
advice-ref = "txAdvice" order = "2" />
</ aop:config >
< tx:advice id = "txAdvice" transaction-manager = "transactionManager" >
< tx:attributes >
< tx:method name = "get*" read-only = "true" />
< tx:method name = "find*" read-only = "true" />
< tx:method name = "*" rollback-for = "BizException" />
</ tx:attributes >
</ tx:advice >
< bean id = "jdbcTemplate" class = "org.springframework.jdbc.core.JdbcTemplate" >
< property name = "dataSource" >
< ref bean = "AppDataSource" />
</ property >
</ bean >
< bean id = "hibernateTemplate" class = "org.springframework.orm.hibernate3.HibernateTemplate" >
< property name = "sessionFactory" >
< ref bean = "sessionFactory" />
</ property >
</ bean >
< bean id = "sessionFactory" name = "sessionFactory"
class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean"
abstract = "false" >
< property name = "mappingDirectoryLocations" >
< list >
< value >classpath:/cn/wgy/common/model/</ value >
</ list >
</ property >
< property name = "hibernateProperties" >
< props >
< prop key = "hibernate.dialect" >org.hibernate.dialect.MySQLDialect</ prop >
< prop key = "hibernate.show_sql" >true</ prop >
< prop key = "hibernate.generate_statistics" >true</ prop >
< prop key = "hibernate.cache.provider_class" >org.hibernate.cache.EhCacheProvider</ prop >
< prop key = "hibernate.cache.use_query_cache" >true</ prop >
< prop key = "hibernate.query.factory_class" >org.hibernate.hql.classic.ClassicQueryTranslatorFactory</ prop >
< prop key = "hibernate.hbm2ddl.auto" >update</ prop >
</ props >
</ property >
< property name = "eventListeners" >
< map >
< entry key = "merge" >
< bean class = "org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" abstract = "false" />
</ entry >
</ map >
</ property >
< property name = "dataSource" >
< ref bean = "AppDataSource" />
</ property >
</ bean >
</ beans >
|
数据库连接配置文件:
1
2
3
4
5
6
7
8
9
|
jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://127.0.0.1:3306/acms?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull jdbc.username=root jdbc.password=ROOT # DBCP Pool settings jdbc.InitialSize=5 jdbc.MaxActive=10 jdbc.MaxIdle=5 jdbc.MaxWait=30000 |
java给flex提供接口类的写法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
package cn.wgy.test.ucc.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;
import cn.ccb.yn.acms.test.service.TestService;
import cn.ccb.yn.acms.test.ucc.TestUcc;
@Service @RemotingDestination public class TestUccImpl implements TestUcc{
@Autowired TestService testServiceImpl; public String getTest(){
return testServiceImpl.getTest();
} } |
TestUccImpl就是flex页面用到的接口。转自IT家园
相关推荐
5. "快速搭建Spring BlazeDS Integration框架环境" 和 "搭建BlazeDs的几点注意事项" 都是关于如何快速启动和配置BlazeDS与Spring集成环境的指南,这些文章可能会涵盖从安装到调试的整个流程,并给出了一些常见问题的...
5. **可扩展性强**:易于与其他 Java 技术集成,如 Spring、Hibernate 等。 #### 三、环境搭建步骤 1. **准备开发工具**: - 安装 Eclipse 或 MyEclipse。 - 安装 Flex SDK 和 BlazeDS。 - 配置 MySQL 数据库。...
Spring框架可以用于管理Java的bean,提供依赖注入,而Hibernate或MyBatis则可以作为持久层框架,简化与MySQL数据库的交互。 4. **MySQL**:MySQL是一款广泛使用的开源关系型数据库管理系统,因其高效、稳定和易用性...
标题 "快速搭建基于BlazeDS的FLEX+JAVA WEB应用" 涉及到的是一个技术教程,旨在指导用户如何构建一个使用Adobe Flex前端和Java后端的Web应用程序,其中BlazeDS作为数据通信的中间件。这个过程涉及到多个关键知识点,...
通过LCDS,Java应用程序可以向Flex前端提供服务,如EJB(Enterprise JavaBeans)、Spring或Hibernate等技术可以无缝地与Flex进行通信。 在这个入门教程中,你可能会学习到以下内容: - 如何安装和配置Flex SDK和...
blaze DS 是一个免费的,弄让flex 调用 jsp 对象的东西 。
标题中的"flex与java交互 blaze+cairngorm框架实现用户登录"是指使用BlazeDS作为数据交换的桥梁,Cairngorm作为前端的架构指导,来实现一个用户登录功能。下面将详细讲解这两个技术以及如何在MySQL数据库中处理登录...
构建整合Hibernate,Spring和BlazeDS的Flex开发环境是一项复杂但功能强大的技术组合,旨在创建高性能、可扩展的RIA(富互联网应用)。以下是对这一整合过程的深入解析,旨在帮助开发者理解并实施这一架构。 ### ...
Java作为后端开发语言,可以使用Spring、Hibernate等框架来管理业务逻辑和数据持久化。Spring框架提供了依赖注入和面向切面编程,简化了代码结构;Hibernate是一个对象关系映射(ORM)工具,将数据库操作转换为对象...
这是一个flex通过blaze服务器与java交互的例子。 测试环境: win7 MyEclipse8.5 Flash Builder4.5 将文件解压后放到tomcat的webapps目录下。在IE上输入http://localhost/flexweb/flex_client.html。
Flex的Blaze是一款基于Adobe Flex技术的开发框架,主要用于构建高性能、富交互式的Web应用程序。在Web开发领域,Flex以其强大的图形用户界面(GUI)组件库和ActionScript编程语言而闻名,而Blaze则为Flex提供了更为...
在Java端,BlazeDS利用了Spring框架来管理和配置服务。开发者可以创建基于HTTP的轻量级Remoting服务,使得Flex客户端能够直接调用Java类的方法。此外,BlazeDS还支持AMF(Action Message Format)协议,这是一种高效...
5. **Java集成**:BlazeDS可以与Spring框架、Hibernate ORM和其他Java EE组件无缝集成,使开发者能够轻松地利用现有的Java服务和数据访问层。通过配置BlazeDS的配置文件(services-config.xml),可以定义远程服务和...
5. **Security**:Blaze DS提供了基本的身份验证和授权机制,可以与Spring Security等第三方安全框架集成,为Flex应用提供安全的访问控制。 6. **Deployment**:Blaze DS作为一个Java Servlet,可以轻松地部署在...
使用Spring框架集成BlazeDS,定义一个`@RemotingDestination`注解的类,这将暴露你的Java方法供Flex客户端调用。 5. **建立连接**:在Flex客户端,使用`FlashNetConnection`对象连接到BlazeDS服务器。指定服务器URL...
flex_blaze_java整合视频,希望对大家有所帮助。
Flex BlazeDS开发使用手册是Adobe官方提供的一份详尽指南,旨在帮助开发者高效地集成BlazeDS框架到Flex应用程序中。BlazeDS是一款开源的服务器端技术,它为富互联网应用(RIA)提供了数据推送、消息传递和Remoting...
blaze