`
samuel5_1
  • 浏览: 15476 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

flex+sping+jdbc 配置

    博客分类:
  • flex
阅读更多
有感于flex的绚丽,业余时间研究了下flex,目前正在做一个系统登录.涉及到spring flex的配置,简单总结如下,希望对各位有所帮助,也欢迎大家提出问题斧正

程序所使用的各个版本:
spring 3.0;
flex4.0;
jdk1.6;
oracle11g


一:首先配置flex+spring,spring和jdbc的配置和其他项目配置是一样的.flex的配置请参考其他文章

1:项目添加相关spring包,增加配置文件.我是用myeclipse自动导入的;
2:web.xml添加spring定义
<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:applicationContext.xml</param-value>
	</context-param>
	  
	  <listener>
	     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	  </listener>

3:flex下的services-config.xml配置spring工厂类
<factories>
	<factory id="spring" class="com.labApp.beanFactory.SpringFactory" />
</factories>

4:flex下的remoting-config.xml配置spring服务类checkLogin,checkLogin是定义在applicationContext.xml中的bean id.以后涉及的spring服务类均需要在remoting-config.xml配置
<destination id="checkLogin">
	    <properties>
	    	<factory>spring</factory>
	    	<source>checkLogin</source>
	    </properties>
	</destination>

5:applicationContext.xml中的checkLogin配置
<bean id="checkLogin" class="*.*.CheckLogin">
</bean>

6:现在就可以在flex程序中调用spring的服务了 如下,其中destination="checkLogin"即使匹配在remoting-config.xml中的配置信息.通过login.method()来调用服务类中的方法
<mx:RemoteObject id="login" destination="checkLogin" result="getResult(event)"/>

二:spring+jdbc配置
1:配置数据源,我用的Proxool连接池
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
		<property name="driver" value="oracle.jdbc.driver.OracleDriver">
		</property>
		<property name="driverUrl" value="**">
		</property>
		<property name="user" value="**"></property>
		<property name="password" value="**"></property>
		<property name="alias">
	      <value>Oracle</value>
	    </property>
	    <property name="trace">
	      <value>true</value>
	    </property>
	</bean>

2:dao配置,其中labJdbcDAO是自己写的一个dao操作列继承自spring的SimpleJdbcDaoSupport
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	<bean id="labJdbcDAO" class="com.labApp.dao.jdbc.LabJdbcDAO">
		<property name="jdbcTemplate" ref="jdbcTemplate"></property>
		
	</bean>

3:jdbc事务配置
<bean id="jdbcTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"/>
	</bean>	
	<bean id="jdbcTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
		<property name="transactionManager">
			<ref local="jdbcTransactionManager"/>
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="add*">PROPAGATION_REQUIRED</prop>
				<prop key="save*">PROPAGATION_REQUIRED</prop>
				<prop key="delete*">PROPAGATION_REQUIRED</prop>
				<prop key="update*">PROPAGATION_REQUIRED</prop>
				<!--  
				<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
				-->
				<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
				<prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
				<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
			</props>
		</property>
	</bean>

<bean id="checkLogin" parent="jdbcTransactionProxy">
		<property name="target">
			<bean class="com.labApp.service.CheckLogin"/>
		</property>
	</bean>




OK配置结束,下面简单说下程序流程
flex通过remote Object在remoting-config.xml找到调用的spring服务类ID,接着springFactory通过该ID 以及applicationContext.xml调用相关的spring服务类,剩下的则交给后台服务类处理
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics