📄 transactionmanager.java~1~
字号:
package com.ibm.bisc.ebiz.base;
/**
* 此处插入类型描述。
* 创建日期:(2002-5-16 22:39:07)
* @author:Administrator
*/
import javax.transaction.*;
import java.util.*;
import org.w3c.dom.*;
import com.ibm.bisc.ebiz.util.*;
import javax.naming.*;
import com.ibm.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 + -