Search in sources :

Example 81 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.

the class PolicyEngineTest method testSetEffectiveServerRequestPolicy.

@Test
public void testSetEffectiveServerRequestPolicy() throws Exception {
    engine = new PolicyEngineImpl();
    EndpointInfo ei = createMockEndpointInfo();
    BindingOperationInfo boi = createMockBindingOperationInfo();
    EffectivePolicy effectivePolicy = control.createMock(EffectivePolicy.class);
    control.replay();
    engine.setEffectiveServerRequestPolicy(ei, boi, effectivePolicy);
    assertSame(effectivePolicy, engine.getEffectiveServerRequestPolicy(ei, boi, msg));
    control.verify();
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Test(org.junit.Test)

Example 82 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.

the class PolicyEngineTest method testGetAggregatedOperationPolicy.

@Test
public void testGetAggregatedOperationPolicy() throws Exception {
    engine = new PolicyEngineImpl();
    BindingOperationInfo boi = createMockBindingOperationInfo();
    control.replay();
    Policy p = engine.getAggregatedOperationPolicy(boi, null);
    assertTrue(p.isEmpty());
    control.verify();
    control.reset();
    PolicyProvider provider1 = control.createMock(PolicyProvider.class);
    engine.getPolicyProviders().add(provider1);
    Policy p1 = control.createMock(Policy.class);
    EasyMock.expect(provider1.getEffectivePolicy(boi, null)).andReturn(p1);
    control.replay();
    assertSame(p1, engine.getAggregatedOperationPolicy(boi, null));
    control.verify();
    control.reset();
    PolicyProvider provider2 = control.createMock(PolicyProvider.class);
    engine.getPolicyProviders().add(provider2);
    Policy p2 = control.createMock(Policy.class);
    Policy p3 = control.createMock(Policy.class);
    EasyMock.expect(provider1.getEffectivePolicy(boi, null)).andReturn(p1);
    EasyMock.expect(provider2.getEffectivePolicy(boi, null)).andReturn(p2);
    EasyMock.expect(p1.merge(p2)).andReturn(p3);
    control.replay();
    assertSame(p3, engine.getAggregatedOperationPolicy(boi, null));
    control.verify();
}
Also used : Policy(org.apache.neethi.Policy) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Test(org.junit.Test)

Example 83 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo 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 84 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.

the class CorbaStreamInInterceptor method prepareArguments.

protected NVList prepareArguments(CorbaMessage corbaMsg, InterfaceInfo info, OperationType opType, QName opQName, CorbaTypeMap typeMap, CorbaDestination destination, ServiceInfo service) {
    BindingInfo bInfo = destination.getBindingInfo();
    EndpointInfo eptInfo = destination.getEndPointInfo();
    BindingOperationInfo bOpInfo = bInfo.getOperation(opQName);
    OperationInfo opInfo = bOpInfo.getOperationInfo();
    Exchange exg = corbaMsg.getExchange();
    exg.put(BindingInfo.class, bInfo);
    exg.put(InterfaceInfo.class, info);
    exg.put(EndpointInfo.class, eptInfo);
    exg.put(EndpointReferenceType.class, destination.getAddress());
    exg.put(ServiceInfo.class, service);
    exg.put(BindingOperationInfo.class, bOpInfo);
    exg.put(OperationInfo.class, opInfo);
    exg.put(MessageInfo.class, opInfo.getInput());
    exg.put(String.class, opQName.getLocalPart());
    exg.setInMessage(corbaMsg);
    corbaMsg.put(MessageInfo.class, opInfo.getInput());
    List<ParamType> paramTypes = opType.getParam();
    CorbaStreamable[] arguments = new CorbaStreamable[paramTypes.size()];
    return prepareDIIArgsList(corbaMsg, bOpInfo, arguments, paramTypes, typeMap, exg.get(ORB.class), service);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) BindingInfo(org.apache.cxf.service.model.BindingInfo) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) ORB(org.omg.CORBA.ORB)

