View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.core.ojb;
17  
18  import javax.transaction.TransactionManager;
19  
20  import org.apache.log4j.Logger;
21  import org.springframework.beans.factory.BeanFactory;
22  import org.springframework.beans.factory.DisposableBean;
23  import org.springframework.beans.factory.InitializingBean;
24  import org.springmodules.orm.ojb.support.LocalOjbConfigurer;
25  
26  /**
27   * Utility bean that sets the JTA TransactionManager on the WorkflowTransactionManagerFactory, the
28   * OJB TransactionManagerFactory implementation that makes this available from Workflow core.
29   * @see TransactionManagerFactory
30   * @see org.apache.ojb.broker.transaction.tm.TransactionManagerFactory
31   */
32  public class JtaOjbConfigurer extends LocalOjbConfigurer implements InitializingBean, DisposableBean {
33      private static final Logger LOG = Logger.getLogger(JtaOjbConfigurer.class);
34  
35  	private TransactionManager transactionManager;
36  
37  	@Override
38  	public void setBeanFactory(BeanFactory beanFactory) {
39  		super.setBeanFactory(beanFactory);
40  		RiceDataSourceConnectionFactory.addBeanFactory(beanFactory);
41  	}
42  
43  	public void afterPropertiesSet() {
44          LOG.debug("Setting OJB WorkflowTransactionManagerFactory transaction manager to: " + this.transactionManager);
45          TransactionManagerFactory.setTransactionManager(this.transactionManager);
46  	}
47  
48  	public void destroy() {
49  	    this.transactionManager = null;
50  	}
51  
52  	public void setTransactionManager(TransactionManager transactionManager) {
53  		this.transactionManager = transactionManager;
54  	}
55  }