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

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


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

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

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

            List<JavaMethod> methods = intf.getMethods();
            assertEquals(6, methods.size());

            Boolean methodSame = false;
            JavaMethod m1 = null;
            for (JavaMethod m2 : methods) {
View Full Code Here


import org.apache.cxf.tools.common.model.JavaInterface;

public final class WebServiceAnnotator implements Annotator {
   
    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);
    }
View Full Code Here

import org.apache.cxf.tools.common.model.JavaMethod;

public final class BindingAnnotator implements Annotator {
   
    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());
            }
        }
    }
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);
        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);
            javaInf.addMethod(jm);
            javaInf.setName(inf.getName().getLocalPart());

            jm.getParameterList();

        }
        return javaInf;
View Full Code Here

    @SuppressWarnings("unchecked")
    public void process() throws ToolException {      
        List<ServiceInfo> services = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
        ServiceInfo serviceInfo = services.get(0);
       
        JavaInterface jinf = JavaFirstUtil.serviceInfo2JavaInf(serviceInfo);
        JavaModel jm = new JavaModel();
        jm.addInterface("inf", jinf);
        jinf.setJavaModel(jm);
        context.put(JavaModel.class, jm);
        generators.add(new SimpleSEIGenerator());
        generators.add(new SimpleImplGenerator());
        generators.add(new SimpleServerGenerator());
        generators.add(new SimpleClientGenerator());
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);

            javaInf.addMethod(jm);
            javaInf.setName(inf.getName().getLocalPart());

            jm.getParameterList();

        }
        return javaInf;
View Full Code Here

public class XmlSeeAlsoAnnotatorTest extends Assert {

    @Test
    public void testAddXmlSeeAlsoAnnotation() throws Exception {
        JavaInterface intf = new JavaInterface();
        assertFalse(intf.getImports().hasNext());

        ClassCollector collector = new ClassCollector();
        collector.getTypesPackages().add(ObjectFactory.class.getPackage().getName());
        intf.annotate(new XmlSeeAlsoAnnotator(collector));

        Iterator<String> iter = intf.getImports();
        assertEquals("javax.xml.bind.annotation.XmlSeeAlso", iter.next());
    
        assertEquals("@XmlSeeAlso({" + ObjectFactory.class.getName() + ".class})",
                     intf.getAnnotations().iterator().next().toString());
    }
View Full Code Here

    private void processOperation(JavaModel model, BindingOperation bop, Binding binding)
        throws ToolException {
        String portType = ProcessorUtil
            .mangleNameToClassName(binding.getPortType().getQName().getLocalPart());
        JavaInterface jf = model.getInterfaces().get(portType);
        // TODO: extend other bindings
        doCustomizeBinding(model, jf, binding);
        if (isSoapBinding()) {
            SoapBinding soapBinding = (SoapBinding)bindingObj;
            if (getSoapStyle(soapBinding.getStyle()) == null) {
                jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
            } else {
                jf.setSOAPStyle(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())) {
                if (isSoapBinding()) {
                    doCustomizeOperation(jf, jm, bop);
                    Map 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 (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 (getSoapStyle(soapStyle) == null) {
                        jm.setSoapStyle(jf.getSOAPStyle());
                    } else {
                        jm.setSoapStyle(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

        super(penv);
    }
   
    public void process(JavaModel jmodel, PortType portType) throws ToolException {
        operationMap.clear();
        JavaInterface intf = new JavaInterface(jmodel);
        intf.setJAXWSBinding(customizing(jmodel, portType));
        intf.setHandlerChains(CustomizationParser.getInstance().getHandlerChains());
       
        String namespace = portType.getQName().getNamespaceURI();
        String packageName = ProcessorUtil.parsePackageName(namespace, env.mapPackageName(namespace));

        String location = (String)env.get(ToolConstants.CFG_WSDLURL);
        String urlLocation;
        try {
            location = ProcessorUtil.getAbsolutePath(location);
            urlLocation = ProcessorUtil.getWSDLURL(location).toString();
           
        } catch (Exception ioe) {
            Message msg = new Message("CANNOT_FIND_WSDL", LOG, env.get(ToolConstants.CFG_WSDLURL));
            throw new ToolException(msg, ioe);
        }
        String serviceName = portType.getQName().getLocalPart();
        intf.setWebServiceName(serviceName);
        intf.setName(ProcessorUtil.mangleNameToClassName(serviceName));
        intf.setNamespace(namespace);
        intf.setPackageName(packageName);
        intf.setLocation(urlLocation);

        List operations = portType.getOperations();
      
        for (Iterator iter = operations.iterator(); iter.hasNext();) {
          
            Operation operation = (Operation)iter.next();
            if (isOverloading(operation.getName())) {
                LOG.log(Level.WARNING, "SKIP_OVERLOADED_OPERATION", operation.getName());
                continue;
            }
            OperationProcessor operationProcessor = new OperationProcessor(env);
            operationProcessor.process(intf, operation);
        }
        //Fixed issue 305772
        jmodel.setLocation(urlLocation);
        jmodel.addInterface(intf.getName(), intf);
      
    }
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.