一个配置文件(spring学习中)
spring学习笔记
2010-01-08 21:49:14
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
>
<!-- 定义DataSource -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:mem:bookstore" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
<!-- 定义TransactionManager -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 定义BookDao -->
<bean id="bookDao" class="example.chapter6.BookDaoImpl">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 将BookDao封装成具有事务功能 -->
<!-- 声明TxAdvice -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 对以query开头的方法要求只读事务 -->
<tx:method name="query*" read-only="true" />
<!-- 对于其他方法要求事务 -->
<tx:method name="*" rollback-for="java.io.IOException" />
</tx:attributes>
</tx:advice>
<!-- PointCut的表达式配置
execute(modifiers-pattern?
ret-type-pattern
declaring-type-pattern?
name-pattern(param-pattern)
throws-pattern?)
// 有"?"的部分表示可以省略,
modifers-pattern表示修饰符,如public何protected等,
ret-type-pattern表示方法返回类型,
declaring-type-pattern表示特定的类,
name-pattern表示参数
throws-pattern表示抛出的异常
在切入点表达式中“*”代表任意字符,“..”表示人一个参数
-->
<aop:config>
<!-- 使用AspectJ语法定义Pointcut -->
<aop:pointcut id="bookDaoOperation" expression="execution(* example.chapter6.BookDao.*(..))" />
<!-- 织入 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="bookDaoOperation" />
</aop:config>
</beans>
转载自我的163博客:http://huangyuantwl.blog.163.com/blog/static/11781460620100894914937/
还有一篇学习笔记不过主要内容就是转载javaEye上边的spring源码解析:
http://huangyuantwl.blog.163.com/blog/static/11781460620091021105822441/
分享到:
相关推荐
中文版EXPERT-ONE-ON-ONE-J2EE-DEVELOPMENT-WITHOUT-EJB.part2.rar
java面试之------J2EE测试题1.rar java面试之------J2EE测试题1.rar java面试之------J2EE测试题1.rar
中文版EXPERT-ONE-ON-ONE-J2EE-DEVELOPMENT-WITHOUT-EJB.pdf
Wrox+-+Expert+One-on-One+J2EE+Design+and+Development
中文版EXPERT-ONE-ON-ONE-J2EE-DEVELOPMENT-WITHOUT-EJB.part3.rar
The results of using J2EE in practice are often disappointing: applications are often slow, unduly complex, and take too long to develop. Rod Johnson believes that the problem lies not in J2EE itself...
《Expert-One-on-one J2EE Development Without EJB》一书的英文版本
Expert One-on-One J2EE Design & Development 中文版 是spring 作者 Rod Johnson的经典之作,Spring就是来自本书中的思想 中文名:J2EE设计开发编程指南
Expert_One-on-One_J2EE_Design___Development
j2ee学习笔记j2ee学习笔记j2ee学习笔记j2ee学习笔记j2ee学习笔记
J2EE-API-7和J2EE-API-6中英文对照版,专为java企业级开发提供参考文档,这两种文档收集不易,希望大家多多支持。
Expert+One-On-One+J2Ee+Design+And+Development.chm
Expert+One-on-One+J2EE+Design+And+Development.chm
Expert One-on-One J2EE Development Without EJB中文版.pdf.7z.002(共3个)
java笔记-从菜鸟到j2se j2ee高手之路
J2EE学习计划 J2EE 学习计划 J2EE 学习计划J2EE 学习计划J2EE 学习计划
文献翻译----基于J2EE在分布式环境下的底层结构的自动动态配置应用.pdf
Expert One-on-One J2EE Development Without EJB中文版 一共10个文件,共需资源分:2,第一个和最后一个各1分 欢迎大家下载
expert+one-on-one+j2ee+development+without+ejb中文版 e
Expert One-on-one J2EE Expert One-on-one J2EE Expert One-on-one J2EE