Search in sources :

Example 1 with ServerRequest

use of org.omg.CORBA.ServerRequest in project cxf by apache.

the class CorbaDSIServantTest method testInvoke.

/*public void testCorbaDSIServant() throws Exception {

        CorbaDestination destination = testUtils.getSimpleTypesTestDestination();
        Service service = new ServiceImpl();
        Endpoint endpoint = new EndpointImpl(bus, service, destination.getEndPointInfo());
        MessageObserver observer = new ChainInitiationObserver(endpoint, bus);
        destination.setMessageObserver(observer);
        POA rootPOA = null;
        CorbaDSIServant dsiServant = new CorbaDSIServant();
        dsiServant.init(orb,
                        rootPOA,
                        destination,
                        observer);

        assertNotNull("DSIServant should not be null", dsiServant != null);
        assertNotNull("POA should not be null", dsiServant._default_POA() != null);
        assertNotNull("Destination should not be null", dsiServant.getDestination() != null);
        assertNotNull("ORB should not be null", dsiServant.getOrb() != null);
        assertNotNull("MessageObserver should not be null", dsiServant.getObserver() != null);

        byte[] objectId = new byte[10];
        String[] interfaces = dsiServant._all_interfaces(rootPOA, objectId);
        assertNotNull("Interfaces should not be null", interfaces != null);
        assertEquals("Interface ID should be equal", interfaces[0], "IDL:Simple:1.0");

    }*/
@Test
public void testInvoke() throws Exception {
    CorbaDestination dest = new TestUtils().getComplexTypesTestDestination();
    CorbaDSIServant dsiServant = new CorbaDSIServant();
    dsiServant.init(orb, null, dest, null);
    ServerRequest request = new ServerRequest() {

        public String operation() {
            return "greetMe";
        }

        public Context ctx() {
            return null;
        }
    };
    MessageObserver incomingObserver = new TestObserver();
    dsiServant.setObserver(incomingObserver);
    Map<String, QName> map = new HashMap<>(2);
    map.put("greetMe", new QName("greetMe"));
    dsiServant.setOperationMapping(map);
    dsiServant.invoke(request);
}
Also used : TestUtils(org.apache.cxf.binding.corba.TestUtils) CorbaDestination(org.apache.cxf.binding.corba.CorbaDestination) MessageObserver(org.apache.cxf.transport.MessageObserver) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ServerRequest(org.omg.CORBA.ServerRequest) Test(org.junit.Test)

Example 2 with ServerRequest

use of org.omg.CORBA.ServerRequest in project cxf by apache.

the class CorbaServerConduit method buildRequestResult.

