use of org.omg.CORBA.ORB in project tomee by apache.
the class Corbas method connect.
public static Object connect(final Object obj) throws IOException {
if (obj instanceof Stub) {
final Stub stub = (Stub) obj;
final ORB orb = getORB();
stub.connect(orb);
}
return obj;
}
use of org.omg.CORBA.ORB in project cxf by apache.
the class CorbaStreamFaultOutInterceptor method handleMessage.
public void handleMessage(Message msg) {
CorbaMessage message = (CorbaMessage) msg;
Exchange exchange = message.getExchange();
CorbaDestination destination;
Fault faultEx = null;
if (message.getDestination() != null) {
destination = (CorbaDestination) message.getDestination();
} else {
destination = (CorbaDestination) exchange.getDestination();
}
orb = (ORB) message.get(CorbaConstants.ORB);
if (orb == null) {
orb = exchange.get(ORB.class);
}
DataWriter<XMLStreamWriter> writer = getDataWriter(message);
Throwable ex = message.getContent(Exception.class);
// is a Fault instance and contains a detail object.
if (ex.getCause() == null) {
if ((ex instanceof Fault) && (((Fault) ex).getDetail() != null)) {
faultEx = (Fault) ex;
} else {
throw new CorbaBindingException(ex);
}
} else {
ex = ex.getCause();
}
if (ex instanceof InvocationTargetException) {
ex = ex.getCause();
}
if (ex instanceof SystemException) {
setSystemException(message, ex, destination);
return;
}
String exClassName = null;
if (faultEx == null) {
// REVISIT, we should not have to depend on WebFault annotation
// Try changing the fault name to the proper mangled java exception classname.
WebFault fault = ex.getClass().getAnnotation(WebFault.class);
if (fault == null) {
throw new CorbaBindingException(ex);
}
exClassName = fault.name();
} else {
// JCGS: exClassName to be set to the exception name
Element faultElement = (Element) faultEx.getDetail().getFirstChild();
exClassName = faultElement.getLocalName();
}
// Get information about the operation being invoked from the WSDL
// definition.
// We need this to marshal data correctly
BindingInfo bInfo = destination.getBindingInfo();
String opName = message.getExchange().get(String.class);
Iterator<BindingOperationInfo> iter = bInfo.getOperations().iterator();
BindingOperationInfo bopInfo = null;
OperationType opType = null;
while (iter.hasNext()) {
bopInfo = iter.next();
if (bopInfo.getName().getLocalPart().equals(opName)) {
opType = bopInfo.getExtensor(OperationType.class);
break;
}
}
if (opType == null) {
throw new CorbaBindingException("Unable to find binding operation for " + opName);
}
OperationInfo opInfo = bopInfo.getOperationInfo();
if (faultEx != null) {
MessagePartInfo partInfo = getFaultMessagePartInfo(opInfo, new QName("", exClassName));
if (partInfo != null) {
exClassName = partInfo.getTypeQName().getLocalPart();
}
}
RaisesType exType = getRaisesType(opType, exClassName, ex);
try {
if (exType != null) {
if (faultEx != null) {
setUserExceptionFromFaultDetail(message, faultEx.getDetail(), exType, opInfo, writer, exchange.getEndpoint().getEndpointInfo().getService());
} else {
setUserException(message, ex, exType, opInfo, writer, exchange.getEndpoint().getEndpointInfo().getService());
}
} else {
throw new CorbaBindingException(ex);
}
} catch (Exception exp) {
throw new CorbaBindingException(exp);
}
}
use of org.omg.CORBA.ORB in project cxf by apache.
the class CorbaStreamInInterceptor method handleReply.
private void handleReply(Message msg) {
ORB orb;
ServiceInfo service;
CorbaDestination destination;
if (msg.getDestination() != null) {
destination = (CorbaDestination) msg.getDestination();
} else {
destination = (CorbaDestination) msg.getExchange().getDestination();
}
service = destination.getBindingInfo().getService();
CorbaMessage message = (CorbaMessage) msg;
if (message.getStreamableException() != null || message.getSystemException() != null) {
message.setContent(Exception.class, message.getExchange().getOutMessage().getContent(Exception.class));
Endpoint ep = message.getExchange().getEndpoint();
message.getInterceptorChain().abort();
if (ep.getInFaultObserver() != null) {
ep.getInFaultObserver().onMessage(message);
return;
}
}
CorbaMessage outMessage = (CorbaMessage) message.getExchange().getOutMessage();
orb = message.getExchange().get(ORB.class);
HandlerIterator paramIterator = new HandlerIterator(outMessage, false);
CorbaTypeEventProducer eventProducer = null;
Exchange exchange = message.getExchange();
BindingOperationInfo bindingOpInfo = exchange.getBindingOperationInfo();
BindingMessageInfo msgInfo = bindingOpInfo.getOutput();
boolean wrap = false;
if (bindingOpInfo.isUnwrappedCapable()) {
wrap = true;
}
if (wrap) {
// wrapper element around our args
// REVISIT, bravi, message name same as the element name
QName wrapperElementQName = msgInfo.getMessageInfo().getName();
eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName, paramIterator, service, orb);
} else {
eventProducer = new ParameterEventProducer(paramIterator, service, orb);
}
CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
message.setContent(XMLStreamReader.class, reader);
}
use of org.omg.CORBA.ORB in project cxf by apache.
the class CorbaBindingHelper method createAddressSpecificORB.
private static ORB createAddressSpecificORB(String address, Properties props, List<String> orbArgs) {
ORB orb = null;
URI addressURI = null;
try {
addressURI = new URI(address);
} catch (URISyntaxException ex) {
throw new CorbaBindingException("Unable to create ORB with address " + address);
}
String scheme = addressURI.getScheme();
// host and port used when no preference has been specified.
if ("corbaloc".equals(scheme)) {
String schemeSpecificPart = addressURI.getSchemeSpecificPart();
int keyIndex = schemeSpecificPart.indexOf('/');
String corbaAddr = schemeSpecificPart.substring(0, keyIndex);
int index = corbaAddr.indexOf(':');
String protocol = "iiop";
if (index != 0) {
protocol = corbaAddr.substring(0, index);
}
int oldIndex = index;
index = corbaAddr.indexOf(':', oldIndex + 1);
String host = corbaAddr.substring(oldIndex + 1, index);
String port = corbaAddr.substring(index + 1);
props.put("yoko.orb.oa.endpoint", new String(protocol + " --host " + host + " --port " + port));
// WHAT to do for non-yoko orb?
} else if ("corbaname".equals(scheme)) {
String schemeSpecificPart = addressURI.getSchemeSpecificPart();
if (schemeSpecificPart.startsWith(":")) {
schemeSpecificPart = schemeSpecificPart.substring(1);
}
int idx = schemeSpecificPart.indexOf(':');
props.put("org.omg.CORBA.ORBInitialHost", schemeSpecificPart.substring(0, idx));
props.put("org.omg.CORBA.ORBInitialPort", schemeSpecificPart.substring(idx + 1));
} else if ("file".equals(scheme) || "relfile".equals(scheme) || "IOR".equals(scheme) || "ior".equals(scheme)) {
// use defaults
} else {
throw new CorbaBindingException("Unsupported address scheme type " + scheme);
}
orb = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
orbList.put(getORBNameFromAddress(address), orb);
return orb;
}
use of org.omg.CORBA.ORB in project narayana by jbosstm.
the class NamingServiceClient method test.
@Ignore
public void test() throws InvalidName {
String[] args = new String[2];
args[0] = "-ORBInitRef";
args[1] = "NameService=corbaloc::localhost:3528/NameService";
Properties props = new Properties();
props.put("org.omg.CORBA.ORBInitialPort", "3528");
props.put("org.omg.CORBA.ORBInitialHost", "localhost");
ORB orb = ORB.init(args, props);
NamingContextExt nc = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
BindingListHolder bl = new BindingListHolder();
BindingIteratorHolder blIt = new BindingIteratorHolder();
nc.list(1000, bl, blIt);
Binding[] bindings = bl.value;
List<String> toResolve = new ArrayList<String>();
toResolve.add("TransactionManagerService");
for (int i = 0; i < bindings.length; i++) {
int lastIx = bindings[i].binding_name.length - 1;
// check to see if this is a naming context
if (bindings[i].binding_type == BindingType.ncontext) {
log.info("Context: " + bindings[i].binding_name[lastIx].id);
} else {
log.info("Object: " + bindings[i].binding_name[lastIx].id);
}
toResolve.remove(bindings[i].binding_name[lastIx].id);
}
assertTrue(toResolve.isEmpty());
}
Aggregations