use of org.omg.CORBA.UNKNOWN in project narayana by jbosstm.
the class ExtendedResourceRecord method save_state.
/**
* restore_state and save_state for ExtendedResourceRecords doesn't
* generally apply due to object pointers. However, we need to save
* something so we can recover failed transactions. So, rather than insist
* that all Resources derive from a class which we can guarantee will give
* us some unique id, we simply rely on string_to_object and
* object_to_string to be meaningful.
*/
public boolean save_state(OutputObjectState os, int t) {
boolean result = super.save_state(os, t);
if (!result)
return false;
try {
/*
* Do we need to save the parent coordinator handle?
*/
/*
* If we have a _resourceHandle then we stringify it and pack the
* string. Failing that if we have a cached stringified version (in
* _stringifiedResourceHandle) then we pack that. If we have neither
* then we're doomed.
*/
os.packBoolean(_propagateRecord);
if (_cachedUid == null)
_cachedUid = order();
UidHelper.packInto(_cachedUid, os);
if (_cachedType == -1)
_cachedType = typeIs();
os.packInt(_cachedType);
if ((_resourceHandle == null) && (_stringifiedResourceHandle == null)) {
os.packInt(-1);
} else {
os.packInt(1);
String stringRef = null;
if (_resourceHandle != null) {
org.omg.CORBA.ORB theOrb = ORBManager.getORB().orb();
if (theOrb == null)
throw new UNKNOWN();
stringRef = theOrb.object_to_string(_resourceHandle);
theOrb = null;
} else {
stringRef = _stringifiedResourceHandle;
}
if (stringRef != null) {
os.packString(stringRef);
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ExtendedResourceRecord: packed obj ref " + stringRef);
}
} else {
result = false;
}
stringRef = null;
if (result) {
// Pack recovery coordinator Uid
UidHelper.packInto(_recCoordUid, os);
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("Packed rec co uid of " + _recCoordUid);
}
}
os.packBoolean(lastRecord);
}
} catch (IOException e) {
result = false;
} catch (SystemException e) {
result = false;
}
return result;
}
use of org.omg.CORBA.UNKNOWN in project narayana by jbosstm.
the class ResourceRecord method resourceHandle.
public final Resource resourceHandle() {
if ((_resourceHandle == null) && (_stringifiedResourceHandle != null)) {
try {
org.omg.CORBA.ORB theOrb = ORBManager.getORB().orb();
if (theOrb == null)
throw new UNKNOWN();
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ResourceRecord: About to string_to_object on " + _stringifiedResourceHandle);
}
org.omg.CORBA.Object optr = theOrb.string_to_object(_stringifiedResourceHandle);
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ResourceRecord: Successfully stringed to object, next try to narrow");
}
theOrb = null;
_resourceHandle = org.omg.CosTransactions.ResourceHelper.narrow(optr);
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ResourceRecord: Successfully narrowed");
}
if (_resourceHandle == null)
throw new BAD_PARAM();
else {
optr = null;
}
} catch (SystemException e) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ResourceRecord: Failed to narrow to Resource");
}
}
}
return _resourceHandle;
}
use of org.omg.CORBA.UNKNOWN in project narayana by jbosstm.
the class ResourceRecord method save_state.
public boolean save_state(OutputObjectState os, int t) {
boolean result = super.save_state(os, t);
if (!result)
return false;
try {
if ((resourceHandle() == null) && (_stringifiedResourceHandle == null)) {
os.packInt(-1);
} else {
os.packInt(1);
String stringRef = null;
if (_resourceHandle != null) {
org.omg.CORBA.ORB theOrb = ORBManager.getORB().orb();
if (theOrb == null)
throw new UNKNOWN();
stringRef = theOrb.object_to_string(_resourceHandle);
theOrb = null;
} else {
stringRef = _stringifiedResourceHandle;
}
if (stringRef != null) {
os.packString(stringRef);
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ResourceRecord: packed obj ref " + stringRef);
}
} else {
result = false;
}
stringRef = null;
if (result) {
// Pack recovery coordinator Uid
UidHelper.packInto(_recCoordUid, os);
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("Packed rec co uid of " + _recCoordUid);
}
}
}
} catch (IOException e) {
result = false;
} catch (SystemException e) {
result = false;
}
return result;
}
use of org.omg.CORBA.UNKNOWN in project narayana by jbosstm.
the class ContextServerRequestInterceptorImpl method suspendContext.
/*
* If there is a thread id associated with PICurrent then it will
* have been placed there by a server-side thread which executed in
* the application object and needed to associate an imported
* transaction with itself. In which case we need to do the
* equivalent of a suspend to remove the thread from Current and
* from the current transaction.
*/
private void suspendContext(ServerRequestInfo request_info) throws SystemException, InvalidSlot {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextServerRequestInterceptorImpl.suspendContext ( " + request_info.operation() + " )");
}
Any data = request_info.get_slot(_dataSlot);
if ((data != null) && (data.type().kind().value() != TCKind._tk_null)) {
String threadId = null;
try {
if ((threadId = data.extract_string()) != null) {
ControlWrapper ctx = OTSImpleManager.current().contextManager().popAction(threadId);
OTSImpleManager.current().contextManager().purgeActions(threadId);
if (ctx != null) {
try {
OTSManager.destroyControl(ctx.getControl());
ctx = null;
} catch (Exception e) {
jtsLogger.i18NLogger.warn_orbspecific_javaidl_interceptors_context_srie("ContextServerRequestInterceptorImpl.suspendContext", e);
throw new UNKNOWN(e.toString());
}
}
}
} catch (BAD_OPERATION be) {
// not a string, so still a pgctx
}
request_info.set_slot(_dataSlot, null);
}
}
use of org.omg.CORBA.UNKNOWN in project narayana by jbosstm.
the class InterpositionClientRequestInterceptorImpl method send_request.
public void send_request(ClientRequestInfo request_info) throws SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
trace_request("send_request", request_info);
}
if (systemCall(request_info))
return;
final boolean otsAlwaysPropagate = InterceptorInfo.getAlwaysPropagate();
try {
if (!otsAlwaysPropagate) {
TransactionalObject ptr = TransactionalObjectHelper.narrow(request_info.target());
if (ptr == null)
throw new BAD_PARAM();
} else {
/**
* If the value is not null then we are currently in use *
*/
if (_inUse.get() != null) {
return;
} else {
_inUse.set(_inUse);
}
}
try {
/*
* We get back an Any, which contains a key which we must
* now use to get the actual transaction context. This saves
* use having to pack and unpack the context every time it
* changes, even if we don't then make a remote invocation.
*/
Any localData = request_info.get_slot(_localSlot);
String threadId = null;
boolean problem = false;
Any data = null;
if (localData.type().kind().value() != TCKind._tk_null) {
if ((threadId = localData.extract_string()) == null)
throw new UNKNOWN(jtsLogger.i18NLogger.get_orbspecific_javaidl_interceptors_interposition_invalidparam());
} else
threadId = ThreadUtil.getThreadId();
if (threadId != null) {
ControlWrapper theControl = OTSImpleManager.current().contextManager().current(threadId);
if (theControl != null) {
try {
Coordinator theCoordinator = theControl.get_coordinator();
PropagationContext ctx = null;
if (theCoordinator != null) {
final Coordinator finalTheCoordinator = theCoordinator;
try {
ctx = doPrivileged(new PrivilegedExceptionAction<PropagationContext>() {
@Override
public PropagationContext run() throws Unavailable {
return finalTheCoordinator.get_txcontext();
}
});
} catch (PrivilegedActionException pex) {
throw pex.getException();
}
data = packPropagationContext(ctx);
theCoordinator = null;
} else
throw new Unavailable();
} catch (Unavailable ex) {
/*
* We may have to make calls during
* commit (e.g., after_completion)
* which are valid, but which will get
* Unavailable.
*/
problem = true;
}
} else
problem = true;
} else
problem = true;
if (problem) {
if (InterceptorInfo.getNeedTranContext())
throw new TRANSACTION_REQUIRED();
}
if (data != null) {
byte[] octets;
try {
final Any finalData = data;
octets = doPrivileged(new PrivilegedExceptionAction<byte[]>() {
@Override
public byte[] run() throws org.omg.CORBA.UserException {
return _codec.encode_value(finalData);
}
});
} catch (PrivilegedActionException pex) {
throw pex.getException();
}
ServiceContext service_context = new ServiceContext(OTSManager.serviceId, octets);
request_info.add_request_service_context(service_context, true);
}
} catch (SystemException e) {
throw e;
} catch (Exception ex) {
throw new UNKNOWN(ex.toString());
} finally {
/**
* If we are set to always propagate then ensure we clear the inuse flag *
*/
if (otsAlwaysPropagate) {
_inUse.set(null);
}
}
} catch (BAD_PARAM ex) {
// narrow failed, so not a transactional object.
}
}
Aggregations