[Mulgara-svn] r646 - branches/mgr-73/src/jar/resolver-spi/java/org/mulgara/resolver/spi
ronald at mulgara.org
ronald at mulgara.org
Mon Feb 18 13:37:14 UTC 2008
Author: ronald
Date: 2008-02-18 05:37:11 -0800 (Mon, 18 Feb 2008)
New Revision: 646
Modified:
branches/mgr-73/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DummyXAResource.java
Log:
Miscellaneous cleanups:
* adjust for current formatting standards
* use generics on flagMap
* use StringBuilder instead of StringBuffer
Modified: branches/mgr-73/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DummyXAResource.java
===================================================================
--- branches/mgr-73/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DummyXAResource.java 2008-02-18 11:28:26 UTC (rev 645)
+++ branches/mgr-73/src/jar/resolver-spi/java/org/mulgara/resolver/spi/DummyXAResource.java 2008-02-18 13:37:11 UTC (rev 646)
@@ -54,15 +54,14 @@
public class DummyXAResource implements XAResource
{
/** Logger. */
- private static final Logger logger =
- Logger.getLogger(DummyXAResource.class.getName());
+ private static final Logger logger = Logger.getLogger(DummyXAResource.class.getName());
/**
* Map from keyed from the {@link Integer} value of the various flags
* defined in {@link XAResource} and mapping to the formatted name for that
* flag.
*/
- private final static Map flagMap = new HashMap();
+ private final static Map<Integer,String> flagMap = new HashMap<Integer,String>();
static {
flagMap.put(new Integer(XAResource.TMENDRSCAN), "TMENDRSCAN");
@@ -87,9 +86,10 @@
*
* @param transactionTimeout transaction timeout period, in seconds
*/
- public DummyXAResource(int transactionTimeout)
- {
- logger.debug("Creating DummyXAResource with timeout " + transactionTimeout);
+ public DummyXAResource(int transactionTimeout) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Creating DummyXAResource with timeout " + transactionTimeout);
+ }
this.transactionTimeout = transactionTimeout;
}
@@ -97,61 +97,70 @@
// Methods implementing XAResource
//
- public void commit(Xid xid, boolean onePhase) throws XAException
- {
- logger.debug("Commit xid=" + System.identityHashCode(xid) + " onePhase=" + onePhase);
+ public void commit(Xid xid, boolean onePhase) throws XAException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Commit xid=" + System.identityHashCode(xid) + " onePhase=" + onePhase);
+ }
}
- public void end(Xid xid, int flags) throws XAException
- {
- logger.debug("End xid=" + System.identityHashCode(xid) + " flags=" + formatFlags(flags));
+ public void end(Xid xid, int flags) throws XAException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("End xid=" + System.identityHashCode(xid) + " flags=" + formatFlags(flags));
+ }
}
- public void forget(Xid xid) throws XAException
- {
- logger.debug("Forget xid=" + System.identityHashCode(xid));
+ public void forget(Xid xid) throws XAException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Forget xid=" + System.identityHashCode(xid));
+ }
}
- public int getTransactionTimeout() throws XAException
- {
- logger.debug("Get transaction timeout: " + transactionTimeout);
+ public int getTransactionTimeout() throws XAException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Get transaction timeout: " + transactionTimeout);
+ }
return transactionTimeout;
}
- public boolean isSameRM(XAResource xaResource) throws XAException
- {
- logger.debug("Is same resource manager? " + (xaResource == this));
+ public boolean isSameRM(XAResource xaResource) throws XAException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Is same resource manager? " + (xaResource == this));
+ }
return xaResource == this;
}
- public int prepare(Xid xid) throws XAException
- {
- logger.debug("Prepare " + System.identityHashCode(xid));
+ public int prepare(Xid xid) throws XAException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Prepare " + System.identityHashCode(xid));
+ }
return XA_OK;
}
- public Xid[] recover(int flag) throws XAException
- {
- logger.debug("Recover flag=" + formatFlags(flag));
+ public Xid[] recover(int flag) throws XAException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Recover flag=" + formatFlags(flag));
+ }
throw new XAException(XAException.XAER_RMERR);
}
- public void rollback(Xid xid) throws XAException
- {
- logger.debug("Rollback " + System.identityHashCode(xid));
+ public void rollback(Xid xid) throws XAException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Rollback " + System.identityHashCode(xid));
+ }
}
- public boolean setTransactionTimeout(int transactionTimeout)
- throws XAException
- {
- logger.debug("Set transaction timeout: " + transactionTimeout);
+ public boolean setTransactionTimeout(int transactionTimeout) throws XAException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Set transaction timeout: " + transactionTimeout);
+ }
this.transactionTimeout = transactionTimeout;
return true;
}
- public void start(Xid xid, int flags) throws XAException
- {
- logger.debug("Start " + System.identityHashCode(xid) + " flags=" + formatFlags(flags));
+ public void start(Xid xid, int flags) throws XAException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Start " + System.identityHashCode(xid) + " flags=" + formatFlags(flags));
+ }
}
//
@@ -161,23 +170,20 @@
/**
* Format bitmasks defined by {@link XAResource}.
*
- * @param flags a bitmask composed from the constants defined in
- * {@link XAResource}
+ * @param flags a bitmask composed from the constants defined in {@link XAResource}
* @return a formatted representation of the <var>flags</var>
*/
- private static String formatFlags(int flags)
- {
+ private static final String formatFlags(int flags) {
// Short-circuit evaluation if we've been explicitly passed no flags
if (flags == XAResource.TMNOFLAGS) {
return "TMNOFLAGS";
}
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
// Add any flags that are present
- for (Iterator i = flagMap.entrySet().iterator(); i.hasNext(); ) {
- Map.Entry entry = (Map.Entry)i.next();
- int entryFlag = ((Integer)entry.getKey()).intValue();
+ for (Map.Entry<Integer,String> entry : flagMap.entrySet()) {
+ int entryFlag = entry.getKey().intValue();
// If this flag is present, add it to the formatted output and remove
// from the bitmask
More information about the Mulgara-svn
mailing list