📄 transactionmanager.java
字号:
/*****************************************************************************
* (C) Copyright 2004 。
* 保留对所有使用、复制、修改和发布整个软件和相关文档的权利。
* 本计算机程序受著作权法和国际公约的保护,未经授权擅自复制或
* 传播本程序的全部或部分,可能受到严厉的民事和刑事制裁,并
* 在法律允许的范围内受到最大可能的起诉。
*/
/*****************************************************************************
* @作者:Golden Peng
* @版本: 1.0
* @时间: 2002-10-08
*/
/*****************************************************************************
* 修改记录清单
* 修改人 :
* 修改记录:
* 修改时间:
* 修改描述:
*
*/
package com.corp.bisc.ebiz.base;
/**
* 此处插入类型描述。
* 创建日期:(2002-5-16 22:39:07)
* @author:Administrator
*/
import javax.transaction.*;
import java.util.*;
import org.w3c.dom.*;
import com.corp.bisc.ebiz.util.*;
import javax.naming.*;
import com.corp.bisc.ebiz.exception.*;
import java.sql.*;
public class TransactionManager extends ObjectBase
{
public final static int TRANSACTION_CONTINUE = 0;
public final static int TRANSACTION_COMMIT = 1;
public final static int TRANSACTION_ROLLBACK = 2;
protected TransactionConfig config = null;
protected int count = 0;
protected Properties props = null;
protected String ctxId = null;
protected boolean isXATransaction = false;
protected Connection conn = null;
protected boolean canRollbackOnly = false;
/**
* TransactionManager 构造子注解。
*/
public TransactionManager() {
super();
}
public void begin() throws SystemException ,
NotSupportedException ,
SQLException
{
enter("begin()");
if (count < 0)
{
throw new IllegalStateException();
}
else if (count++ == 0)
{
beginInternal();
}
leave("begin()");
}
protected void beginInternal() throws SystemException ,
NotSupportedException ,
SQLException
{
enter("beginInternal()");
/*
if (isXATransaction)
getTransaction().begin();
else
getConnection().setAutoCommit(false);
*/
leave("beginTrans()");
}
public void commit() throws RollbackException,
HeuristicMixedException,
HeuristicRollbackException,
SystemException ,
SQLException
{
enter("commit()");
if (count <= 0)
{
throw new IllegalStateException();
}
else if (count-- == 1)
{
commitInternal();
}
leave("commit()");
}
protected void commitDirectly() throws javax.transaction.RollbackException,
HeuristicMixedException,
HeuristicRollbackException,
SystemException ,
SQLException
{
enter("commitDirectly()");
if (count <= 0)
{
throw new IllegalStateException();
}
else
{
count = 0;
commit();
}
leave("commitDirectly()");
}
protected void commitInternal() throws RollbackException,
HeuristicMixedException,
HeuristicRollbackException,
SystemException ,
SQLException
{
enter("commitInternal()");
if (canRollbackOnly)
{
throw new IllegalStateException();
}
if (isXATransaction)
{
getTransaction().commit();
}
else
{
Connection conn = getConnection();
conn.commit();
conn.setAutoCommit(true);
}
leave("commitInternal()");
}
protected Connection getConnection()
{
enterleave("getConnection");
return conn;
}
protected UserTransaction getTransaction()
{
enterleave("getTransaction()");
return config.getUserTransaction();
}
public boolean isInTransaction()
{
enterleave("isInTransaction");
return count > 0;
}
public void rollback() throws SystemException , SQLException
{
enter("rollback()");
/*
if (count <= 0)
{
throw new IllegalStateException();
}
else if (count-- == 1)
{
rollbackInternal();
}
else
{
setRollbackOnly();
}
*/
leave("rollback()");
}
protected void rollbackDirectly() throws SystemException ,
SQLException
{
enter("rollbackDirectly()");
/*
if (count <= 0)
{
throw new IllegalStateException();
}
else
{
count = 0;
rollback();
}
*/
leave("rollbackDirectly()");
}
protected void rollbackInternal() throws SystemException , SQLException
{
enter("rollbackInternal()");
/*
if (isXATransaction)
{
getTransaction().rollback();
}
else
{
Connection conn = getConnection();
conn.setAutoCommit(true);
conn.rollback();
}
*/
leave("rollbackInternal()");
}
protected void setRollbackOnly() throws SystemException
{
/*
canRollbackOnly = true;
if (isXATransaction)
config.getUserTransaction().setRollbackOnly();
*/
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -