return xaResource == this;
}
public void start(Xid xid, int flag) throws XAException {
if (flag != XAResource.TMNOFLAGS && flag != XAResource.TMJOIN)
throw new BitronixXAException("unsupported start flag " + Decoder.decodeXAResourceFlag(flag), XAException.XAER_RMERR);
if (xid == null)
throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL);
if (state == NO_TX) {
if (this.xid != null)
throw new BitronixXAException("resource already started on XID " + this.xid, XAException.XAER_PROTO);
else {
if (flag == XAResource.TMJOIN)
throw new BitronixXAException("resource not yet started", XAException.XAER_PROTO);
else {
if (log.isDebugEnabled()) { log.debug("OK to start, old state=" + xlatedState() + ", XID=" + xid + ", flag=" + Decoder.decodeXAResourceFlag(flag)); }
this.xid = xid;
}
}
}
else if (state == STARTED) {
throw new BitronixXAException("resource already started on XID " + this.xid, XAException.XAER_PROTO);
}
else if (state == ENDED) {
if (flag == XAResource.TMNOFLAGS)
throw new BitronixXAException("resource already registered XID " + this.xid, XAException.XAER_DUPID);
else {
if (xid.equals(this.xid)) {
if (log.isDebugEnabled()) { log.debug("OK to join, old state=" + xlatedState() + ", XID=" + xid + ", flag=" + Decoder.decodeXAResourceFlag(flag)); }
}
else
throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot start it on more than one XID at a time", XAException.XAER_RMERR);
}
}
else if (state == PREPARED) {
throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO);
}
this.state = STARTED;
}