Example 85 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.

the class CorbaStreamOutEndingInterceptor method handleOutBoundMessage.

private void handleOutBoundMessage(CorbaMessage message, BindingOperationInfo boi) {
    OperationInfo opInfo = boi.getOperationInfo();
    OperationType opType = boi.getExtensor(OperationType.class);
    List<ParamType> paramTypes = opType.getParam();
    MessageInfo outMsgInfo = opInfo.getOutput();
    String wrapNSUri = null;
    boolean wrap = false;
    if (boi.isUnwrappedCapable()) {
        wrap = true;
        if (outMsgInfo != null) {
            wrapNSUri = getWrappedParamNamespace(outMsgInfo);
            if (!CorbaUtils.isElementFormQualified(service, wrapNSUri)) {
                wrapNSUri = "";
            }
        }
    }
    CorbaStreamWriter writer = (CorbaStreamWriter) message.getContent(XMLStreamWriter.class);
    CorbaObjectHandler[] objs = writer.getCorbaObjects();
    int count = 0;
    int msgIndex = 0;
    ArgType returnParam = opType.getReturn();
    if (returnParam != null) {
        QName retName;
        if (wrap) {
            retName = new QName(wrapNSUri, returnParam.getName());
        } else {
            retName = getMessageParamQName(outMsgInfo, returnParam.getName(), msgIndex);
        }
        QName retIdlType = returnParam.getIdltype();
        CorbaObjectHandler obj = CorbaHandlerUtils.initializeObjectHandler(orb, retName, retIdlType, typeMap, service);
        CorbaStreamable streamable = message.createStreamableObject(obj, retName);
        message.setStreamableReturn(streamable);
        msgIndex++;
    }
    for (Iterator<ParamType> iter = paramTypes.iterator(); iter.hasNext(); ) {
        ParamType param = iter.next();
        QName idlType = param.getIdltype();
        QName paramName;
        CorbaObjectHandler obj = null;
        if (param.getMode().equals(ModeType.OUT)) {
            if (wrap) {
                paramName = new QName(wrapNSUri, param.getName());
            } else {
                paramName = getMessageParamQName(outMsgInfo, param.getName(), msgIndex);
            }
            obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, idlType, typeMap, service);
            msgIndex++;
        } else {
            obj = objs[count++];
            paramName = obj.getName();
        }
        CorbaStreamable streamable = message.createStreamableObject(obj, paramName);
        ModeType paramMode = param.getMode();
        if (paramMode.value().equals("in")) {
            streamable.setMode(org.omg.CORBA.ARG_IN.value);
        } else if (paramMode.value().equals("inout")) {
            streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
        }
        // default mode is out
        message.addStreamableArgument(streamable);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) MessageInfo(org.apache.cxf.service.model.MessageInfo) CorbaStreamWriter(org.apache.cxf.binding.corba.runtime.CorbaStreamWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) ModeType(org.apache.cxf.binding.corba.wsdl.ModeType) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType)

Aggregations

BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)214 QName (javax.xml.namespace.QName)82 BindingInfo (org.apache.cxf.service.model.BindingInfo)57 Test (org.junit.Test)55 Exchange (org.apache.cxf.message.Exchange)50 OperationInfo (org.apache.cxf.service.model.OperationInfo)47 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)42 Endpoint (org.apache.cxf.endpoint.Endpoint)41 Message (org.apache.cxf.message.Message)36 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)36 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)32 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)31 Service (org.apache.cxf.service.Service)29 Fault (org.apache.cxf.interceptor.Fault)24 MessageInfo (org.apache.cxf.service.model.MessageInfo)24 MessageContentsList (org.apache.cxf.message.MessageContentsList)23 Method (java.lang.reflect.Method)22 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)22 ArrayList (java.util.ArrayList)21 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)16