01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.openejb.resource;
21:
22: import java.io.IOException;
23:
24: import javax.transaction.xa.XAException;
25:
26: import org.apache.geronimo.transaction.log.HOWLLog;
27: import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
28: import org.apache.geronimo.transaction.manager.TransactionLog;
29: import org.apache.geronimo.transaction.manager.XidFactory;
30: import org.apache.geronimo.transaction.manager.XidFactoryImpl;
31: import org.apache.openejb.loader.SystemInstance;
32:
33: /**
34: * @version $Rev: 637548 $ $Date: 2008-03-15 23:48:50 -0700 $
35: */
36: public class GeronimoTransactionManagerFactory {
37:
38: private static final byte[] DEFAULT_TM_ID = new byte[] { 71, 84,
39: 77, 73, 68 };
40: private static final int DEFAULT_BUFFER_SIZE = 32;
41:
42: public static GeronimoTransactionManager create(
43: int defaultTransactionTimeoutSeconds, byte[] tmId,
44: String bufferClassName, int bufferSizeKb,
45: boolean checksumEnabled, boolean adler32Checksum,
46: int flushSleepTimeMilliseconds, String logFileDir,
47: String logFileExt, String logFileName,
48: int maxBlocksPerFile, int maxBuffers, int maxLogFiles,
49: int minBuffers, int threadsWaitingForceThreshold)
50: throws Exception {
51: XidFactory xidFactory = null;
52: TransactionLog txLog = null;
53: if (maxLogFiles > 0) {
54: xidFactory = new XidFactoryImpl(
55: tmId == null ? DEFAULT_TM_ID : tmId);
56: txLog = new HOWLLog(
57: bufferClassName == null ? "org.objectweb.howl.log.BlockLogBuffer"
58: : bufferClassName,
59: bufferSizeKb == 0 ? DEFAULT_BUFFER_SIZE
60: : bufferSizeKb, checksumEnabled,
61: adler32Checksum, flushSleepTimeMilliseconds,
62: logFileDir, logFileExt, logFileName,
63: maxBlocksPerFile, maxBuffers, maxLogFiles,
64: minBuffers, threadsWaitingForceThreshold,
65: xidFactory, SystemInstance.get().getBase()
66: .getDirectory("."));
67: ((HOWLLog) txLog).doStart();
68: }
69: return new GeronimoTransactionManager(
70: defaultTransactionTimeoutSeconds, xidFactory, txLog);
71: }
72: }
|