use of com.arjuna.ats.jta.recovery.SerializableXAResourceDeserializer in project narayana by jbosstm.
the class XAResourceRecord method getXAResourceDeserializers.
private List<SerializableXAResourceDeserializer> getXAResourceDeserializers() {
if (serializableXAResourceDeserializers != null) {
return serializableXAResourceDeserializers;
}
synchronized (this) {
if (serializableXAResourceDeserializers != null) {
return serializableXAResourceDeserializers;
}
serializableXAResourceDeserializers = new ArrayList<SerializableXAResourceDeserializer>();
for (RecoveryModule recoveryModule : RecoveryManager.manager().getModules()) {
if (recoveryModule instanceof XARecoveryModule) {
XARecoveryModule xaRecoveryModule = (XARecoveryModule) recoveryModule;
serializableXAResourceDeserializers.addAll(xaRecoveryModule.getSeriablizableXAResourceDeserializers());
return serializableXAResourceDeserializers;
}
}
}
return serializableXAResourceDeserializers;
}
use of com.arjuna.ats.jta.recovery.SerializableXAResourceDeserializer in project narayana by jbosstm.
the class XAResourceRecord method getXAResourceDeserializers.
private List<SerializableXAResourceDeserializer> getXAResourceDeserializers() {
if (serializableXAResourceDeserializers != null) {
return serializableXAResourceDeserializers;
}
synchronized (this) {
if (serializableXAResourceDeserializers != null) {
return serializableXAResourceDeserializers;
}
serializableXAResourceDeserializers = new ArrayList<SerializableXAResourceDeserializer>();
for (RecoveryModule recoveryModule : RecoveryManager.manager().getModules()) {
if (recoveryModule instanceof XARecoveryModule) {
XARecoveryModule xaRecoveryModule = (XARecoveryModule) recoveryModule;
serializableXAResourceDeserializers.addAll(xaRecoveryModule.getSeriablizableXAResourceDeserializers());
return serializableXAResourceDeserializers;
}
}
}
return serializableXAResourceDeserializers;
}
use of com.arjuna.ats.jta.recovery.SerializableXAResourceDeserializer in project narayana by jbosstm.
the class XAResourceRecord method restore_state.
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) {
try {
_theXAResource = (XAResource) o.readObject();
if (jtaLogger.logger.isTraceEnabled()) {
jtaLogger.logger.trace("XAResourceRecord.restore_state - XAResource de-serialized");
}
} catch (ClassNotFoundException e) {
// JBTM-2550 if we fail to deserialize the object, we treat it as haveXAResource is false
jtaLogger.i18NLogger.warn_resources_arjunacore_classnotfound(className);
haveXAResource = false;
}
}
o.close();
} catch (Exception ex) {
// not serializable in the first place!
jtaLogger.i18NLogger.warn_resources_arjunacore_restorestate(ex);
return false;
}
}
if (!haveXAResource) {
/*
* 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;
} finally {
if (res)
res = super.restore_state(os, t);
if (_heuristic != TwoPhaseOutcome.FINISH_OK) {
jtaLogger.logger.warn("XAResourceRecord restored heuristic instance: " + this);
}
}
return res;
}
use of com.arjuna.ats.jta.recovery.SerializableXAResourceDeserializer in project narayana by jbosstm.
the class XAResourceRecord method restoreState.
public boolean restoreState(InputObjectState os) {
boolean res = false;
try {
_heuristic = os.unpackInt();
_committed = os.unpackBoolean();
_tranID = XidImple.unpack(os);
_theXAResource = null;
_recoveryObject = null;
if (os.unpackInt() == RecoverableXAConnection.OBJECT_RECOVERY) {
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;
}
}
try {
// Give it a go ourselves
if (!deserialized) {
_theXAResource = (XAResource) o.readObject();
}
if (jtaxLogger.logger.isTraceEnabled()) {
jtaxLogger.logger.trace("XAResourceRecord.restore_state - XAResource de-serialized");
}
} catch (ClassNotFoundException cnfe) {
jtaxLogger.i18NLogger.warn_could_not_load_class_will_wait_for_bottom_up(cnfe);
} finally {
o.close();
}
} catch (Exception ex) {
// not serializable in the first place!
jtaxLogger.i18NLogger.warn_jtax_resources_jts_orbspecific_restoreerror1(ex);
return false;
}
}
} 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 (_theXAResource == null) {
jtaxLogger.i18NLogger.warn_jtax_resources_jts_orbspecific_norecoveryxa(XAHelper.xidToString(_tranID));
}
if (jtaxLogger.logger.isTraceEnabled()) {
jtaxLogger.logger.trace("XAResourceRecord.restore_state - XAResource got from " + creatorName);
}
}
boolean haveRecCoord = os.unpackBoolean();
if (haveRecCoord) {
String ior = os.unpackString();
if (ior == null)
return false;
else {
org.omg.CORBA.Object objRef = ORBManager.getORB().orb().string_to_object(ior);
_recoveryCoordinator = RecoveryCoordinatorHelper.narrow(objRef);
}
} else
_recoveryCoordinator = null;
res = true;
} catch (Exception e) {
jtaxLogger.i18NLogger.warn_jtax_resources_jts_orbspecific_restoreerror2(e);
res = false;
} finally {
if (_heuristic != TwoPhaseOutcome.FINISH_OK) {
jtaxLogger.logger.warn("XAResourceRecord restored heuristic instance: " + this);
}
}
return res;
}
Aggregations