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.transaction.log.UnrecoverableLog; 020 import org.apache.geronimo.transaction.manager.TransactionLog; 021 import org.apache.geronimo.transaction.manager.TransactionManagerImpl; 022 import org.springframework.beans.factory.FactoryBean; 023 import org.springframework.beans.factory.InitializingBean; 024 025 import java.util.Collection; 026 027 /** 028 * This FactoryBean creates and configures the Geronimo implementation 029 * of the TransactionManager interface. 030 * 031 * @author Thierry Templier 032 * @see UnrecoverableLog 033 * @see org.apache.geronimo.transaction.log.HOWLLog 034 */ 035 public class TransactionManagerFactoryBean implements FactoryBean, InitializingBean { 036 037 private int defaultTransactionTimeoutSeconds = 600; 038 private TransactionLog transactionLog; 039 private Collection resourceManagers; 040 041 private TransactionManagerImpl transactionManagerImpl; 042 043 public Object getObject() throws Exception { 044 return transactionManagerImpl; 045 } 046 047 public Class getObjectType() { 048 return TransactionManagerImpl.class; 049 } 050 051 public boolean isSingleton() { 052 return true; 053 } 054 055 /** 056 * Set the default transaction timeout in second. 057 */ 058 public void setDefaultTransactionTimeoutSeconds(int timeout) { 059 defaultTransactionTimeoutSeconds = timeout; 060 } 061 062 /** 063 * Set the transaction log for the transaction context manager. 064 */ 065 public void setTransactionLog(TransactionLog log) { 066 transactionLog = log; 067 } 068 069 public Collection getResourceManagers() { 070 return resourceManagers; 071 } 072 073 /** 074 * Set the resource managers 075 */ 076 public void setResourceManagers(Collection resourceManagers) { 077 this.resourceManagers = resourceManagers; 078 } 079 080 public void afterPropertiesSet() throws Exception { 081 if (transactionLog == null) { 082 transactionLog = new UnrecoverableLog(); 083 } 084 this.transactionManagerImpl = new TransactionManagerImpl(defaultTransactionTimeoutSeconds, 085 transactionLog, resourceManagers); 086 } 087 088 }