Package org.apache.cxf.tools.common.model

Examples of org.apache.cxf.tools.common.model.JavaInterface


    }

    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",
View Full Code Here


            enableOpMime = true;
            if (bopBinding.getJaxwsParas() != null) {
                jaxwsBinding.setJaxwsParas(bopBinding.getJaxwsParas());
            }
        }
        JavaInterface jf = null;
        for (JavaInterface jf2 : model.getInterfaces().values()) {
            if (binding.getInterface().getName().getLocalPart()
                    .equals(jf2.getWebServiceName())) {
                jf = jf2;
            }
        }
        if (isSoapBinding()) {
            SoapBinding soapBinding = (SoapBinding)bindingObj;
            if (SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()) == null) {
                jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
            } else {
                jf.setSOAPStyle(SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()));
            }
        } else {
            // REVISIT: fix for xml binding
            jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
        }

        Object[] methods = jf.getMethods().toArray();
        for (int i = 0; i < methods.length; i++) {
            JavaMethod jm = (JavaMethod)methods[i];
            if (jm.getOperationName() != null && jm.getOperationName().equals(bop.getName().getLocalPart())) {
                if (isSoapBinding()) {
                    // TODO: add customize here
                    //doCustomizeOperation(jf, jm, bop);
                    Map<String, Object> prop = getSoapOperationProp(bop);
                    String soapAction = prop.get(soapOPAction) == null ? "" : (String)prop.get(soapOPAction);
                    String soapStyle = prop.get(soapOPStyle) == null ? "" : (String)prop.get(soapOPStyle);
                    jm.setSoapAction(soapAction);

                    if (SOAPBindingUtil.getSoapStyle(soapStyle) == null && this.bindingObj == null) {
                        org.apache.cxf.common.i18n.Message msg =
                            new  org.apache.cxf.common.i18n.Message("BINDING_STYLE_NOT_DEFINED",
                                                                         LOG);
                        throw new ToolException(msg);
                    }
                    if (SOAPBindingUtil.getSoapStyle(soapStyle) == null) {
                        jm.setSoapStyle(jf.getSOAPStyle());
                    } else {
                        jm.setSoapStyle(SOAPBindingUtil.getSoapStyle(soapStyle));
                    }
                } else {
                    // REVISIT: fix for xml binding
                    jm.setSoapStyle(jf.getSOAPStyle());
                }

                if (jm.getSoapStyle().equals(javax.jws.soap.SOAPBinding.Style.RPC)) {
                    jm.getAnnotationMap().remove("SOAPBinding");
                }
View Full Code Here

public final class JavaFirstUtil {
    private JavaFirstUtil() {
       
    }
    public static JavaInterface serviceInfo2JavaInf(ServiceInfo service) {
        JavaInterface javaInf = new JavaInterface();
        InterfaceInfo inf = service.getInterface();
        for (OperationInfo op : inf.getOperations()) {
            JavaMethod jm = new JavaMethod();
            Method m = (Method)op.getProperty(ReflectionServiceFactoryBean.METHOD);
            jm.setName(m.getName());
            int i = 0;
            for (Type type : m.getGenericParameterTypes()) {
                JavaParameter jp = new JavaParameter();
                jp.setClassName(getClassName(type));
                jp.setStyle(Style.IN);
                jp.setName("arg" + i++);
                jm.addParameter(jp);
            }

            for (Type type : m.getGenericExceptionTypes()) {
                JavaException jex = new JavaException();
                String className = getClassName(type);
                jex.setClassName(className);
                jex.setName(className);
                jm.addException(jex);
            }

            JavaReturn jreturn = new JavaReturn();
            jreturn.setClassName(getClassName(m.getGenericReturnType()));
            jreturn.setStyle(Style.OUT);
            jm.setReturn(jreturn);

            String pkg = PackageUtils.getPackageName(m.getDeclaringClass());
            javaInf.setPackageName(pkg.length() == 0 ? ToolConstants.DEFAULT_PACKAGE_NAME : pkg);
            javaInf.addMethod(jm);
            javaInf.setName(inf.getName().getLocalPart());

            jm.getParameterList();

        }
        return javaInf;
View Full Code Here

    @SuppressWarnings("unchecked")
    public void process() throws ToolException {
        checkJaxwsClass();
        List<ServiceInfo> services = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
        ServiceInfo serviceInfo = services.get(0);
        JavaInterface jinf = JavaFirstUtil.serviceInfo2JavaInf(serviceInfo);
        String className = (String)context.get(ToolConstants.IMPL_CLASS);
        if (className != null && className.equals(jinf.getFullClassName())) {
            jinf.setName(jinf.getName() + SEI_SUFFIX);
        }
        JavaModel jm = new JavaModel();
        jm.addInterface("inf", jinf);
        jinf.setJavaModel(jm);
        context.put(JavaModel.class, jm);
        context.put(ToolConstants.SERVICE_NAME, serviceInfo.getName());
        EndpointInfo endpointInfo = serviceInfo.getEndpoints().iterator().next();       
        context.put(ToolConstants.PORT_NAME, endpointInfo.getName());
        generators.add(new JaxwsSEIGenerator());
View Full Code Here

    public void setEnvironment(ToolContext env) {
        this.context = env;
    }

    public JavaInterface serviceInfo2JavaInf(ServiceInfo service) {
        JavaInterface javaInf = new JavaInterface();
        InterfaceInfo inf = service.getInterface();
        for (OperationInfo op : inf.getOperations()) {
            JavaMethod jm = new JavaMethod();
            Method m = (Method)op.getProperty(ReflectionServiceFactoryBean.METHOD);
            jm.setName(m.getName());
            int i = 0;
            for (Type type : m.getGenericParameterTypes()) {
                JavaParameter jp = new JavaParameter();
                jp.setClassName(getClassName(type));
                jp.setStyle(Style.IN);
                jp.setName("arg" + i++);
                jm.addParameter(jp);
            }

            for (Type type : m.getGenericExceptionTypes()) {
                JavaException jex = new JavaException();
                String className = getClassName(type);
                jex.setClassName(className);
                jex.setName(className);
                jm.addException(jex);
            }

            JavaReturn jreturn = new JavaReturn();
            jreturn.setClassName(getClassName(m.getGenericReturnType()));
            jreturn.setStyle(Style.OUT);
            jm.setReturn(jreturn);

            String pkg = PackageUtils.getPackageName(m.getDeclaringClass());
            javaInf.setPackageName(pkg.length() > 0 ? pkg : ToolConstants.DEFAULT_PACKAGE_NAME);
            javaInf.addMethod(jm);
            javaInf.setName(inf.getName().getLocalPart());

            jm.getParameterList();

        }
        return javaInf;
View Full Code Here

            JavaServiceClass service = null;
            if (!services.values().isEmpty()) {
                for (JavaServiceClass javaservice : services.values()) {
                    service = javaservice;
                    for (JavaPort jport : javaservice.getPorts()) {
                        JavaInterface intf = interfaces.get(jport.getInterfaceClass());
                        outputImpl(intf, service, jport.getPortName(), penv);
                       
                    }
                }
            } else {
                for (String interfaceName : interfaces.keySet()) {
                    JavaInterface intf = interfaces.get(interfaceName);
                    outputImpl(intf, null, "", penv);
                }
            }
        }
    }
View Full Code Here

        }

        boolean required = false;


        JavaInterface intf = method.getInterface();
        MessageInfo inputMessage = operation.getInput();
        MessageInfo outputMessage = operation.getOutput();

        JAnnotation actionAnnotation = new JAnnotation(Action.class);
        if (inputMessage.getExtensionAttributes() != null) {
            QName inputAction = (QName)inputMessage.getExtensionAttribute(WSAW_ACTION_QNAME);
            if (inputAction != null) {
                actionAnnotation.addElement(new JAnnotationElement("input",
                                                                          inputAction.getLocalPart()));
                required = true;
            }
        }

        if (outputMessage != null && outputMessage.getExtensionAttributes() != null) {
            QName outputAction = (QName)outputMessage.getExtensionAttribute(WSAW_ACTION_QNAME);
            if (outputAction != null) {
                actionAnnotation.addElement(new JAnnotationElement("output",
                                                                          outputAction.getLocalPart()));
                required = true;
            }
        }
        if (operation.hasFaults()) {
            List<JAnnotation> faultAnnotations = new ArrayList<JAnnotation>();
            for (FaultInfo faultInfo : operation.getFaults()) {
                if (faultInfo.getExtensionAttributes() != null) {
                    QName faultAction = (QName)faultInfo.getExtensionAttribute(WSAW_ACTION_QNAME);

                    JavaException exceptionClass = getExceptionClass(method, faultInfo);                   
                    if (!StringUtils.isEmpty(exceptionClass.getPackageName())
                        && !exceptionClass.getPackageName().equals(intf.getPackageName())) {
                        intf.addImport(exceptionClass.getClassName());
                    }                   

                    JAnnotation faultAnnotation = new JAnnotation(FaultAction.class);
                    faultAnnotation.addElement(new JAnnotationElement("className", exceptionClass));
                    faultAnnotation.addElement(new JAnnotationElement("value",
View Full Code Here

            JavaServiceClass js = (JavaServiceClass)it.next();
            Iterator i = js.getPorts().iterator();
            while (i.hasNext()) {
                JavaPort jp = (JavaPort)i.next();
                String interfaceName = jp.getInterfaceClass();
                JavaInterface intf = interfaces.get(interfaceName);
                if (intf == null) {
                    interfaceName = jp.getPortType();
                    intf = interfaces.get(interfaceName);
                }
               
                String clientClassName = interfaceName + "_"
                                         + NameUtil.mangleNameToClassName(jp.getPortName()) + "_Client";

                clearAttributes();
                setAttributes("clientClassName", clientClassName);
                setAttributes("intf", intf);
                setAttributes("service", js);
                setAttributes("port", jp);

                setCommonAttributes();

                doWrite(CLT_TEMPLATE, parseOutputName(intf.getPackageName(), clientClassName));
            }
        }
    }
View Full Code Here

    public InterfaceMapper(ToolContext c) {
        this.context = c;
    }
   
    public JavaInterface map(InterfaceInfo interfaceInfo) {
        JavaInterface intf = new JavaInterface();
        String namespace = interfaceInfo.getName().getNamespaceURI();
        String packageName = ProcessorUtil.parsePackageName(namespace, context.mapPackageName(namespace));
       
        String loc = (String)context.get(ToolConstants.CFG_WSDLLOCATION);
        if (loc == null) {
            loc = (String)context.get(ToolConstants.CFG_WSDLURL);
        }
       
        String webServiceName = interfaceInfo.getName().getLocalPart();

        intf.setWebServiceName(webServiceName);
        intf.setName(NameUtil.mangleNameToClassName(webServiceName));
        intf.setNamespace(namespace);
        intf.setPackageName(packageName);
        intf.setLocation(loc);

        return intf;
    }
View Full Code Here

            JavaModel javaModel = context.get(JavaModel.class);

            Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
            assertEquals(1, interfaces.size());

            JavaInterface intf = interfaces.values().iterator().next();
            assertEquals("http://apache.org/hello_world_soap_http", intf.getNamespace());
            assertEquals("Greeter", intf.getName());
            assertEquals("org.apache.hello_world_soap_http", intf.getPackageName());

            List<JavaMethod> methods = intf.getMethods();
            assertEquals(6, methods.size());
            Boolean methodSame = false;
            for (JavaMethod m1 : methods) {
                if (m1.getName().equals("testDocLitFault")) {
                    methodSame = true;
View Full Code Here

TOP

Related Classes of org.apache.cxf.tools.common.model.JavaInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.