use of com.arjuna.ats.jta.xa.RecoverableXAConnection in project narayana by jbosstm.
the class XAOnePhaseResource method unpack.
/**
* Unpack the state of the resource.
* @param is The object input state.
*/
public void unpack(final InputObjectState is) throws IOException {
XidImple.unpack(is);
final int recoveryType = is.unpackInt();
switch(recoveryType) {
case RecoverableXAConnection.AUTO_RECOVERY:
final String recoverableXAConnectionClassName = is.unpackString();
recoverableXAConnection = ClassloadingUtility.loadAndInstantiateClass(RecoverableXAConnection.class, recoverableXAConnectionClassName, null);
if (recoverableXAConnection == null) {
throw generateUnpackError(new ClassNotFoundException());
}
recoverableXAConnection.unpackFrom(is);
try {
xaResource = recoverableXAConnection.getResource();
} catch (final SQLException sqle) {
throw generateUnpackError(sqle);
}
break;
case RecoverableXAConnection.OBJECT_RECOVERY:
final byte[] data = is.unpackBytes();
try {
final ByteArrayInputStream bais = new ByteArrayInputStream(data);
final ObjectInputStream ois = new ObjectInputStream(bais);
xaResource = (XAResource) ois.readObject();
} catch (final ClassNotFoundException cnfe) {
throw generateUnpackError(cnfe);
} catch (final IOException ioe) {
throw generateUnpackError(ioe);
} catch (final ClassCastException cce) {
throw generateUnpackError(cce);
}
break;
default:
final String message = jtaLogger.i18NLogger.get_resources_arjunacore_XAOnePhaseResource_unpackType(Integer.toString(recoveryType));
throw new IOException(message);
}
}
Aggregations