Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
4Activity
0 of .
Results for:
No results containing your search query
P. 1
Application Context RoseIndia

Application Context RoseIndia

Ratings: (0)|Views: 938|Likes:
Published by zamirarif
Spring
Spring

More info:

Published by: zamirarif on May 04, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

07/24/2010

pdf

text

original

 
In this section we will wire up the components by defining the Application context definition file (applicationContext-hibernate.xml). This file is used by context loader servlet to initialize the Spring application context.
About Application ApplicationContext
An ApplicationContext is the central interface to provide configuration for an application.An ApplicationContext provides the following functionalities:
Beanfactory methods,inherited from ListableBeanFactory. This avoids the need for applications to use singletons.
The ability to resolve messages, supporting internationalization. Inherited fromthe MessageSource interface.
The ability to load file resources in a generic fashion. Inherited from theResourceLoader interface.
The ability to publish events. Implementations must provide a means of registering event listeners.
Inheritance from a parent context. Definitions in a descendant context will alwaystake priority. This means, for example, that a single parent context can be used byan entireweb application, while each servlet has its own child context that isindependent of that of any other servlet.Here is the code of our applicationContext-hibernate.xml file:
 
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN""http://www.springframework.org/dtd/spring-beans.dtd"><!--- Application context definition for RoseIndia Login Application on Hibernate.--><beans><!-- ========================= RESOURCE DEFINITIONS========================= --><!-- Configurer that replaces ${...} placeholders with values from a properties file --><!-- (in this case, JDBC-related settings for the dataSource definition below) --><bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="location"><value>
/WEB-INF/jdbc.properties
</value></property></bean><!-- Local DataSource that works in any environment --><!-- Note that DriverManagerDataSource does not pool; it is not intended for production -->
 
<bean id="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource"><propertyname="driverClassName"><value>${jdbc.driverClassName}</value></property><property name="url"><value>${jdbc.url}</value></property><property name="username"><value>${jdbc.username}</value></property><property name="password"><value>${jdbc.password}</value></property></bean>
<!-- JNDI DataSource for  J2EEenvironments --> <!-- Hibernate SessionFactory --><bean id="sessionFactory"class="
org.springframework.orm.hibernate3.LocalSessionFactoryBean
"><property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources"><list><value>roseindia/dao/hibernate/Login.hbm.xml</value></list></property>
<property name="hibernateProperties"><props><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">true</prop></props></property></bean><!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --><bean id="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory"><ref local="sessionFactory"/></property></bean><!-- ========================= BUSINESS OBJECT DEFINITIONS========================= --><!--Data access object: Hibernate implementation.-->
 
<bean id="HibernateSpringDaoTarget" class="roseindia.dao.SpringHibernateDAOImpl"><property name="sessionFactory"><ref local="sessionFactory"/></property></bean><!--- Transactional proxy for Login Application central data access object.-- Defines specific transaction attributes with "readOnly" markers,- which is an optimization that is particularly valuable with Hibernate- (to suppress unnecessary flush attempts for read-only operations).-- Note that in a real-life app with multiple transaction proxies,- you will probably want to use parent and child bean definitions- as described in the manual, to reduce duplication.-->
<bean id="SpringHibernateDao"class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="transactionManager"/></property><property name="target"><ref local="HibernateSpringDaoTarget"/></property><property name="transactionAttributes"><props><prop key="get*">PROPAGATION_REQUIRED,readOnly</prop><prop key="find*">PROPAGATION_REQUIRED,readOnly</prop><prop key="load*">PROPAGATION_REQUIRED,readOnly</prop><prop key="store*">PROPAGATION_REQUIRED</prop></props></property></bean><!-- EmailService-->
<bean id="mailbean" class="roseindia.web.common.SendMail"><property name="strSmtp"><value>192.168.10.14</value></property></bean>
</beans>
Understanding the applicationContext-hibernate.xml configuration fileData source configuration:
The following line of the configuration file configures thedata source for the application.
<bean id="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource">

Activity (4)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
malle7 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->