Java Code Examples for org.apache.cxf.service.model.OperationInfo#setProperty()

The following examples show how to use org.apache.cxf.service.model.OperationInfo#setProperty() . 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: JaxWsServiceFactoryBean.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method) {
    method = ((JaxWsServiceConfiguration)jaxWsConfiguration).getDeclaredMethod(method);
    o.setProperty(Method.class.getName(), method);
    o.setProperty(METHOD, method);
    initializeWrapping(o, method);

    // rpc out-message-part-info class mapping
    Operation op = (Operation)o.getProperty(WSDLServiceBuilder.WSDL_OPERATION);

    initializeClassInfo(o, method, op == null ? null
        : CastUtils.cast(op.getParameterOrdering(), String.class));

    bindOperation(o, method);

    sendEvent(Event.INTERFACE_OPERATION_BOUND, o, method);
}
 
Example 2
Source File: MAPAggregatorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private BindingOperationInfo setUpBindingOperationInfo(String nsuri,
                                                       String opreq,
                                                       String opresp,
                                                       String opfault, Method method) {
    ServiceInfo si = new ServiceInfo();
    InterfaceInfo iinf = new InterfaceInfo(si,
                                           new QName(nsuri, method.getDeclaringClass().getSimpleName()));
    OperationInfo opInfo = iinf.addOperation(new QName(nsuri, method.getName()));
    opInfo.setProperty(Method.class.getName(), method);
    opInfo.setInput(opreq, opInfo.createMessage(new QName(nsuri, opreq), Type.INPUT));
    opInfo.setOutput(opresp, opInfo.createMessage(new QName(nsuri, opresp), Type.INPUT));
    FaultInfo finfo = opInfo.addFault(new QName(nsuri, opfault), new QName(nsuri, opfault));
    finfo.addMessagePart("fault");

    return new TestBindingOperationInfo(opInfo);
}
 
Example 3
Source File: SoapPreProtocolOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private BindingOperationInfo setUpBindingOperationInfo(String nsuri,
                                                       String opreq,
                                                       String opresp,
                                                       Method method) {
    ServiceInfo si = new ServiceInfo();
    InterfaceInfo iinf = new InterfaceInfo(si,
                                           new QName(nsuri, method.getDeclaringClass().getSimpleName()));
    OperationInfo opInfo = iinf.addOperation(new QName(nsuri, method.getName()));
    opInfo.setProperty(Method.class.getName(), method);
    opInfo.setInput(opreq, opInfo.createMessage(new QName(nsuri, opreq), Type.INPUT));
    opInfo.setOutput(opresp, opInfo.createMessage(new QName(nsuri, opresp), Type.INPUT));

    return new BindingOperationInfo(null, opInfo);
}
 
Example 4
Source File: AbstractMessageResponseTestBase.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void setupOperationForMessage() {
    OperationInfo op = EasyMock.createMock(OperationInfo.class);
    BindingOperationInfo bop = EasyMock.createMock(BindingOperationInfo.class);
    EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(bop);
    EasyMock.expect(bop.getOperationInfo()).andReturn(op);
    EasyMock.expect(op.getName()).andReturn(OPERATION_NAME);
    EasyMock.expect(op.getProperty("javax.management.ObjectName", ObjectName.class)).andReturn(null).anyTimes();
    op.setProperty(EasyMock.eq("javax.management.ObjectName"),
                                   EasyMock.anyObject(ObjectName.class));
    EasyMock.expectLastCall();
    EasyMock.replay(bop, op);
}
 
Example 5
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method) {
    // rpc out-message-part-info class mapping
    Operation op = (Operation)o.getProperty(WSDLServiceBuilder.WSDL_OPERATION);

    if (initializeClassInfo(o, method, op == null ? null
        : CastUtils.cast(op.getParameterOrdering(), String.class))) {
        bindOperation(o, method);
        o.setProperty(ReflectionServiceFactoryBean.METHOD, method);
        sendEvent(Event.INTERFACE_OPERATION_BOUND, o, method);
    } else {
        LOG.log(Level.WARNING, "NO_METHOD_FOR_OP", o.getName());
    }
}
 
