Search in sources :

Example 66 with ORB

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;
}
Also used : Stub(javax.rmi.CORBA.Stub) ORB(org.omg.CORBA.ORB)

Example 67 with ORB

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);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) CorbaMessage(org.apache.cxf.binding.corba.CorbaMessage) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) Fault(org.apache.cxf.interceptor.Fault) WebFault(javax.xml.ws.WebFault) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException) SystemException(org.omg.CORBA.SystemException) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Exchange(org.apache.cxf.message.Exchange) WebFault(javax.xml.ws.WebFault) CorbaDestination(org.apache.cxf.binding.corba.CorbaDestination) RaisesType(org.apache.cxf.binding.corba.wsdl.RaisesType) SystemException(org.omg.CORBA.SystemException) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) BindingInfo(org.apache.cxf.service.model.BindingInfo) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ORB(org.omg.CORBA.ORB)

Example 68 with ORB

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);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) WrappedParameterSequenceEventProducer(org.apache.cxf.binding.corba.types.WrappedParameterSequenceEventProducer) CorbaMessage(org.apache.cxf.binding.corba.CorbaMessage) QName(javax.xml.namespace.QName) HandlerIterator(org.apache.cxf.binding.corba.types.HandlerIterator) CorbaStreamReader(org.apache.cxf.binding.corba.runtime.CorbaStreamReader) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Exchange(org.apache.cxf.message.Exchange) ParameterEventProducer(org.apache.cxf.binding.corba.types.ParameterEventProducer) CorbaDestination(org.apache.cxf.binding.corba.CorbaDestination) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) CorbaTypeEventProducer(org.apache.cxf.binding.corba.types.CorbaTypeEventProducer) ORB(org.omg.CORBA.ORB)

Example 69 with ORB

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;
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ORB(org.omg.CORBA.ORB)

Example 70 with 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());
}
Also used : Binding(org.omg.CosNaming.Binding) BindingIteratorHolder(org.omg.CosNaming.BindingIteratorHolder) NamingContextExt(org.omg.CosNaming.NamingContextExt) ArrayList(java.util.ArrayList) BindingListHolder(org.omg.CosNaming.BindingListHolder) Properties(java.util.Properties) ORB(org.omg.CORBA.ORB) Ignore(org.junit.Ignore)

Aggregations

ORB (org.omg.CORBA.ORB)73 POA (org.omg.PortableServer.POA)12 Properties (java.util.Properties)10 NamingException (javax.naming.NamingException)8 Test (org.junit.Test)7 AcsProfilingORB (org.jacorb.orb.acs.AcsProfilingORB)6 IOException (java.io.IOException)5 Logger (java.util.logging.Logger)5 HashMap (java.util.HashMap)4 StartException (org.jboss.msc.service.StartException)4 Any (org.omg.CORBA.Any)4 ManagerImpl (com.cosylab.acs.maci.manager.ManagerImpl)3 FileWriter (java.io.FileWriter)3 PrintWriter (java.io.PrintWriter)3 MessageImpl (org.apache.cxf.message.MessageImpl)3 Monitorlong (alma.ACS.Monitorlong)2 DAL (com.cosylab.CDB.DAL)2 HandleDataStore (com.cosylab.acs.maci.manager.HandleDataStore)2 OutputStream (java.io.OutputStream)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2