001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.server.admin;
030:
031: import com.caucho.config.ConfigException;
032: import com.caucho.util.L10N;
033: import com.caucho.util.Log;
034: import com.caucho.vfs.Path;
035: import com.caucho.vfs.Vfs;
036: import com.caucho.server.resin.Resin;
037:
038: import java.util.logging.Logger;
039:
040: /**
041: * Configures the transaction manager.
042: */
043: public class TransactionManager {
044: private static L10N L = new L10N(TransactionManager.class);
045: private static Logger log = Log.open(TransactionManager.class);
046:
047: private final Management _management;
048: private final Resin _resin;
049: private final Path _path;
050:
051: private TransactionLog _transactionLog;
052:
053: public TransactionManager(Management management) {
054: _management = management;
055: _resin = null;
056: _path = null;
057: }
058:
059: @Deprecated
060: public TransactionManager(Resin resin) {
061: _management = null;
062: _resin = resin;
063: _path = null;
064: }
065:
066: @Deprecated
067: public TransactionManager(Path path) {
068: _management = null;
069: _resin = null;
070: _path = path;
071: }
072:
073: public Path getPath() {
074: if (_management != null)
075: return _management.getPath();
076: else if (_resin != null && _resin.getManagementPath() != null)
077: return _resin.getManagementPath();
078: else if (_path != null)
079: return _path;
080: else
081: return Vfs.lookup("admin");
082: }
083:
084: /**
085: * Configures the xa log.
086: */
087: public TransactionLog createTransactionLog() throws ConfigException {
088: if (_transactionLog == null)
089: _transactionLog = new TransactionLog(this );
090:
091: return _transactionLog;
092: }
093:
094: /**
095: * Initializes the XA manager.
096: */
097: public void start() throws ConfigException {
098: if (_transactionLog != null)
099: _transactionLog.start();
100: }
101:
102: public void destroy() {
103: TransactionLog transactionLog = _transactionLog;
104: _transactionLog = null;
105:
106: if (transactionLog != null)
107: transactionLog.destroy();
108: }
109: }
|