public void buildRequestResult(CorbaMessage msg) {
    Exchange exg = msg.getExchange();
    ServerRequest request = exg.get(ServerRequest.class);
    try {
        if (!exg.isOneWay()) {
            CorbaMessage inMsg = (CorbaMessage) msg.getExchange().getInMessage();
            NVList list = inMsg.getList();
            if (msg.getStreamableException() != null) {
                Any exAny = CorbaAnyHelper.createAny(orb);
                CorbaStreamable exception = msg.getStreamableException();
                exAny.insert_Streamable(exception);
                request.set_exception(exAny);
                if (msg.getExchange() != null) {
                    msg.getExchange().setOutFaultMessage(msg);
                }
            } else {
                CorbaStreamable[] arguments = msg.getStreamableArguments();
                if (arguments != null) {
                    for (int i = 0; i < arguments.length; ++i) {
                        if (list.item(i).flags() != org.omg.CORBA.ARG_IN.value) {
                            arguments[i].getObject().setIntoAny(list.item(i).value(), arguments[i], true);
                        }
                    }
                }
                CorbaStreamable resultValue = msg.getStreamableReturn();
                if (resultValue != null) {
                    Any resultAny = CorbaAnyHelper.createAny(orb);
                    resultValue.getObject().setIntoAny(resultAny, resultValue, true);
                    request.set_result(resultAny);
                }
            }
        }
    } catch (java.lang.Exception ex) {
        throw new CorbaBindingException("Exception during buildRequestResult", ex);
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) ServerRequest(org.omg.CORBA.ServerRequest) NVList(org.omg.CORBA.NVList) Any(org.omg.CORBA.Any)

Example 3 with ServerRequest

use of org.omg.CORBA.ServerRequest in project cxf by apache.

the class CorbaStreamFaultOutInterceptor method setSystemException.

protected void setSystemException(CorbaMessage message, Throwable ex, CorbaDestination dest) {
    SystemException sysEx = (SystemException) ex;
    message.setSystemException(sysEx);
    ServerRequest request = message.getExchange().get(ServerRequest.class);
    Any exAny = dest.getOrbConfig().createSystemExceptionAny(orb, sysEx);
    request.set_exception(exAny);
}
Also used : SystemException(org.omg.CORBA.SystemException) ServerRequest(org.omg.CORBA.ServerRequest) Any(org.omg.CORBA.Any)

Example 4 with ServerRequest

use of org.omg.CORBA.ServerRequest in project cxf by apache.

the class CorbaStreamInInterceptor method handleRequest.

private void handleRequest(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;
    Exchange exchange = message.getExchange();
    CorbaTypeMap typeMap = message.getCorbaTypeMap();
    BindingInfo bInfo = destination.getBindingInfo();
    InterfaceInfo info = bInfo.getInterface();
    String opName = exchange.get(String.class);
    Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
    OperationType opType = null;
    BindingOperationInfo bopInfo = null;
    QName opQName = null;
    while (i.hasNext()) {
        bopInfo = i.next();
        if (bopInfo.getName().getLocalPart().equals(opName)) {
            opType = bopInfo.getExtensor(OperationType.class);
            opQName = bopInfo.getName();
            break;
        }
    }
    if (opType == null) {
        throw new RuntimeException("Couldn't find the binding operation for " + opName);
    }
    orb = exchange.get(ORB.class);
    ServerRequest request = exchange.get(ServerRequest.class);
    NVList list = prepareArguments(message, info, opType, opQName, typeMap, destination, service);
    request.arguments(list);
    message.setList(list);
    HandlerIterator paramIterator = new HandlerIterator(message, true);
    CorbaTypeEventProducer eventProducer = null;
    BindingMessageInfo msgInfo = bopInfo.getInput();
    boolean wrap = false;
    if (bopInfo.isUnwrappedCapable()) {
        wrap = true;
    }
    if (wrap) {
        // wrapper element around our args
        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 : CorbaTypeMap(org.apache.cxf.binding.corba.CorbaTypeMap) 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) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) CorbaTypeEventProducer(org.apache.cxf.binding.corba.types.CorbaTypeEventProducer) ServerRequest(org.omg.CORBA.ServerRequest) NVList(org.omg.CORBA.NVList) ORB(org.omg.CORBA.ORB)

Example 5 with ServerRequest

use of org.omg.CORBA.ServerRequest in project cxf by apache.

the class CorbaServerConduitTest method testBuildRequestResultArgumentReturn.

@Test
public void testBuildRequestResultArgumentReturn() {
    CorbaStreamable[] arguments = new CorbaStreamable[1];
    QName objName = new QName("object");
    QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
    TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
    CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable arg = new CorbaStreamableImpl(obj, objName);
    arguments[0] = arg;
    arguments[0].setMode(org.omg.CORBA.ARG_OUT.value);
    NVList nvlist = orb.create_list(2);
    Any value = orb.create_any();
    value.insert_Streamable(arguments[0]);
    nvlist.add_value(arguments[0].getName(), value, arguments[0].getMode());
    CorbaServerConduit conduit = setupCorbaServerConduit(false);
    CorbaMessage msg = control.createMock(CorbaMessage.class);
    Exchange exchange = control.createMock(Exchange.class);
    ServerRequest request = control.createMock(ServerRequest.class);
    EasyMock.expect(msg.getExchange()).andReturn(exchange);
    EasyMock.expect(exchange.get(ServerRequest.class)).andReturn(request);
    EasyMock.expect(exchange.isOneWay()).andReturn(false);
    EasyMock.expect(msg.getExchange()).andReturn(exchange);
    Message message = new MessageImpl();
    CorbaMessage corbaMessage = new CorbaMessage(message);
    corbaMessage.setList(nvlist);
    EasyMock.expect(exchange.getInMessage()).andReturn(corbaMessage);
    EasyMock.expect(msg.getStreamableException()).andReturn(null);
    EasyMock.expect(msg.getStreamableArguments()).andReturn(arguments);
    EasyMock.expect(msg.getStreamableReturn()).andReturn(arg);
    control.replay();
    conduit.buildRequestResult(msg);
    control.verify();
}
Also used : CorbaStreamableImpl(org.apache.cxf.binding.corba.runtime.CorbaStreamableImpl) Message(org.apache.cxf.message.Message) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Any(org.omg.CORBA.Any) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) Exchange(org.apache.cxf.message.Exchange) NVList(org.omg.CORBA.NVList) ServerRequest(org.omg.CORBA.ServerRequest) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Aggregations

ServerRequest (org.omg.CORBA.ServerRequest)7 Exchange (org.apache.cxf.message.Exchange)5 NVList (org.omg.CORBA.NVList)5 QName (javax.xml.namespace.QName)4 Test (org.junit.Test)4 Any (org.omg.CORBA.Any)3 CorbaDestination (org.apache.cxf.binding.corba.CorbaDestination)2 CorbaStreamableImpl (org.apache.cxf.binding.corba.runtime.CorbaStreamableImpl)2 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)2 TypeCode (org.omg.CORBA.TypeCode)2 HashMap (java.util.HashMap)1 CorbaMessage (org.apache.cxf.binding.corba.CorbaMessage)1 CorbaTypeMap (org.apache.cxf.binding.corba.CorbaTypeMap)1 TestUtils (org.apache.cxf.binding.corba.TestUtils)1 CorbaStreamReader (org.apache.cxf.binding.corba.runtime.CorbaStreamReader)1 CorbaTypeEventProducer (org.apache.cxf.binding.corba.types.CorbaTypeEventProducer)1 HandlerIterator (org.apache.cxf.binding.corba.types.HandlerIterator)1 ParameterEventProducer (org.apache.cxf.binding.corba.types.ParameterEventProducer)1 WrappedParameterSequenceEventProducer (org.apache.cxf.binding.corba.types.WrappedParameterSequenceEventProducer)1 OperationType (org.apache.cxf.binding.corba.wsdl.OperationType)1