Search in sources :

Example 16 with JavaInterface

use of org.apache.cxf.tools.common.model.JavaInterface in project cxf by apache.

the class SimpleImplGenerator method generate.

public void generate(ToolContext penv) throws ToolException {
    this.env = penv;
    JavaModel javaModel = env.get(JavaModel.class);
    if (passthrough()) {
        return;
    }
    Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
    for (JavaInterface intf : interfaces.values()) {
        clearAttributes();
        setAttributes("intf", intf);
        setAttributes("seiClass", env.get(ToolConstants.SEI_CLASS));
        setCommonAttributes();
        doWrite(IMPL_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName() + "Impl"));
        env.put(ToolConstants.IMPL_CLASS, intf.getFullClassName() + "Impl");
    }
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) JavaModel(org.apache.cxf.tools.common.model.JavaModel)

Example 17 with JavaInterface

use of org.apache.cxf.tools.common.model.JavaInterface in project cxf by apache.

the class PortTypeProcessor method process.

public void process(ServiceInfo serviceInfo) throws ToolException {
    operationMap.clear();
    JavaModel jmodel = context.get(JavaModel.class);
    InterfaceInfo interfaceInfo = serviceInfo.getInterface();
    if (interfaceInfo == null) {
        return;
    }
    JavaInterface intf = getInterface(context, serviceInfo, interfaceInfo);
    intf.setJavaModel(jmodel);
    Element handler = (Element) context.get(ToolConstants.HANDLER_CHAIN);
    intf.setHandlerChains(handler);
    Collection<OperationInfo> operations = interfaceInfo.getOperations();
    for (OperationInfo operation : operations) {
        if (isOverloading(operation.getName())) {
            LOG.log(Level.WARNING, "SKIP_OVERLOADED_OPERATION", operation.getName());
            continue;
        }
        OperationProcessor operationProcessor = new OperationProcessor(context);
        operationProcessor.process(intf, operation);
    }
    jmodel.setLocation(intf.getLocation());
    jmodel.addInterface(intf.getName(), intf);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) JavaModel(org.apache.cxf.tools.common.model.JavaModel) Element(org.w3c.dom.Element) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 18 with JavaInterface

use of org.apache.cxf.tools.common.model.JavaInterface in project cxf by apache.

the class ServiceProcessor method processPort.

private JavaPort processPort(JavaModel model, ServiceInfo si, EndpointInfo port) throws ToolException {
    BindingInfo binding = port.getBinding();
    String portType = binding.getInterface().getName().getLocalPart();
    JavaInterface intf = PortTypeProcessor.getInterface(context, si, binding.getInterface());
    JavaPort jport = new JavaPort(NameUtil.mangleNameToClassName(port.getName().getLocalPart()));
    jport.setPackageName(intf.getPackageName());
    jport.setPortName(port.getName().getLocalPart());
    jport.setBindingAdress(port.getAddress());
    jport.setBindingName(binding.getName().getLocalPart());
    jport.setPortType(portType);
    jport.setInterfaceClass(intf.getName());
    bindingType = getBindingType(binding);
    if (bindingType == null) {
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_SPECIFY_ONE_PROTOCOL", LOG, binding.getName());
        throw new ToolException(msg);
    }
    if (isSoapBinding()) {
        SoapBinding spbd = SOAPBindingUtil.getProxy(SoapBinding.class, this.bindingObj);
        jport.setStyle(SOAPBindingUtil.getSoapStyle(spbd.getStyle()));
        jport.setTransURI(spbd.getTransportURI());
    }
    Collection<BindingOperationInfo> operations = binding.getOperations();
    for (BindingOperationInfo bop : operations) {
        processOperation(model, bop, binding);
    }
    jport.setJavaDoc(port.getDocumentation());
    JAXWSBinding bind = port.getExtensor(JAXWSBinding.class);
    if (bind != null) {
        jport.setMethodName(bind.getMethodName());
        jport.setJavaDoc(bind.getMethodJavaDoc());
    }
    return jport;
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.common.i18n.Message) Message(org.apache.cxf.common.i18n.Message) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) JavaPort(org.apache.cxf.tools.common.model.JavaPort) BindingInfo(org.apache.cxf.service.model.BindingInfo) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) ToolException(org.apache.cxf.tools.common.ToolException)

