Search in sources :

Example 1 with InterfaceMapper

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.mapper.InterfaceMapper in project cxf by apache.

the class PortTypeProcessor method getInterface.

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().equals("")) {
            intf.setPackageJavaDoc(infBinding.getPackageJavaDoc());
        } else if (jaxwsBinding != null && !jaxwsBinding.getPackageJavaDoc().equals("")) {
            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;
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) ClassCollector(org.apache.cxf.tools.util.ClassCollector) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) ToolException(org.apache.cxf.tools.common.ToolException) InterfaceMapper(org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.mapper.InterfaceMapper)

Aggregations

ToolException (org.apache.cxf.tools.common.ToolException)1 JavaInterface (org.apache.cxf.tools.common.model.JavaInterface)1 ClassCollector (org.apache.cxf.tools.util.ClassCollector)1 JAXWSBinding (org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding)1 InterfaceMapper (org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.mapper.InterfaceMapper)1