Skip to content
Permalink
Browse files
merge logging improvements from branches/2.1 rev 984262 (from branche…
…s/2.1.1 rev 981270)

git-svn-id: https://svn.apache.org/repos/asf/geronimo/components/txmanager/trunk@984470 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
djencks committed Aug 11, 2010
1 parent 81c1e23 commit b55c8a73fcdd960248538fcff5e5b40929df9c62
Showing 1 changed file with 49 additions and 1 deletion.
@@ -21,7 +21,8 @@
import javax.transaction.xa.Xid;
import javax.transaction.xa.XAException;

import org.apache.geronimo.transaction.manager.NamedXAResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
*
@@ -30,6 +31,7 @@
*
* */
public class WrapperNamedXAResource implements NamedXAResource {
protected static Logger log = LoggerFactory.getLogger(WrapperNamedXAResource.class.getName());

private final XAResource xaResource;
private final String name;
@@ -46,14 +48,23 @@ public String getName() {
}

public void commit(Xid xid, boolean onePhase) throws XAException {
if (log.isTraceEnabled()) {
log.trace("Commit called on XAResource " + getName() + "\n Xid: " + xid + "\n onePhase:" + onePhase);
}
xaResource.commit(xid, onePhase);
}

public void end(Xid xid, int flags) throws XAException {
if (log.isTraceEnabled()) {
log.trace("End called on XAResource " + getName() + "\n Xid: " + xid + "\n flags:" + decodeFlags(flags));
}
xaResource.end(xid, flags);
}

public void forget(Xid xid) throws XAException {
if (log.isTraceEnabled()) {
log.trace("Forget called on XAResource " + getName() + "\n Xid: " + xid);
}
xaResource.forget(xid);
}

@@ -69,14 +80,23 @@ public boolean isSameRM(XAResource other) throws XAException {
}

public int prepare(Xid xid) throws XAException {
if (log.isTraceEnabled()) {
log.trace("Prepare called on XAResource " + getName() + "\n Xid: " + xid);
}
return xaResource.prepare(xid);
}

public Xid[] recover(int flag) throws XAException {
if (log.isTraceEnabled()) {
log.trace("Recover called on XAResource " + getName() + "\n flags: " + decodeFlags(flag));
}
return xaResource.recover(flag);
}

public void rollback(Xid xid) throws XAException {
if (log.isTraceEnabled()) {
log.trace("Rollback called on XAResource " + getName() + "\n Xid: " + xid);
}
xaResource.rollback(xid);
}

@@ -85,8 +105,36 @@ public boolean setTransactionTimeout(int seconds) throws XAException {
}

public void start(Xid xid, int flags) throws XAException {
if (log.isTraceEnabled()) {
log.trace("Start called on XAResource " + getName() + "\n Xid: " + xid + "\n flags:" + decodeFlags(flags));
}
xaResource.start(xid, flags);
}
private String decodeFlags(int flags) {
if (flags == 0) {
return " TMNOFLAGS";
}
StringBuilder b = new StringBuilder();
decodeFlag(flags, b, TMENDRSCAN, " TMENDRSCAN");
decodeFlag(flags, b, TMFAIL, " TMFAIL");
decodeFlag(flags, b, TMJOIN, " TMJOIN");
decodeFlag(flags, b, TMONEPHASE, " TMONEPHASE");
decodeFlag(flags, b, TMRESUME, " TMRESUME");
decodeFlag(flags, b, TMSTARTRSCAN, " TMSTARTRSCAN");
decodeFlag(flags, b, TMSUCCESS, " TMSUCCESS");
decodeFlag(flags, b, TMSUSPEND, " TMSUSPEND");
if (flags != 0) {
b.append(" remaining: ").append(flags);
}
return b.toString();
}

private void decodeFlag(int flags, StringBuilder b, int flag, String flagName) {
if ((flags & flag) == flag) {
b.append(flagName);
flags = flags ^ flag;
}
}
}


0 comments on commit b55c8a7

Please sign in to comment.