org.omg.CORBA.ServerRequest Java Examples

The following examples show how to use org.omg.CORBA.ServerRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CorbaServerConduitTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testBuildRequestResult() {
    NVList list = orb.create_list(0);
    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);
    CorbaMessage inMsg = EasyMock.createMock(CorbaMessage.class);
    EasyMock.expect(msg.getExchange()).andReturn(exchange);
    EasyMock.expect(exchange.getInMessage()).andReturn(inMsg);

    EasyMock.expect(inMsg.getList()).andReturn(list);
    EasyMock.expect(msg.getStreamableException()).andReturn(null);
    EasyMock.expect(msg.getStreamableArguments()).andReturn(null);
    EasyMock.expect(msg.getStreamableReturn()).andReturn(null);

    control.replay();
    conduit.buildRequestResult(msg);
    control.verify();
}
 
Example #2
Source File: CorbaServerConduit.java    From cxf with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #3
Source File: CorbaDSIServant.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void invoke(ServerRequest request) throws CorbaBindingException {
    String opName = request.operation();
    QName requestOperation = operationMap.get(opName);

    MessageImpl msgImpl = new MessageImpl();
    msgImpl.setDestination(getDestination());
    Exchange exg = new ExchangeImpl();
    exg.put(String.class, requestOperation.getLocalPart());
    exg.put(ORB.class, getOrb());
    exg.put(ServerRequest.class, request);
    msgImpl.setExchange(exg);
    CorbaMessage msg = new CorbaMessage(msgImpl);
    msg.setCorbaTypeMap(typeMap);

    // If there's no output message part in our operation then it's a oneway op
    BindingMessageInfo bindingMsgOutputInfo = null;
    BindingOperationInfo bindingOpInfo = null;
    try {
        bindingOpInfo = this.destination.getEndPointInfo().getBinding().getOperation(requestOperation);
    } catch (Exception ex) {
        throw new CorbaBindingException("Invalid Request. Operation unknown: " + opName);
    }
    if (bindingOpInfo != null) {
        bindingMsgOutputInfo = bindingOpInfo.getOutput();
        if (bindingMsgOutputInfo == null) {
            exg.setOneWay(true);
        }
    }

    // invokes the interceptors
    getObserver().onMessage(msg);
}
 
Example #4
Source File: CorbaStreamFaultOutInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #5
Source File: CorbaServerConduitTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildRequestResultException() {
    NVList list = orb.create_list(0);
    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);
    CorbaMessage inMsg = EasyMock.createMock(CorbaMessage.class);
    EasyMock.expect(msg.getExchange()).andReturn(exchange);
    EasyMock.expect(exchange.getInMessage()).andReturn(inMsg);

    EasyMock.expect(inMsg.getList()).andReturn(list);
    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 exception = new CorbaStreamableImpl(obj, objName);

    EasyMock.expect(msg.getStreamableException()).andReturn(exception);
    EasyMock.expect(msg.getStreamableException()).andReturn(exception);

    control.replay();
    conduit.buildRequestResult(msg);
    control.verify();
}
 
Example #6
Source File: CorbaDSIServantTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #7
Source File: CorbaStreamInInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
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);
}