01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.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
33: InitializingBean, DisposableBean {
34: private static final Logger LOG = Logger
35: .getLogger(JtaOjbConfigurer.class);
36:
37: private TransactionManager transactionManager;
38:
39: @Override
40: public void setBeanFactory(BeanFactory beanFactory) {
41: super .setBeanFactory(beanFactory);
42: RiceDataSourceConnectionFactory.addBeanFactory(beanFactory);
43: }
44:
45: public void afterPropertiesSet() {
46: LOG
47: .debug("Setting OJB WorkflowTransactionManagerFactory transaction manager to: "
48: + this .transactionManager);
49: TransactionManagerFactory
50: .setTransactionManager(this .transactionManager);
51: }
52:
53: public void destroy() {
54: this .transactionManager = null;
55: }
56:
57: public void setTransactionManager(
58: TransactionManager transactionManager) {
59: this.transactionManager = transactionManager;
60: }
61: }
|