001 /* 002 * Copyright 2002-2005 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package org.jencks.factory; 018 019 import org.apache.geronimo.gbean.ReferenceCollection; 020 import org.apache.geronimo.transaction.log.UnrecoverableLog; 021 import org.apache.geronimo.transaction.manager.TransactionLog; 022 import org.apache.geronimo.transaction.manager.TransactionManagerImpl; 023 import org.springframework.beans.factory.FactoryBean; 024 import org.springframework.beans.factory.InitializingBean; 025 026 /** 027 * This FactoryBean creates and configures the Geronimo implementation 028 * of the TransactionManager interface. 029 * 030 * @author Thierry Templier 031 * @see UnrecoverableLog 032 * @see org.apache.geronimo.transaction.log.HOWLLog 033 */ 034 public class TransactionManagerFactoryBean implements FactoryBean, InitializingBean { 035 036 private int defaultTransactionTimeoutSeconds = 600; 037 private TransactionLog transactionLog; 038 private ReferenceCollection resourceManagers; 039 040 private TransactionManagerImpl transactionManagerImpl; 041 042 public Object getObject() throws Exception { 043 return transactionManagerImpl; 044 } 045 046 public Class getObjectType() { 047 return TransactionManagerImpl.class; 048 } 049 050 public boolean isSingleton() { 051 return true; 052 } 053 054 /** 055 * Set the default transaction timeout in second. 056 */ 057 public void setDefaultTransactionTimeoutSeconds(int timeout) { 058 defaultTransactionTimeoutSeconds = timeout; 059 } 060 061 /** 062 * Set the transaction log for the transaction context manager. 063 */ 064 public void setTransactionLog(TransactionLog log) { 065 transactionLog = log; 066 } 067 068 public ReferenceCollection getResourceManagers() { 069 return resourceManagers; 070 } 071 072 /** 073 * Set the resource managers 074 */ 075 public void setResourceManagers(ReferenceCollection resourceManagers) { 076 this.resourceManagers = resourceManagers; 077 } 078 079 public void afterPropertiesSet() throws Exception { 080 if (transactionLog == null) { 081 transactionLog = new UnrecoverableLog(); 082 } 083 this.transactionManagerImpl = new TransactionManagerImpl(defaultTransactionTimeoutSeconds, 084 transactionLog, resourceManagers); 085 } 086 087 }