Example 19 with JavaInterface

use of org.apache.cxf.tools.common.model.JavaInterface in project cxf by apache.

the class BindingAnnotator method annotate.

public void annotate(JavaAnnotatable ja) {
    JavaInterface intf;
    if (ja instanceof JavaInterface) {
        intf = (JavaInterface) ja;
    } else {
        throw new RuntimeException("BindingAnnotator can only annotate JavaInterface");
    }
    if (processBinding(intf)) {
        JAnnotation bindingAnnotation = new JAnnotation(SOAPBinding.class);
        if (!SOAPBinding.Style.DOCUMENT.equals(intf.getSOAPStyle())) {
            bindingAnnotation.addElement(new JAnnotationElement("style", intf.getSOAPStyle()));
        }
        if (!SOAPBinding.Use.LITERAL.equals(intf.getSOAPUse())) {
            bindingAnnotation.addElement(new JAnnotationElement("use", intf.getSOAPUse()));
        }
        if (intf.getSOAPStyle() == SOAPBinding.Style.DOCUMENT && intf.getSOAPParameterStyle() != SOAPBinding.ParameterStyle.WRAPPED) {
            bindingAnnotation.addElement(new JAnnotationElement("parameterStyle", intf.getSOAPParameterStyle()));
        }
        intf.addAnnotation(bindingAnnotation);
    }
    for (JavaMethod method : intf.getMethods()) {
        if (!method.isAsync()) {
            method.annotate(new SoapBindingAnnotator());
        }
    }
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) JAnnotation(org.apache.cxf.tools.common.model.JAnnotation) JAnnotationElement(org.apache.cxf.tools.common.model.JAnnotationElement) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod)

Example 20 with JavaInterface

use of org.apache.cxf.tools.common.model.JavaInterface in project cxf by apache.

the class WebServiceAnnotator method annotate.

public void annotate(JavaAnnotatable ja) {
    JavaInterface intf = null;
    if (ja instanceof JavaInterface) {
        intf = (JavaInterface) ja;
    } else {
        throw new RuntimeException("WebService can only annotate JavaInterface");
    }
    JAnnotation serviceAnnotation = new JAnnotation(WebService.class);
    serviceAnnotation.addElement(new JAnnotationElement("targetNamespace", intf.getNamespace()));
    serviceAnnotation.addElement(new JAnnotationElement("name", intf.getWebServiceName()));
    intf.addAnnotation(serviceAnnotation);
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) JAnnotation(org.apache.cxf.tools.common.model.JAnnotation) JAnnotationElement(org.apache.cxf.tools.common.model.JAnnotationElement)

Aggregations

JavaInterface (org.apache.cxf.tools.common.model.JavaInterface)33 JavaModel (org.apache.cxf.tools.common.model.JavaModel)20 QName (javax.xml.namespace.QName)11 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)8 JavaMethod (org.apache.cxf.tools.common.model.JavaMethod)7 ArrayList (java.util.ArrayList)6 Message (org.apache.cxf.common.i18n.Message)6 JAnnotation (org.apache.cxf.tools.common.model.JAnnotation)6 JAnnotationElement (org.apache.cxf.tools.common.model.JAnnotationElement)6 JavaPort (org.apache.cxf.tools.common.model.JavaPort)6 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)5 JavaException (org.apache.cxf.tools.common.model.JavaException)5 JavaServiceClass (org.apache.cxf.tools.common.model.JavaServiceClass)5 OperationInfo (org.apache.cxf.service.model.OperationInfo)4 ToolContext (org.apache.cxf.tools.common.ToolContext)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 ToolException (org.apache.cxf.tools.common.ToolException)3 JAXWSBinding (org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding)3 GenericArrayType (java.lang.reflect.GenericArrayType)2