Java Code Examples for org.apache.cxf.service.model.ServiceInfo#getDescription()

The following examples show how to use org.apache.cxf.service.model.ServiceInfo#getDescription() . 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: WSDLServiceBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void buildInterface(ServiceInfo si, PortType p) {
    InterfaceInfo inf = si.createInterface(p.getQName());
    DescriptionInfo d = si.getDescription();
    if (null != d) {
        d.getDescribed().add(inf);
    }
    copyDocumentation(inf, p);
    this.copyExtensors(inf, p.getExtensibilityElements());
    this.copyExtensionAttributes(inf, p);
    if (recordOriginal) {
        inf.setProperty(WSDL_PORTTYPE, p);
    }
    for (Operation op : cast(p.getOperations(), Operation.class)) {
        buildInterfaceOperation(inf, op);
    }

}
 
Example 2
Source File: Wsdl11AttachmentPolicyProvider.java    From cxf with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: PortTypeProcessor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static JavaInterface getInterface(
                                   ToolContext context,
                                   ServiceInfo serviceInfo,
                                   InterfaceInfo interfaceInfo) throws ToolException {
    JavaInterface intf = interfaceInfo.getProperty("JavaInterface", JavaInterface.class);
    if (intf == null) {
        intf = new InterfaceMapper(context).map(interfaceInfo);

        JAXWSBinding jaxwsBinding = null;
        if (serviceInfo.getDescription() != null) {
            jaxwsBinding = serviceInfo.getDescription().getExtensor(JAXWSBinding.class);
        }
        JAXWSBinding infBinding = interfaceInfo.getExtensor(JAXWSBinding.class);
        if (infBinding != null && infBinding.getPackage() != null) {
            intf.setPackageName(infBinding.getPackage());
        } else if (jaxwsBinding != null && jaxwsBinding.getPackage() != null) {
            intf.setPackageName(jaxwsBinding.getPackage());
        }

        if (infBinding != null && !infBinding.getPackageJavaDoc().isEmpty()) {
            intf.setPackageJavaDoc(infBinding.getPackageJavaDoc());
        } else if (jaxwsBinding != null && !jaxwsBinding.getPackageJavaDoc().isEmpty()) {
            intf.setPackageJavaDoc(jaxwsBinding.getPackageJavaDoc());
        }

        String name = intf.getName();
        if (infBinding != null
            && infBinding.getJaxwsClass() != null
            && infBinding.getJaxwsClass().getClassName() != null) {
            name = infBinding.getJaxwsClass().getClassName();

            if (name.contains(".")) {
                intf.setPackageName(name.substring(0, name.lastIndexOf('.')));
                name = name.substring(name.lastIndexOf('.') + 1);
            }

            intf.setClassJavaDoc(infBinding.getJaxwsClass().getComments());
        }
        if (StringUtils.isEmpty(intf.getClassJavaDoc())) {
            intf.setClassJavaDoc(interfaceInfo.getDocumentation());
        }

        ClassCollector collector = context.get(ClassCollector.class);
        if (context.optionSet(ToolConstants.CFG_AUTORESOLVE)) {
            int count = 0;
            String checkName = name;
            while (collector.isReserved(intf.getPackageName(), checkName)) {
                checkName = name + "_" + (++count);
            }
            name = checkName;
        } else if (collector.isReserved(intf.getPackageName(), name)) {
            throw new ToolException("RESERVED_SEI_NAME", LOG, name);
        }
        interfaceInfo.setProperty("InterfaceName", name);
        intf.setName(name);
        collector.addSeiClassName(intf.getPackageName(),
                                  intf.getName(),
                                  intf.getPackageName() + "." + intf.getName());

        interfaceInfo.setProperty("JavaInterface", intf);

        if (context.containsKey(ToolConstants.CFG_SEI_SUPER)) {
            String[] supers = context.getArray(ToolConstants.CFG_SEI_SUPER);
            for (String s : supers) {
                intf.addSuperInterface(s);
            }
        }
    }
    return intf;
}
 
Example 4
Source File: PolicyAnnotationListener.java    From cxf with Apache License 2.0 4 votes vote down vote up
private Element addPolicy(ServiceInfo service, Policy p, Class<?> cls, String defName) {
    String uri = p.uri();
    String ns = Constants.URI_POLICY_NS;

    if (p.includeInWSDL()) {
        Element element = loadPolicy(uri, defName);
        if (element == null) {
            return null;
        }

        // might have been updated on load policy
        uri = getPolicyId(element);
        ns = element.getNamespaceURI();

        if (service.getDescription() == null && cls != null) {
            service.setDescription(new DescriptionInfo());
            URL u = cls.getResource("/");
            if (u != null) {
                service.getDescription().setBaseURI(u.toString());
            }
        }

        // if not already added to service add it, otherwise ignore
        // and just create the policy reference.
        if (!isExistsPolicy(service.getDescription().getExtensors().get(), uri)) {
            UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
            uee.setElement(element);
            uee.setRequired(true);
            uee.setElementType(DOMUtils.getElementQName(element));
            service.getDescription().addExtensor(uee);
        }

        uri = "#" + uri;
    }

    Document doc = DOMUtils.getEmptyDocument();
    Element el = doc.createElementNS(ns, "wsp:" + Constants.ELEM_POLICY_REF);
    Attr att = doc.createAttributeNS(null, "URI");
    att.setValue(uri);
    el.setAttributeNodeNS(att);
    return el;
}
 
Example 5
Source File: Wsdl11AttachmentPolicyProvider.java    From cxf with Apache License 2.0 3 votes vote down vote up
/**
 * 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;
}