Example 6
Source File: PolicyAnnotationListener.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void addPolicies(AbstractServiceFactoryBean factory, OperationInfo inf, Method m) {
    if (m == null) {
        return;
    }

    Policy p = m.getAnnotation(Policy.class);
    Policies ps = m.getAnnotation(Policies.class);
    if (p != null || ps != null) {
        List<Policy> list = new ArrayList<>();
        if (p != null) {
            list.add(p);
        }
        if (ps != null) {
            Collections.addAll(list, ps.value());
        }
        ListIterator<Policy> it = list.listIterator();
        while (it.hasNext()) {
            p = it.next();
            Policy.Placement place = p.placement();
            if (place == Policy.Placement.DEFAULT) {
                place = Policy.Placement.BINDING_OPERATION;
            }
            ServiceInfo service = inf.getInterface().getService();
            Class<?> cls = m.getDeclaringClass();
            switch (place) {
            case PORT_TYPE_OPERATION:
                addPolicy(inf, service, p, cls,
                          inf.getName().getLocalPart() + "PortTypeOpPolicy");
                it.remove();
                break;
            case PORT_TYPE_OPERATION_INPUT:
                addPolicy(inf.getInput(), service, p, cls,
                          inf.getName().getLocalPart() + "PortTypeOpInputPolicy");
                it.remove();
                break;
            case PORT_TYPE_OPERATION_OUTPUT:
                addPolicy(inf.getOutput(), service, p, cls,
                          inf.getName().getLocalPart() + "PortTypeOpOutputPolicy");
                it.remove();
                break;
            case PORT_TYPE_OPERATION_FAULT: {
                for (FaultInfo f : inf.getFaults()) {
                    if (p.faultClass().equals(f.getProperty(Class.class.getName()))) {
                        addPolicy(f, service, p, cls,
                                  f.getName().getLocalPart() + "PortTypeOpFaultPolicy");
                        it.remove();
                    }
                }
                break;
            }
            default:
                //nothing
            }
        }

        if (!list.isEmpty()) {
            List<Policy> stuff = CastUtils.cast((List<?>)inf.getProperty(EXTRA_POLICIES));
            if (stuff != null) {
                for (Policy p2 : list) {
                    if (!stuff.contains(p2)) {
                        stuff.add(p2);
                    }
                }
            } else {
                inf.setProperty(EXTRA_POLICIES, list);
            }
        }
    }
}
 
