⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jtatransaction.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
字号:
/* * $Id: JtaTransaction.java 5462 2005-08-05 18:35:48Z jonesde $ * * Copyright (c) 2004 The Open For Business Project - www.ofbiz.org * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */package org.ofbiz.shark.transaction;import java.util.HashMap;import java.util.Map;import org.ofbiz.base.util.Debug;import org.ofbiz.entity.transaction.GenericTransactionException;import org.ofbiz.entity.transaction.TransactionUtil;import org.enhydra.shark.api.ApplicationMappingTransaction;import org.enhydra.shark.api.ParticipantMappingTransaction;import org.enhydra.shark.api.TransactionException;import org.enhydra.shark.api.UserTransaction;import org.enhydra.shark.api.RepositoryTransaction;import org.enhydra.shark.api.RootException;import org.enhydra.shark.api.internal.transaction.SharkInternalTransaction;import org.enhydra.shark.api.internal.working.WfProcessInternal;import org.enhydra.shark.api.internal.working.WfResourceInternal;/** * Shark JTA Transaction Implementation * * @author     <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a> * @version    $Rev: 5462 $ * @since      3.1 */public class JtaTransaction implements SharkInternalTransaction, UserTransaction,        ApplicationMappingTransaction, ParticipantMappingTransaction, RepositoryTransaction {    public static final String module = JtaTransaction.class.getName();    public static final int transactionTimeout = 120;    protected Map resourceMap = new HashMap();    protected Map processMap = new HashMap();    protected boolean beganTransaction = false;    protected boolean active = false;    protected boolean enabled = true;    public JtaTransaction() {        if (enabled) {            try {                this.beganTransaction = TransactionUtil.begin(transactionTimeout);                active = true;            } catch (GenericTransactionException e) {                Debug.logError(e, module);            }        }    }    public void commit() throws TransactionException {        if (active) {            try {                TransactionUtil.commit(beganTransaction);            } catch (GenericTransactionException e) {                Debug.logError(e, module);                throw new TransactionException(e);            }            active = false;        } else {            Debug.logError(new Exception(), "No active transaction; unable to commit", module);            //throw new TransactionException("No active transaction");        }    }    public void rollback() throws TransactionException {        if (active) {            try {                TransactionUtil.rollback(beganTransaction, "Transaction rollback from Shark", null);            } catch (GenericTransactionException e) {                Debug.logError(e, module);                throw new TransactionException(e);            }            active = false;        } else {            Debug.logError(new Exception(), "No active transaction; unable to rollback", module);            //throw new TransactionException("No active transaction");        }    }    public void release() throws TransactionException {        if (active) {            this.commit();        }            }    public void addToTransaction(String procId, WfProcessInternal proc) throws RootException {        this.processMap.put(procId, proc);    }    public void addToTransaction(String resId, WfResourceInternal res) throws RootException {        this.resourceMap.put(resId, res);    }    public void removeProcess(String procId) throws RootException {        this.processMap.remove(procId);    }    public void removeResource(String resId) throws RootException {        this.resourceMap.remove(resId);    }    public WfProcessInternal getProcess(String procId) throws RootException {        return (WfProcessInternal) this.processMap.get(procId);    }    public WfResourceInternal getResource(String resId) throws RootException {        return (WfResourceInternal) this.resourceMap.get(resId);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -