Search in sources :

Example 91 with ServiceInfo

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

the class PolicyAnnotationListener method addPolicies.

private void addPolicies(AbstractServiceFactoryBean factory, Endpoint endpoint, Class<?> cls, List<Policy> list, Policy.Placement defaultPlace) {
    ListIterator<Policy> it = list.listIterator();
    InterfaceInfo inf = endpoint.getEndpointInfo().getInterface();
    BindingInfo binf = endpoint.getBinding().getBindingInfo();
    ServiceInfo si = endpoint.getService().getServiceInfos().get(0);
    while (it.hasNext()) {
        Policy p = it.next();
        Policy.Placement place = p.placement();
        if (place == Policy.Placement.DEFAULT) {
            place = defaultPlace;
        }
        switch(place) {
            case PORT_TYPE:
                {
                    addPolicy(inf, si, p, cls, inf.getName().getLocalPart() + "PortTypePolicy");
                    it.remove();
                    break;
                }
            case BINDING:
                {
                    addPolicy(binf, si, p, cls, binf.getName().getLocalPart() + "BindingPolicy");
                    it.remove();
                    break;
                }
            case SERVICE:
                {
                    addPolicy(si, si, p, cls, si.getName().getLocalPart() + "ServicePolicy");
                    it.remove();
                    break;
                }
            case SERVICE_PORT:
                {
                    addPolicy(endpoint.getEndpointInfo(), si, p, cls, endpoint.getEndpointInfo().getName().getLocalPart() + "PortPolicy");
                    it.remove();
                    break;
                }
            default:
        }
    }
}
Also used : Policy(org.apache.cxf.annotations.Policy) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 92 with ServiceInfo

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

the class PolicyAnnotationListener method addPolicies.

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:
            }
        }
        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);
            }
        }
    }
}
Also used : Policy(org.apache.cxf.annotations.Policy) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) Policies(org.apache.cxf.annotations.Policies) ArrayList(java.util.ArrayList)

Example 93 with ServiceInfo

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

the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.

public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) {
    ServiceInfo si = bfi.getBindingOperation().getBinding().getService();
    DescriptionInfo di = si.getDescription();
    Policy p = getElementPolicy(bfi, false, di);
    FaultInfo fi = bfi.getFaultInfo();
    p = mergePolicies(p, getElementPolicy(fi, true, di));
    Extensible ex = getMessageTypeInfo(fi.getName(), di);
    p = mergePolicies(p, getElementPolicy(ex, false, di));
    return p;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Policy(org.apache.neethi.Policy) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) Extensible(org.apache.cxf.service.model.Extensible) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo)

Example 94 with ServiceInfo

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

the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.

/**
 * The effective policy for a specific WSDL message (input or output) is calculated
 * in relation to a specific port, and includes the element policy of the wsdl:message
 * element that defines the message's type merged with the element policy of the
 * wsdl11:binding and wsdl11:portType message definitions that describe the message.
 * For example, the effective policy of a specific input message for a specific port
 * would be the (element policies of the) wsdl11:message element defining the message type,
 * the wsdl11:portType/wsdl11:operation/wsdl11:input element and the corresponding
 * wsdl11:binding/wsdl11:operation/wsdl11:input element for that message.
 *
 * @param bmi the BindingMessageInfo identifiying the message
 * @return the effective policy
 */
public Policy getEffectivePolicy(BindingMessageInfo bmi, Message m) {
    ServiceInfo si = bmi.getBindingOperation().getBinding().getService();
    DescriptionInfo di = si.getDescription();
    Policy p = getElementPolicy(bmi, false, di);
    MessageInfo mi = bmi.getMessageInfo();
    p = mergePolicies(p, getElementPolicy(mi, true, di));
    Extensible ex = getMessageTypeInfo(mi.getName(), di);
    p = mergePolicies(p, getElementPolicy(ex, false, di));
    return p;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Policy(org.apache.neethi.Policy) Extensible(org.apache.cxf.service.model.Extensible) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 95 with ServiceInfo

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

the class ApplicationContextTest method getEndpointInfo.

private EndpointInfo getEndpointInfo(String serviceNS, String endpointLocal, String address) {
    ServiceInfo serviceInfo2 = new ServiceInfo();
    serviceInfo2.setName(new QName(serviceNS, "Service"));
    EndpointInfo info2 = new EndpointInfo(serviceInfo2, "");
    info2.setName(new QName("urn:test:ns", endpointLocal));
    info2.setAddress(address);
    return info2;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) QName(javax.xml.namespace.QName)

Aggregations

ServiceInfo (org.apache.cxf.service.model.ServiceInfo)195 QName (javax.xml.namespace.QName)89 Test (org.junit.Test)76 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)63 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)47 BindingInfo (org.apache.cxf.service.model.BindingInfo)43 OperationInfo (org.apache.cxf.service.model.OperationInfo)37 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)36 Service (org.apache.cxf.service.Service)33 Endpoint (org.apache.cxf.endpoint.Endpoint)31 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)29 File (java.io.File)28 ArrayList (java.util.ArrayList)27 Bus (org.apache.cxf.Bus)26 InputStream (java.io.InputStream)23 Definition (javax.wsdl.Definition)20 Method (java.lang.reflect.Method)16 SchemaCollection (org.apache.cxf.common.xmlschema.SchemaCollection)15 HTTPTransportFactory (org.apache.cxf.transport.http.HTTPTransportFactory)15 IOException (java.io.IOException)12