spring

阅读更多

"http://wwww.springframework.org/dtd/spring-beans.dtd">

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

springwork/core/aop/targetsource/init.properties





${datasource.driverClassName}


${datasource.url}


${datasource.username}


${datasource.password}





${datasource.driverClassName}


${datasource.url1}


${datasource.username}


${datasource.password}



class="org.springframework.aop.target.HotSwappableTargetSource">




class="org.springframework.aop.framework.ProxyFactoryBean">




class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">





springwork/core/aop/targetsource/Cat.hbm.xml




${hibernate.dialect}
true
true

net.sf.ehcache.hibernate.SingletonEhCacheProvider












class="org.springframework.orm.hibernate3.HibernateTransactionManager">








class="org.springframework.transaction.interceptor.TransactionInterceptor"
dependency-check="none">





PROPAGATION_REQUIRED,readOnly
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"
dependency-check="none">

true



transactionInterceptor




catDAO








代码


代码

public void testWithTwoDataSource()
{
Cat cat=new Cat("mimi");
catDAO.save(cat);
Assert.assertNotNull(cat.getId());
Cat cat2=new Cat("xixi");
HotSwappableTargetSource swapper=(HotSwappableTargetSource) application.getBean("swappableDataSource");
DataSource newDataSource=(DataSource)application.getBean("dataSource1");
swapper.swap(newDataSource);
catDAO.save(cat2);
Assert.assertNotNull(cat2.getId());
}

你可能感兴趣的:(Spring,Hibernate,AOP,Bean,XML)