2008年8月24日星期日

Spring配置文件--Typical

<?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">

<!--

- Application context definition for PetClinic 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"/>

</bean>

<!-- Local DataSource that works in any environment -->

<!-- Note that DriverManagerDataSource does not pool; it is not intended for production -->

<!-- See JPetStore for an example of using Commons DBCP BasicDataSource as alternative -->

<!-- See Image Database for an example of using C3P0 ComboPooledDataSource as alternative -->

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName" value="${jdbc.driverClassName}"/>

<property name="url" value="${jdbc.url}"/>

<property name="username" value="${jdbc.username}"/>

<property name="password" value="${jdbc.password}"/>

</bean>

<!-- JNDI DataSource for J2EE environments -->

<!--

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">

<property name="jndiName" value="java:comp/env/jdbc/petclinic"/>

</bean>

-->

<!-- Hibernate SessionFactory -->

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="dataSource" ref="dataSource"/>

<property name="mappingResources">

<value>mobile.hbm.xml</value>

</property>

<property name="hibernateProperties">

<props>

<prop key="hibernate.dialect">${hibernate.dialect}</prop>

<prop key="hibernate.show_sql">true</prop>

<prop key="hibernate.generate_statistics">true</prop>

</props>

</property>

<property name="eventListeners">

<map>

<entry key="merge">

<bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>

</entry>

</map>

</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="sessionFactory"/>

</bean>



<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->

<!--

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>

-->



<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->

<!--

- PetClinic's central data access object: Hibernate implementation.

-->

<bean id="mobileTarget" class="com.gomt.stbc.hibernate.HibernateMobile">

<property name="sessionFactory" ref="sessionFactory"/>

</bean>

<!--

- Transactional proxy for PetClinic's 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="mobile" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

<property name="transactionManager" ref="transactionManager"/>

<property name="target" ref="mobileTarget"/>

<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>



<!-- Hibernate 3.0's JMX statistics service -->

<!-- Implements the StatisticsServiceMBean management interface -->

<!--

<bean name="petclinic:type=HibernateStatistics" class="org.hibernate.jmx.StatisticsService">

<property name="sessionFactory" ref="sessionFactory"/>

</bean>-->

<!-- ========================= JMX EXPORTER DEFINITION ========================= -->

<!--

- Exporter that exposes Hibernate 3.0's statistics service via JMX.

- Autodetects the statistics service, which is a standard MBean,

- using its bean name as JMX object name.

-

- By default, the standard MBeanServerFactory.findMBeanServer method will be used

- to determine the MBeanServer. Unfortunately, this does not work on WebLogic <= 8.1:

- you need to comment in the WebLogicMBeanServerFactoryBean definition on WebLogic,

- specifying appropriate configuration values there.

-->

<!--

<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter">

<property name="autodetect" value="true"/>

</bean>-->

<!-- Comment the following in on WebLogic <= 8.1, which doesn't support -->

<!-- the standard MBeanServerFactory.findMBeanServer lookup mechanism. -->

<!--

<property name="server">

<bean class="org.springframework.jmx.support.WebLogicJndiMBeanServerFactoryBean"/>

</property>

-->

</beans>

标签:

0 条评论:

发表评论

订阅 博文评论 [Atom]

<< 主页