y.service.DefaultFooService y.SimpleProfiler y.service.DefaultFooService

4.3.9.RELEASE Spring Framework 395 ?xml version=1.0 encoding=UTF-8? beans xmlns = http:www.springframework.orgschemabeans xmlns:xsi = http:www.w3.org2001XMLSchema-instance xmlns:aop = http:www.springframework.orgschemaaop xmlns:tx = http:www.springframework.orgschematx xsi:schemaLocation = http:www.springframework.orgschemabeans http:www.springframework.orgschemabeansspring-beans.xsd http:www.springframework.orgschematx http:www.springframework.orgschematxspring-tx.xsd http:www.springframework.orgschemaaop http:www.springframework.orgschemaaopspring-aop.xsd bean id = fooService class =

x.y.service.DefaultFooService

-- this is the aspect -- bean id = profiler class =

x.y.SimpleProfiler

-- execute before the transactional advice hence the lower order number -- property name = order __value = 1 __ bean tx:annotation-driven transaction-manager = txManager __order = 200 __ aop:config -- this advice will execute around the transactional advice -- aop:aspect id = profilingAspect ref = profiler aop:pointcut id = serviceMethodWithReturnValue expression = executionvoid x.y..Service... aop:around method = profile pointcut-ref = serviceMethodWithReturnValue aop:aspect aop:config bean id = dataSource class = org.apache.commons.dbcp.BasicDataSource destroy-method = close property name = driverClassName value = oracle.jdbc.driver.OracleDriver property name = url value = jdbc:oracle:thin:rj-t42:1521:elvis property name = username value = scott property name = password value = tiger bean bean id = txManager class = org.springframework.jdbc.datasource.DataSourceTransactionManager property name = dataSource ref = dataSource bean beans The result of the above configuration is a fooService bean that has profiling and transactional aspects applied to it in the desired order. You configure any number of additional aspects in similar fashion. The following example effects the same setup as above, but uses the purely XML declarative approach. 4.3.9.RELEASE Spring Framework 396 ?xml version=1.0 encoding=UTF-8? beans xmlns = http:www.springframework.orgschemabeans xmlns:xsi = http:www.w3.org2001XMLSchema-instance xmlns:aop = http:www.springframework.orgschemaaop xmlns:tx = http:www.springframework.orgschematx xsi:schemaLocation = http:www.springframework.orgschemabeans http:www.springframework.orgschemabeansspring-beans.xsd http:www.springframework.orgschematx http:www.springframework.orgschematxspring-tx.xsd http:www.springframework.orgschemaaop http:www.springframework.orgschemaaopspring-aop.xsd bean id = fooService class =

x.y.service.DefaultFooService

-- the profiling advice -- bean id = profiler class =

x.y.SimpleProfiler