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

Spring Framework example source code file (applicationContext.xml)

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

both, c3p0, c3p0, clobs, datasource, datasource, jdbc, jdbc, lobhandler, lobhandler, middle, nativejdbcextractor, oracleconnections, see

The Spring Framework applicationContext.xml source code

<?xml version="1.0" encoding="UTF-8"?>
<!--
  - Middle tier application context definition for the image database.
  -->
<beans xmlns="http://www.springframework.org/schema/beans"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:context="http://www.springframework.org/schema/context"
		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.5.xsd
				http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
				http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

	<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
	<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
	<context:property-placeholder location="WEB-INF/jdbc.properties,WEB-INF/mail.properties"/>

	<!-- Local C3P0 DataSource that works in any environment -->
	<!-- See JPetStore for an example of using Apache Commons DBCP as alternative -->
	<!-- (Both DataSource implementations have a "close" method to be called on shutdown) -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
		<property name="driverClass" value="${jdbc.driverClassName}"/>
		<property name="jdbcUrl" value="${jdbc.url}"/>
		<property name="user" value="${jdbc.username}"/>
		<property name="password" value="${jdbc.password}"/>
	</bean>

	<!-- Transaction manager for a single JDBC DataSource -->
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"/>
	</bean>

	<!-- Activates @Transactional for DefaultImageDatabase -->
	<tx:annotation-driven transaction-manager="transactionManager"/>

	<!-- Default implementation of the ImageDatabase business interface -->
	<!-- (refers to a LobHandler for handling BLOBs and CLOBs -->
	<bean id="imageDatabase" class="org.springframework.samples.imagedb.DefaultImageDatabase">
		<property name="dataSource" ref="dataSource"/>
		<property name="lobHandler" ref="${imageDatabase.lobHandler}"/>
	</bean>

	<!-- MailSender implementation for JavaMail -->
	<!-- Used by ListImagesQuartzJob and ListImagesTimerTask; see "scheduling-*.xml" -->
	<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
		<property name="host" value="${mail.host}"/>
	</bean>

	<!-- LobHandler for well-behaved JDBC drivers -->
	<!-- (simply delegating to corresponding PreparedStatement and ResultSet methods) -->
	<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>

	<!-- LobHandler for Oracle JDBC drivers -->
	<!-- (refers to the NativeJdbcExtractor above to get access to native OracleConnections) -->
	<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true">
		<property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/>
	</bean>

	<!-- NativeJdbcExtractor for the C3P0 connection pool above -->
	<!-- (just needed for oracleLobHandler) -->
	<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor"
			lazy-init="true"/>

</beans>

Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework applicationContext.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.