use of org.omg.CORBA.BAD_PARAM 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) {
ctx = theCoordinator.get_txcontext();
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 = _codec.encode_value(data);
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.
}
}
use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.
the class InterpositionServerRequestInterceptorImpl method receive_request_service_contexts.
public void receive_request_service_contexts(ServerRequestInfo request_info) throws SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
trace_request("receive_request_service_contexts", request_info);
}
try {
try {
if (!InterceptorInfo.getAlwaysPropagate()) {
if (!request_info.target_is_a(TransactionalObjectHelper.id()))
throw new BAD_PARAM();
}
} catch (Exception ex) {
// just in case the object isn't in the IR.
}
try {
ServiceContext serviceContext = null;
try {
serviceContext = request_info.get_request_service_context(OTSManager.serviceId);
} catch (BAD_PARAM bp) {
// no context, so nothing shipped!
serviceContext = null;
}
if (serviceContext != null) {
Any receivedData = _codec.decode_value(serviceContext.context_data, PropagationContextHelper.type());
/*
* Set the slot information for the "current" thread. When
* the real invocation thread actually needs to get its
* transaction context it must check this slot (if it does
* not have a transaction context already) and then do
* a resume.
*/
request_info.set_slot(_dataSlot, receivedData);
} else {
if (InterceptorInfo.getNeedTranContext())
throw new TRANSACTION_REQUIRED();
}
} catch (TRANSACTION_REQUIRED ex) {
throw ex;
} catch (Exception e) {
}
} catch (BAD_PARAM ex) {
}
}
use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.
the class ContextClientRequestInterceptorImpl method send_request.
public void send_request(ClientRequestInfo request_info) throws SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextClientRequestInterceptorImpl::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;
String stringRef = null;
if ((localData != null) && (localData.type().kind().value() != TCKind._tk_null)) {
if ((threadId = localData.extract_string()) == null)
throw new UNKNOWN(jtsLogger.i18NLogger.get_orbspecific_jacorb_interceptors_context_invalidparam());
} else
threadId = ThreadUtil.getThreadId();
if (threadId != null) {
ControlWrapper theControl = OTSImpleManager.current().contextManager().current(threadId);
if (theControl != null) {
try {
Coordinator theCoordinator = theControl.get_coordinator();
if (theCoordinator != null) {
stringRef = ORBManager.getORB().orb().object_to_string(theCoordinator);
} else {
problem = true;
}
} catch (Unavailable e) {
problem = true;
}
theControl = null;
} else
problem = true;
} else
problem = true;
if (problem) {
if (InterceptorInfo.getNeedTranContext())
throw new TRANSACTION_REQUIRED();
else
stringRef = null;
}
if (stringRef != null) {
Any data = ORBManager.getORB().orb().create_any();
data.insert_string(stringRef);
byte[] octets = _codec.encode_value(data);
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) {
jtsLogger.i18NLogger.warn_orbspecific_jacorb_interceptors_context_error(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.
} catch (OBJECT_NOT_EXIST ex) {
}
}
use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.
the class ContextServerRequestInterceptorImpl method receive_request_service_contexts.
public void receive_request_service_contexts(ServerRequestInfo request_info) throws SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextServerRequestInterceptorImpl::receive_request_service_contexts ( " + request_info.operation() + " )");
}
try {
try {
if (!InterceptorInfo.getAlwaysPropagate()) {
if (!request_info.target_is_a(TransactionalObjectHelper.id()))
throw new BAD_PARAM();
}
} catch (Exception ex) {
// just in case the object isn't in the IR.
}
try {
ServiceContext serviceContext = null;
try {
serviceContext = request_info.get_request_service_context(OTSManager.serviceId);
} catch (BAD_PARAM bp) {
// no context, so nothing shipped!
serviceContext = null;
}
if (serviceContext != null) {
Any receivedData = _codec.decode_value(serviceContext.context_data, ORBManager.getORB().orb().get_primitive_tc(TCKind.tk_string));
/*
* Set the slot information for the "current" thread. When
* the real invocation thread actually needs to get its
* transaction context it must check this slot (if it does
* not have a transaction context already) and then do
* a resume.
*/
request_info.set_slot(_dataSlot, receivedData);
} else {
if (InterceptorInfo.getNeedTranContext())
throw new TRANSACTION_REQUIRED();
}
} catch (TRANSACTION_REQUIRED ex) {
ex.printStackTrace();
throw ex;
} catch (Exception e) {
e.printStackTrace();
}
} catch (BAD_PARAM ex) {
} catch (Exception exp) {
exp.printStackTrace();
}
}
use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.
the class Services method getService.
public org.omg.CORBA.Object getService(String serviceName, Object[] params, int mechanism) throws org.omg.CORBA.ORBPackage.InvalidName, IOException, SystemException {
org.omg.CORBA.Object objRef = null;
switch(mechanism) {
case RESOLVE_INITIAL_REFERENCES:
{
try {
objRef = _orb.orb().resolve_initial_references(serviceName);
} catch (SystemException ex) {
throw ex;
} catch (InvalidName exp) {
throw exp;
} catch (Exception e) {
if (opLogger.logger.isTraceEnabled()) {
opLogger.logger.trace("Services.getService - resolve_initial_references on " + serviceName + " failed: " + e.toString());
}
throw new InvalidName();
}
}
break;
case NAME_SERVICE:
{
String kind = ((params == null) ? null : (String) params[0]);
try {
org.omg.CORBA.Object nsRef = _orb.orb().resolve_initial_references(Services.nameService);
NamingContext ncRef = NamingContextHelper.narrow(nsRef);
// bind the Object Reference in Naming
NameComponent nc = new NameComponent(serviceName, kind);
NameComponent[] path = { nc };
objRef = ncRef.resolve(path);
} catch (SystemException ex) {
throw ex;
} catch (UserException e) {
throw new org.omg.CORBA.ORBPackage.InvalidName();
}
}
break;
case CONFIGURATION_FILE:
{
String cosservicesRoot = opPropertyManager.getOrbPortabilityEnvironmentBean().getInitialReferencesRoot();
String configLocation = opPropertyManager.getOrbPortabilityEnvironmentBean().getInitialReferencesFile();
String configFile = cosservicesRoot + File.separatorChar + configLocation;
LineNumberReader input;
try {
input = new LineNumberReader(new FileReader(configFile));
} catch (FileNotFoundException e) {
if (opLogger.logger.isTraceEnabled()) {
opLogger.logger.trace("Services.getService could not open config file " + configFile);
}
throw new InvalidName();
}
String ior = null;
try {
boolean finished = false;
while ((ior == null) && !finished) {
String line = input.readLine();
if (line == null)
finished = true;
else {
int occur = line.indexOf(serviceName);
if (// should be first on line
occur == 0)
// +1 for space separator
ior = line.substring(serviceName.length() + 1);
}
}
input.close();
} catch (SystemException ex) {
input.close();
throw ex;
} catch (Exception e) {
opLogger.i18NLogger.warn_Services_unexpectedexception("Services.getService", e);
input.close();
throw new UNKNOWN();
}
if (ior == null) {
opLogger.i18NLogger.warn_Services_servicenotfound(serviceName, configFile);
throw new InvalidName();
} else {
try {
objRef = _orb.orb().string_to_object(ior);
} catch (Exception e) {
objRef = null;
}
}
}
break;
case FILE:
{
try {
String fileDir = opPropertyManager.getOrbPortabilityEnvironmentBean().getFileDir();
File f = null;
if (fileDir != null && fileDir.length() != 0)
f = new File(fileDir + File.separator + serviceName);
else
f = new File(serviceName);
FileInputStream ifile = new FileInputStream(f);
int size = (int) f.length();
byte[] b = new byte[size];
ifile.read(b);
ifile.close();
String objString = new String(b, StandardCharsets.UTF_8);
objRef = _orb.orb().string_to_object(objString);
objString = null;
} catch (SystemException ex) {
throw ex;
} catch (FileNotFoundException e) {
throw new InvalidName();
}
}
break;
case NAMED_CONNECT:
{
opLogger.i18NLogger.warn_Services_unsupportedoption("NAMED_CONNECT");
throw new BAD_PARAM();
}
}
return objRef;
}
Aggregations