Example 7
Source File: DocLiteralInInterceptorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testUnmarshalSourceData() throws Exception {
    XMLStreamReader reader = StaxUtils.createXMLStreamReader(getClass()
        .getResourceAsStream("resources/multiPartDocLitBareReq.xml"));

    assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());

    XMLStreamReader filteredReader = new PartialXMLStreamReader(reader,
         new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body"));

    // advance the xml reader to the message parts
    StaxUtils.read(filteredReader);
    assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());

    Message m = new MessageImpl();
    Exchange exchange = new ExchangeImpl();

    Service service = control.createMock(Service.class);
    exchange.put(Service.class, service);
    EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding());
    EasyMock.expect(service.size()).andReturn(0).anyTimes();
    EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();

    Endpoint endpoint = control.createMock(Endpoint.class);
    exchange.put(Endpoint.class, endpoint);

    OperationInfo operationInfo = new OperationInfo();
    operationInfo.setProperty("operation.is.synthetic", Boolean.TRUE);
    MessageInfo messageInfo = new MessageInfo(operationInfo, Type.INPUT,
                                              new QName("http://foo.com", "bar"));
    messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo1"), null));
    messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo2"), null));
    messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo3"), null));
    messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo4"), null));

    for (MessagePartInfo mpi : messageInfo.getMessageParts()) {
        mpi.setMessageContainer(messageInfo);
    }

    operationInfo.setInput("inputName", messageInfo);

    BindingOperationInfo boi = new BindingOperationInfo(null, operationInfo);
    exchange.put(BindingOperationInfo.class, boi);

    EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
    BindingInfo binding = control.createMock(BindingInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
    EasyMock.expect(endpointInfo.getBinding()).andReturn(binding).anyTimes();
    EasyMock.expect(binding.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
    EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
    EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
    EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();

    ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
    EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).anyTimes();

    EasyMock.expect(serviceInfo.getName()).andReturn(new QName("http://foo.com", "service")).anyTimes();
    InterfaceInfo interfaceInfo = control.createMock(InterfaceInfo.class);
    EasyMock.expect(serviceInfo.getInterface()).andReturn(interfaceInfo).anyTimes();
    EasyMock.expect(interfaceInfo.getName())
        .andReturn(new QName("http://foo.com", "interface")).anyTimes();

    EasyMock.expect(endpointInfo.getName()).andReturn(new QName("http://foo.com", "endpoint")).anyTimes();
    EasyMock.expect(endpointInfo.getProperty("URI", URI.class)).andReturn(new URI("dummy")).anyTimes();

    List<OperationInfo> operations = new ArrayList<>();
    EasyMock.expect(interfaceInfo.getOperations()).andReturn(operations).anyTimes();

    m.setExchange(exchange);
    m.put(Message.SCHEMA_VALIDATION_ENABLED, false);
    m.setContent(XMLStreamReader.class, reader);

    control.replay();

    new DocLiteralInInterceptor().handleMessage(m);

    MessageContentsList params = (MessageContentsList)m.getContent(List.class);

    assertEquals(4, params.size());
    assertEquals("StringDefaultInputElem",
                 ((DOMSource)params.get(0)).getNode().getFirstChild().getNodeName());
    assertEquals("IntParamInElem",
                 ((DOMSource)params.get(1)).getNode().getFirstChild().getNodeName());
}
 
Example 8
Source File: AnnotationsFactoryBeanListener.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void addSchemaValidationSupport(OperationInfo inf, SchemaValidation annotation) {
    if (annotation != null) {
        inf.setProperty(Message.SCHEMA_VALIDATION_TYPE, annotation.type());
    }
}
 
Example 9
Source File: AnnotationsFactoryBeanListener.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void addDocumentation(OperationInfo inf, Placement defPlace, WSDLDocumentation ... values) {
    List<WSDLDocumentation> later = new ArrayList<>();
    for (WSDLDocumentation doc : values) {
        WSDLDocumentation.Placement p = doc.placement();
        if (p == WSDLDocumentation.Placement.DEFAULT) {
            p = defPlace;
        }
        switch (p) {
        case PORT_TYPE_OPERATION:
            inf.setDocumentation(doc.value());
            break;
        case PORT_TYPE_OPERATION_INPUT:
            inf.getInput().setDocumentation(doc.value());
            break;
        case PORT_TYPE_OPERATION_OUTPUT:
            inf.getOutput().setDocumentation(doc.value());
            break;
        case FAULT_MESSAGE:
        case PORT_TYPE_OPERATION_FAULT: {
            for (FaultInfo f : inf.getFaults()) {
                if (doc.faultClass().equals(f.getProperty(Class.class.getName()))) {
                    if (p == Placement.FAULT_MESSAGE) {
                        f.setMessageDocumentation(doc.value());
                    } else {
                        f.setDocumentation(doc.value());
                    }
                }
            }
            break;
        }
        case INPUT_MESSAGE:
            inf.getInput().setMessageDocumentation(doc.value());
            break;
        case OUTPUT_MESSAGE:
            inf.getOutput().setMessageDocumentation(doc.value());
            break;
        default:
            later.add(doc);
        }
    }
    if (!later.isEmpty()) {
        List<WSDLDocumentation> stuff = CastUtils.cast((List<?>)inf
                                                           .getProperty(EXTRA_DOCUMENTATION));
        if (stuff != null) {
            stuff.addAll(later);
        } else {
            inf.setProperty(EXTRA_DOCUMENTATION, later);
        }
    }
}