Home » openejb-3.1.2-src » org.apache » openejb » resource » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements.  See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership.  The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License.  You may obtain a copy of the License at
    9    *
   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   
   21   package org.apache.openejb.resource;
   22   
   23   import org.apache.geronimo.transaction.log.HOWLLog;
   24   import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
   25   import org.apache.geronimo.transaction.manager.TransactionLog;
   26   import org.apache.geronimo.transaction.manager.XidFactory;
   27   import org.apache.geronimo.transaction.manager.XidFactoryImpl;
   28   import org.apache.geronimo.transaction.manager.WrapperNamedXAResource;
   29   import org.apache.openejb.loader.SystemInstance;
   30   
   31   import javax.transaction.xa.XAResource;
   32   
   33   /**
   34    * @version $Rev: 710022 $ $Date: 2008-11-03 00:40:14 -0800 (Mon, 03 Nov 2008) $
   35    */
   36   public class GeronimoTransactionManagerFactory {
   37   
   38       private static final byte[] DEFAULT_TM_ID = new byte[]{71, 84, 77, 73, 68};
   39       private static final int DEFAULT_BUFFER_SIZE = 32;
   40   
   41       public static GeronimoTransactionManager create(int defaultTransactionTimeoutSeconds,
   42                                                       boolean txRecovery,
   43                                                       byte[] tmId,
   44                                                       String bufferClassName,
   45                                                       int bufferSizeKb,
   46                                                       boolean checksumEnabled,
   47                                                       boolean adler32Checksum,
   48                                                       int flushSleepTimeMilliseconds,
   49                                                       String logFileDir,
   50                                                       String logFileExt,
   51                                                       String logFileName,
   52                                                       int maxBlocksPerFile,
   53                                                       int maxBuffers,
   54                                                       int maxLogFiles,
   55                                                       int minBuffers,
   56                                                       int threadsWaitingForceThreshold) throws Exception {
   57           XidFactory xidFactory = null;
   58           TransactionLog txLog = null;
   59           if (txRecovery) {
   60               SystemInstance.get().setComponent(XAResourceWrapper.class, new GeronimoXAResourceWrapper());
   61               
   62               xidFactory = new XidFactoryImpl(tmId == null ? DEFAULT_TM_ID: tmId);
   63               txLog = new HOWLLog(bufferClassName == null ? "org.apache.howl.log.BlockLogBuffer" : bufferClassName,
   64                       bufferSizeKb == 0 ? DEFAULT_BUFFER_SIZE : bufferSizeKb,
   65                       checksumEnabled,
   66                       adler32Checksum,
   67                       flushSleepTimeMilliseconds,
   68                       logFileDir,
   69                       logFileExt,
   70                       logFileName,
   71                       maxBlocksPerFile,
   72                       maxBuffers,
   73                       maxLogFiles,
   74                       minBuffers,
   75                       threadsWaitingForceThreshold,
   76                       xidFactory,
   77                       SystemInstance.get().getBase().getDirectory("."));
   78               ((HOWLLog)txLog).doStart();
   79           }
   80   
   81           return new GeronimoTransactionManager(defaultTransactionTimeoutSeconds, xidFactory, txLog);
   82       }
   83   
   84       public static class GeronimoXAResourceWrapper implements XAResourceWrapper {
   85           public XAResource wrap(XAResource xaResource, String name) {
   86               return new WrapperNamedXAResource(xaResource, name);
   87           }
   88       }
   89   }

Home » openejb-3.1.2-src » org.apache » openejb » resource » [javadoc | source]