alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Spring Framework example source code file (declarativeServices.xml)

This example Spring Framework source code file (declarativeServices.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Spring Framework tags/keywords

advisor, advisor, aop, attributes, attributes, commons, doctype, jpetstore, the, the, this, transaction, transaction, you

The Spring Framework declarativeServices.xml source code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>

	<description>
		Generic auto-proxy definitions enabling declarative transaction management,
		based on Commons Attributes attributes. The application context must define
		a PlatformTransactionManager bean with name "transactionManager" (the bean
		name can be adapted in the corresponding bean reference below).
		
		This file is generic, and not specific to JPetStore. You can use it unchanged
		as an application context definition file for your own applications to get
		attribute-driven declarative transaction management.
		
		The power of this approach is more apparent when you have many transactional
		business objects, not just one as in this simple application.
		
		Add more Advisor definitions if you want, for additional declarative services.
		Advisors are detected by type: therefore, no explicit references are necessary.
	</description>

	<!--
		This bean is a post-processor that will automatically apply relevant advisors
		to any bean in child factories.
	-->
	<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>

	<!--
		AOP advisor that will provide declarative transaction management based on
		attributes. It's possible to add arbitrary custom Advisor implementations
		as well, and they will also be evaluated and applied automatically.
	-->
	<bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
		<property name="transactionInterceptor" ref="transactionInterceptor"/>
	</bean>

	<!--
		Transaction interceptor to use for auto-proxy creation.
		Transaction attributes will be read in from class-level metadata.
	-->
	<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
		<property name="transactionManager" ref="transactionManager"/>
		<property name="transactionAttributeSource">
			<bean class="org.springframework.transaction.interceptor.AttributesTransactionAttributeSource">
				<property name="attributes" ref="attributes"/>
			</bean>
		</property>
	</bean>

	<!--
		Commons Attributes Attributes implementation. Replace with another
		implementation of org.springframework.metadata.Attributes to source
		attributes from a different source.
	-->
	<bean id="attributes" class="org.springframework.metadata.commons.CommonsAttributes"/>
	
</beans>

Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework declarativeServices.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.