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

Spring Framework example source code file (transactionalBeanFactory.xml)

This example Spring Framework source code file (transactionalBeanFactory.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

doctype, hotswappabletargetsource, invocationcounterinterceptor, invocationcounterinterceptor, propagation_mandatory, propagation_mandatory, propagation_required, propagation_required, propagation_supports, propagation_supports, public, same, spring//dtd, type

The Spring Framework transactionalBeanFactory.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>

	<bean id="targetDependency" class="org.springframework.beans.TestBean">
		<property name="name">dependency
	</bean>

	<!-- Simple target -->
	<bean id="target" class="org.springframework.beans.DerivedTestBean" lazy-init="true">
		<property name="name">custom
		<property name="age">666
		<property name="spouse">
	</bean>

	<bean id="debugInterceptor" class="org.springframework.aop.interceptor.DebugInterceptor"/>

	<bean id="mockMan" class="org.springframework.transaction.interceptor.PlatformTransactionManagerFacade"/>

	<bean id="txInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
		<property name="transactionManager">
		<property name="transactionAttributeSource">
			<value>
				org.springframework.beans.ITestBean.s*=PROPAGATION_MANDATORY
				org.springframework.beans.ITestBean.setAg*=PROPAGATION_REQUIRED
				org.springframework.beans.ITestBean.set*= PROPAGATION_SUPPORTS , readOnly
			</value>
		</property>
	</bean>

	<bean id="proxyFactory1" class="org.springframework.aop.framework.ProxyFactoryBean">
		<property name="proxyInterfaces">
			<value>org.springframework.beans.ITestBean
		</property>
		<property name="interceptorNames">
			<list>
				<value>txInterceptor
				<value>target
			</list>
		</property>
	</bean>

	<bean id="baseProxyFactory" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
		  abstract="true">
		<property name="transactionManager">
		<property name="transactionAttributes">
			<props>
				<prop key="s*">PROPAGATION_MANDATORY
				<prop key="setAg*">  PROPAGATION_REQUIRED  ,  readOnly  
				<prop key="set*">PROPAGATION_SUPPORTS
			</props>
		</property>
	</bean>

	<bean id="proxyFactory2DynamicProxy" parent="baseProxyFactory">
		<property name="target">
	</bean>

	<!--
		Same as proxyFactory2DynamicProxy but forces the use of CGLIB.
	-->
	<bean id="proxyFactory2Cglib" parent="baseProxyFactory">
		<property name="proxyTargetClass">true
		<property name="target">
	</bean>

	<bean id="proxyFactory2Lazy" parent="baseProxyFactory">
		<property name="target">
			<bean class="org.springframework.aop.target.LazyInitTargetSource">
				<property name="targetBeanName">		
			</bean>
		</property>
	</bean>

	<bean id="proxyFactory3" parent="baseProxyFactory">
		<property name="target">
		<property name="proxyTargetClass">true
		<property name="pointcut">
			<ref local="txnInvocationCounterPointcut"/>
		</property>
		<property name="preInterceptors">
			<list>
				<ref local="preInvocationCounterInterceptor"/>
			</list>
		</property>
		<property name="postInterceptors">
			<list>
				<ref local="postInvocationCounterInterceptor"/>
			</list>
		</property>
	</bean>

	<bean name="cglibNoInterfaces" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
		<property name="transactionManager">
		<property name="target">
			<bean class="org.springframework.transaction.interceptor.ImplementsNoInterfaces">
				<property name="dependency">
			</bean>
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED
			</props>
		</property>
	</bean>

	<!--
		The HotSwappableTargetSource is a Type 3 component.
	-->
	<bean id="swapper" class="org.springframework.aop.target.HotSwappableTargetSource">
		<constructor-arg>
	</bean>

	<bean id="hotSwapped" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
		<property name="transactionManager">
		<!-- Should automatically pick up the target source, rather than simple target -->
		<property name="target">
		<property name="transactionAttributes">
			<props>
				<prop key="s*">PROPAGATION_MANDATORY
				<prop key="setAg*">PROPAGATION_REQUIRED
				<prop key="set*">PROPAGATION_SUPPORTS
			</props>
		</property>
		<property name="proxyTargetClass">true
		<property name="optimize">false
	</bean>

	<bean id="txnInvocationCounterPointcut"
			class="org.springframework.transaction.interceptor.BeanFactoryTransactionTests$InvocationCounterPointcut"/>

	<bean id="preInvocationCounterInterceptor" class="org.springframework.transaction.interceptor.BeanFactoryTransactionTests$InvocationCounterInterceptor"/>

	<bean id="postInvocationCounterInterceptor" class="org.springframework.transaction.interceptor.BeanFactoryTransactionTests$InvocationCounterInterceptor"/>

</beans>

Other Spring Framework examples (source code examples)

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

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

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 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.