@Override public String getNodeName() { return XATxConverter.getNodeName(xidImple.getXID()); }
@Override public int getFormatId() { return xidImple.getFormatId(); }
@Override public byte[] getBranchQualifier() { return xidImple.getBranchQualifier(); }
@Override public byte[] getGlobalTransactionId() { return xidImple.getGlobalTransactionId(); }
public boolean restore_state(InputObjectState os, int t) { boolean res = false; try { _heuristic = os.unpackInt(); _committed = os.unpackBoolean(); _tranID = XidImple.unpack(os); _theXAResource = null; _recoveryObject = null; if (os.unpackInt() == RecoverableXAConnection.OBJECT_RECOVERY) { _productName = os.unpackString(); _productVersion = os.unpackString(); _jndiName = os.unpackString(); boolean haveXAResource = os.unpackBoolean(); if (haveXAResource) { try { // Read the classname of the serialized XAResource String className = os.unpackString(); byte[] b = os.unpackBytes(); ByteArrayInputStream s = new ByteArrayInputStream(b); ObjectInputStream o = new ObjectInputStream(s); // Give the list of deserializers a chance to deserialize the record boolean deserialized = false; Iterator<SerializableXAResourceDeserializer> iterator = getXAResourceDeserializers().iterator(); while (iterator.hasNext()) { SerializableXAResourceDeserializer proxyXAResourceDeserializer = iterator.next(); if (proxyXAResourceDeserializer.canDeserialze(className)) { _theXAResource = proxyXAResourceDeserializer.deserialze(o); deserialized = true; break; } } // Give it a go ourselves if (!deserialized) { _theXAResource = (XAResource) o.readObject(); } o.close(); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("XAResourceRecord.restore_state - XAResource de-serialized"); } } catch (Exception ex) { // not serializable in the first place! jtaLogger.i18NLogger.warn_resources_arjunacore_restorestate(ex); return false; } } else { /* * Lookup new XAResource via XARecoveryModule if possible. */ _theXAResource = getNewXAResource(); if (_theXAResource == null) { jtaLogger.i18NLogger.warn_resources_arjunacore_norecoveryxa(toString()); /* * Don't prevent tx from activating because there may be * other participants that can still recover. Plus, we will * try to get a new XAResource later for this instance. */ res = true; } } } else { String creatorName = os.unpackString(); _recoveryObject = ClassloadingUtility.loadAndInstantiateClass( RecoverableXAConnection.class, creatorName, null); if (_recoveryObject == null) { throw new ClassNotFoundException(); } _recoveryObject.unpackFrom(os); _theXAResource = _recoveryObject.getResource(); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace( "XAResourceRecord.restore_state - XAResource got from " + creatorName); } } res = true; } catch (Exception e) { jtaLogger.i18NLogger.warn_resources_arjunacore_restorestateerror( _theXAResource.toString(), XAHelper.xidToString(_tranID), e); res = false; } if (res) res = super.restore_state(os, t); return res; }
public boolean save_state(OutputObjectState os, int t) { boolean res = false; try { os.packInt(_heuristic); os.packBoolean(_committed); /* * Since we don't know what type of Xid we are using, leave it up to * XID to pack. */ XidImple.pack(os, _tranID); /* * If no recovery object set then rely upon object serialisation! */ if (_recoveryObject == null) { os.packInt(RecoverableXAConnection.OBJECT_RECOVERY); os.packString(_productName); os.packString(_productVersion); os.packString(_jndiName); if (_theXAResource instanceof Serializable) { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); ObjectOutputStream o = new ObjectOutputStream(s); o.writeObject(_theXAResource); o.close(); os.packBoolean(true); String name = _theXAResource.getClass().getName(); os.packString(name); os.packBytes(s.toByteArray()); } catch (NotSerializableException ex) { jtaLogger.i18NLogger.warn_resources_arjunacore_savestate(); return false; } } else { // have to rely upon XAResource.recover! os.packBoolean(false); } } else { os.packInt(RecoverableXAConnection.AUTO_RECOVERY); os.packString(_recoveryObject.getClass().getName()); _recoveryObject.packInto(os); } res = true; } catch (Exception e) { jtaLogger.i18NLogger.warn_resources_arjunacore_savestateerror( _theXAResource.toString(), XAHelper.xidToString(_tranID), e); res = false; } if (res) res = super.save_state(os, t); return res; }