Author: david.lloyd(a)jboss.com
Date: 2009-01-14 22:48:15 -0500 (Wed, 14 Jan 2009)
New Revision: 4814
Modified:
remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientImpl.java
Log:
clarify some code
Modified:
remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientImpl.java
===================================================================
---
remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientImpl.java 2009-01-15
03:43:01 UTC (rev 4813)
+++
remoting-txn/trunk/src/main/java/org/jboss/remoting/txn/impl/TransactionalClientImpl.java 2009-01-15
03:48:15 UTC (rev 4814)
@@ -75,14 +75,6 @@
}
}
- private static TxnReply doInvoke(Client<TxnRequest, TxnReply> txnClient,
TxnRequest request) throws XAException {
- try {
- return txnClient.invoke(request);
- } catch (IOException e) {
- throw xaException(e);
- }
- }
-
public void start() throws IOException {
txnClient.invoke(TxnRequest.StartLocal.INSTANCE);
}
@@ -141,19 +133,37 @@
}
public void commit(final Xid xid, final boolean onePhase) throws XAException {
- doInvoke(txnClient, new TxnRequest.CommitXA(xid, onePhase));
+ try {
+ txnClient.invoke(new TxnRequest.CommitXA(xid, onePhase));
+ } catch (IOException e) {
+ throw xaException(e);
+ }
}
public void end(final Xid xid, final int flags) throws XAException {
- doInvoke(txnClient, new TxnRequest.EndXA(xid, flags));
+ try {
+ txnClient.invoke(new TxnRequest.EndXA(xid, flags));
+ } catch (IOException e) {
+ throw xaException(e);
+ }
}
public void forget(final Xid xid) throws XAException {
- doInvoke(txnClient, new TxnRequest.ForgetXA(xid));
+ try {
+ txnClient.invoke(new TxnRequest.ForgetXA(xid));
+ } catch (IOException e) {
+ throw xaException(e);
+ }
}
public int getTransactionTimeout() throws XAException {
- return ((TxnReply.Timeout) doInvoke(txnClient,
TxnRequest.GetTimeout.INSTANCE)).getTimeout();
+ final TxnReply result;
+ try {
+ result = txnClient.invoke(TxnRequest.GetTimeout.INSTANCE);
+ } catch (IOException e) {
+ throw xaException(e);
+ }
+ return ((TxnReply.Timeout) result).getTimeout();
}
public boolean isSameRM(final XAResource resource) throws XAException {
@@ -170,23 +180,49 @@
}
public int prepare(final Xid xid) throws XAException {
- return ((TxnReply.Prepared) doInvoke(txnClient, new
TxnRequest.PrepareXA(xid))).getVote();
+ final TxnReply result;
+ try {
+ result = txnClient.invoke(new TxnRequest.PrepareXA(xid));
+ } catch (IOException e) {
+ throw xaException(e);
+ }
+ return ((TxnReply.Prepared) result).getVote();
}
public Xid[] recover(final int flag) throws XAException {
- return ((TxnReply.Recover) doInvoke(txnClient, new
TxnRequest.Recover(flag))).getResources();
+ final TxnReply result;
+ try {
+ result = txnClient.invoke(new TxnRequest.Recover(flag));
+ } catch (IOException e) {
+ throw xaException(e);
+ }
+ return ((TxnReply.Recover) result).getResources();
}
public void rollback(final Xid xid) throws XAException {
- doInvoke(txnClient, new TxnRequest.RollbackXA(xid));
+ try {
+ txnClient.invoke(new TxnRequest.RollbackXA(xid));
+ } catch (IOException e) {
+ throw xaException(e);
+ }
}
public boolean setTransactionTimeout(final int timeout) throws XAException {
- return ((TxnReply.TimeoutSet) doInvoke(txnClient, new
TxnRequest.SetTimeout(timeout))).getSuccess();
+ final TxnReply result;
+ try {
+ result = txnClient.invoke(new TxnRequest.SetTimeout(timeout));
+ } catch (IOException e) {
+ throw xaException(e);
+ }
+ return ((TxnReply.TimeoutSet) result).getSuccess();
}
public void start(final Xid xid, final int flags) throws XAException {
- doInvoke(txnClient, new TxnRequest.StartXA(xid, flags));
+ try {
+ txnClient.invoke(new TxnRequest.StartXA(xid, flags));
+ } catch (IOException e) {
+ throw xaException(e);
+ }
}
}
}
Show replies by date