001 /** 002 * 003 * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.jencks.factory; 019 020 import org.apache.geronimo.connector.BootstrapContextImpl; 021 import org.apache.geronimo.connector.work.GeronimoWorkManager; 022 import org.apache.geronimo.gbean.ReferenceCollection; 023 import org.apache.geronimo.transaction.ExtendedTransactionManager; 024 import org.apache.geronimo.transaction.context.TransactionContextManager; 025 import org.apache.geronimo.transaction.log.UnrecoverableLog; 026 import org.apache.geronimo.transaction.manager.TransactionLog; 027 import org.apache.geronimo.transaction.manager.TransactionManagerImpl; 028 import org.apache.geronimo.transaction.manager.XidImporter; 029 import org.springframework.beans.factory.FactoryBean; 030 import org.springframework.beans.factory.InitializingBean; 031 032 import javax.resource.spi.BootstrapContext; 033 import javax.resource.spi.work.WorkManager; 034 import javax.transaction.xa.XAException; 035 036 /** 037 * A Spring {@link FactoryBean} for creating a {@link BootstrapContext} for the JCA container 038 * with the {@link WorkManager} and {@link ExtendedTransactionManager}. 039 * 040 * @version $Revision: 1.3 $ 041 */ 042 public class BootstrapContextFactoryBean implements FactoryBean, InitializingBean { 043 044 private BootstrapContext bootstrapContext; 045 private GeronimoWorkManager workManager; 046 private WorkManagerFactoryBean workManagerFactory = new WorkManagerFactoryBean(); 047 048 public Object getObject() throws Exception { 049 return bootstrapContext; 050 } 051 052 public Class getObjectType() { 053 return BootstrapContext.class; 054 } 055 056 public boolean isSingleton() { 057 return true; 058 } 059 060 public void afterPropertiesSet() throws Exception { 061 bootstrapContext = new BootstrapContextImpl(getWorkManager()); 062 } 063 064 065 // Properties 066 //------------------------------------------------------------------------- 067 public GeronimoWorkManager getWorkManager() throws Exception { 068 if (workManager == null) { 069 workManager = workManagerFactory.getWorkManager(); 070 } 071 return workManager; 072 } 073 074 public void setWorkManager(GeronimoWorkManager workManager) { 075 this.workManager = workManager; 076 } 077 078 public TransactionContextManager getTransactionContextManager() throws XAException { 079 return workManagerFactory.getTransactionContextManager(); 080 } 081 082 public void setTransactionContextManager(TransactionContextManager transactionContextManager) { 083 workManagerFactory.setTransactionContextManager(transactionContextManager); 084 } 085 086 public int getThreadPoolSize() { 087 return workManagerFactory.getThreadPoolSize(); 088 } 089 090 public void setThreadPoolSize(int threadPoolSize) { 091 workManagerFactory.setThreadPoolSize(threadPoolSize); 092 } 093 094 public ExtendedTransactionManager getTransactionManager() throws XAException { 095 return workManagerFactory.getTransactionManager(); 096 } 097 098 public void setTransactionManager(ExtendedTransactionManager transactionManager) { 099 workManagerFactory.setTransactionManager(transactionManager); 100 } 101 102 public XidImporter getXidImporter() { 103 return workManagerFactory.getXidImporter(); 104 } 105 106 public void setXidImporter(XidImporter xidImporter) { 107 workManagerFactory.setXidImporter(xidImporter); 108 } 109 110 public int getDefaultTransactionTimeoutSeconds() { 111 return workManagerFactory.getDefaultTransactionTimeoutSeconds(); 112 } 113 114 public void setDefaultTransactionTimeoutSeconds(int defaultTransactionTimeoutSeconds) { 115 workManagerFactory.setDefaultTransactionTimeoutSeconds(defaultTransactionTimeoutSeconds); 116 } 117 118 public TransactionLog getTransactionLog() { 119 return workManagerFactory.getTransactionLog(); 120 } 121 122 public void setTransactionLog(TransactionLog transactionLog) { 123 workManagerFactory.setTransactionLog(transactionLog); 124 } 125 126 public ReferenceCollection getResourceManagers() { 127 return workManagerFactory.getResourceManagers(); 128 } 129 130 public void setResourceManagers(ReferenceCollection resourceManagers) { 131 workManagerFactory.setResourceManagers(resourceManagers); 132 } 133 }