Examples of FrontEndProfile


Examples of org.apache.cxf.tools.wsdlto.core.FrontEndProfile

        if (serviceList == null) {
            serviceList = new ArrayList<ServiceInfo>();

            PluginLoader pluginLoader = PluginLoader.getInstance();
            // for JavaScript generation, we always use JAX-WS.
            FrontEndProfile frontend = pluginLoader.getFrontEndProfile("jaxws");

            // Build the ServiceModel from the WSDLModel
            if (version == WSDLConstants.WSDLVersion.WSDL11) {
                AbstractWSDLBuilder<Definition> builder = (AbstractWSDLBuilder<Definition>)frontend
                    .getWSDLBuilder();
                builder.setContext(context);
                builder.setBus(getBus());
                context.put(Bus.class, getBus());
                builder.build(URIParserUtil.getAbsoluteURI(wsdlURL));
View Full Code Here

Examples of org.apache.cxf.tools.wsdlto.core.FrontEndProfile

            // TODO: After runtime support w3c EPR mapping ,this will be removed
            //context.put(ToolConstants.CFG_NO_ADDRESS_BINDING,
            //            ToolConstants.CFG_NO_ADDRESS_BINDING);
            buildToolContext();
            validate(context);
            FrontEndProfile frontend = context.get(FrontEndProfile.class);

            if (frontend == null) {
                Message msg = new Message("FOUND_NO_FRONTEND", LOG);
                throw new ToolException(msg);
            }

            WSDLConstants.WSDLVersion version = getWSDLVersion();

            String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);
            List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
            if (serviceList == null) {
                serviceList = new ArrayList<ServiceInfo>();

                // Build the ServiceModel from the WSDLModel
                if (version == WSDLConstants.WSDLVersion.WSDL11) {
                    AbstractWSDLBuilder<Definition> builder = (AbstractWSDLBuilder<Definition>)frontend
                        .getWSDLBuilder();
                    builder.setContext(context);
                    builder.setBus(getBus());
                    context.put(Bus.class, getBus());
                    wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
                    builder.build(wsdlURL);
                    builder.customize();
                    Definition definition = builder.getWSDLModel();

                    context.put(Definition.class, definition);

                    builder.validate(definition);

                    WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
                    String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);

                    if (serviceName != null) {
                        List<ServiceInfo> services = serviceBuilder
                            .buildServices(definition, getServiceQName(definition));
                        serviceList.addAll(services);
                    } else if (definition.getServices().size() > 0) {
                        serviceList = serviceBuilder.buildServices(definition);
                    } else {
                        serviceList = serviceBuilder.buildMockServices(definition);
                    }

                } else {
                    // TODO: wsdl2.0 support
                }
            }
            Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();

            Map<String, Element> schemas = (Map<String, Element>)serviceList.get(0)
                .getProperty(WSDLServiceBuilder.WSDL_SCHEMA_ELEMENT_LIST);
            if (schemas == null) {
                schemas = new java.util.HashMap<String, Element>();
                ServiceInfo serviceInfo = serviceList.get(0);
                for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) {
                    if (schemaInfo.getElement() != null && schemaInfo.getSystemId() == null) {
                        String sysId = schemaInfo.getElement().getAttribute("targetNamespce");
                        if (sysId == null) {
                            sysId = serviceInfo.getTargetNamespace();
                        }
                        schemas.put(sysId, schemaInfo.getElement());
                    }
                    if (schemaInfo.getElement() != null && schemaInfo.getSystemId() != null) {
                        schemas.put(schemaInfo.getSystemId(), schemaInfo.getElement());
                    }
                }
            }
            context.put(ToolConstants.SCHEMA_MAP, schemas);
            context.put(ToolConstants.PORTTYPE_MAP, interfaces);
            context.put(ClassCollector.class, new ClassCollector());
            Processor processor = frontend.getProcessor();
            if (processor instanceof ClassNameProcessor) {
                processor.setEnvironment(context);
                for (ServiceInfo service : serviceList) {

                    context.put(ServiceInfo.class, service);

                    ((ClassNameProcessor)processor).processClassNames();

                    context.put(ServiceInfo.class, null);
                }
            }
            generateTypes();

            for (ServiceInfo service : serviceList) {

                context.put(ServiceInfo.class, service);

                validate(service);

                // Build the JavaModel from the ServiceModel
                processor.setEnvironment(context);
                processor.process();

                if (!isSuppressCodeGen()) {
                    // Generate artifacts
                    for (FrontEndGenerator generator : frontend.getGenerators()) {
                        generator.generate(context);
                    }
                }
            }
View Full Code Here

Examples of org.apache.cxf.tools.wsdlto.core.FrontEndProfile

    private void processWsdl() {
        // TODO: After runtime support w3c EPR mapping ,this will be removed
        //context.put(ToolConstants.CFG_NO_ADDRESS_BINDING,
        //            ToolConstants.CFG_NO_ADDRESS_BINDING);
        validate(context);
        FrontEndProfile frontend = context.get(FrontEndProfile.class);

        if (frontend == null) {
            throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG));
        }

        WSDLConstants.WSDLVersion version = getWSDLVersion();

        String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);

        @SuppressWarnings("unchecked")
        List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
        if (serviceList == null) {
            serviceList = new ArrayList<ServiceInfo>();

            // Build the ServiceModel from the WSDLModel
            if (version == WSDLConstants.WSDLVersion.WSDL11) {
                AbstractWSDLBuilder builder = frontend.getWSDLBuilder();
                builder.setContext(context);
                builder.setBus(getBus());
                context.put(Bus.class, getBus());
                wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
                builder.build(wsdlURL);
                builder.customize();
                Definition definition = builder.getWSDLModel();

                context.put(Definition.class, definition);

                builder.validate(definition);

                WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
                if (context.isVerbose()) {
                    serviceBuilder.setUnwrapLogLevel(Level.INFO);
                }
                serviceBuilder.setIgnoreUnknownBindings(true);
                String allowRefs = (String)context.get(ToolConstants.CFG_ALLOW_ELEMENT_REFS);
                if (!StringUtils.isEmpty(allowRefs)
                    || context.optionSet(ToolConstants.CFG_ALLOW_ELEMENT_REFS)) {
                    if (allowRefs.length() > 0 && allowRefs.charAt(0) == '=') {
                        allowRefs = allowRefs.substring(1);
                    }
                    if (StringUtils.isEmpty(allowRefs)) {
                        allowRefs = "true";
                    }
                    serviceBuilder.setAllowElementRefs(Boolean.valueOf(allowRefs));
                }
                String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);

                if (serviceName != null) {
                    List<ServiceInfo> services = serviceBuilder
                        .buildServices(definition, getServiceQName(definition));
                    serviceList.addAll(services);
                } else if (definition.getServices().size() > 0) {
                    serviceList = serviceBuilder.buildServices(definition);
                } else {
                    serviceList = serviceBuilder.buildMockServices(definition);
                }
                //remove definition from cache so that won't fail when encounter same wsdl file
                //name but different wsdl content(CXF-3340)
                getBus().getExtension(WSDLManager.class).removeDefinition(definition);
            } else {
                // TODO: wsdl2.0 support
            }
        }
        context.put(ToolConstants.SERVICE_LIST, serviceList);
       
        Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();

        ServiceInfo service0 = serviceList.get(0);
        SchemaCollection schemaCollection = service0.getXmlSchemaCollection();
        context.put(ToolConstants.XML_SCHEMA_COLLECTION, schemaCollection);
       
        context.put(ToolConstants.PORTTYPE_MAP, interfaces);
       
        context.put(ClassCollector.class, createClassCollector());
        Processor processor = frontend.getProcessor();
        if (processor instanceof ClassNameProcessor) {
            processor.setEnvironment(context);
            for (ServiceInfo service : serviceList) {

                context.put(ServiceInfo.class, service);

                ((ClassNameProcessor)processor).processClassNames();

                context.put(ServiceInfo.class, null);
            }
        }
       
        if (context.optionSet(ToolConstants.CFG_NO_TYPES)) {
            context.remove(ToolConstants.CFG_TYPES);
            context.remove(ToolConstants.CFG_ALL);
            context.remove(ToolConstants.CFG_COMPILE);
        }
       
        generateTypes();
        if (context.getErrorListener().getErrorCount() > 0) {
            return;
        }

        for (ServiceInfo service : serviceList) {
            context.put(ServiceInfo.class, service);

            if (context.basicValidateWSDL()) {
                validate(service);
            }

            if (context.getErrorListener().getErrorCount() == 0) {
                // Build the JavaModel from the ServiceModel
                processor.setEnvironment(context);
                processor.process();
            }
        }
        if (context.getErrorListener().getErrorCount() > 0) {
            return;
        }
       
        if (context.optionSet(ToolConstants.CFG_CLIENT_JAR)) {
            enforceWSDLLocation(context);
        }
       
        if (!isSuppressCodeGen()) {
            // Generate artifacts
            for (FrontEndGenerator generator : frontend.getGenerators()) {
                generator.generate(context);
            }
        }
        context.remove(ToolConstants.SERVICE_LIST);
View Full Code Here

Examples of org.apache.cxf.tools.wsdlto.core.FrontEndProfile

    private void processWsdl() {
        // TODO: After runtime support w3c EPR mapping ,this will be removed
        //context.put(ToolConstants.CFG_NO_ADDRESS_BINDING,
        //            ToolConstants.CFG_NO_ADDRESS_BINDING);
        validate(context);
        FrontEndProfile frontend = context.get(FrontEndProfile.class);

        if (frontend == null) {
            throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG));
        }

        WSDLConstants.WSDLVersion version = getWSDLVersion();

        String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);

        @SuppressWarnings("unchecked")
        List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
        if (serviceList == null) {
            serviceList = new ArrayList<ServiceInfo>();

            // Build the ServiceModel from the WSDLModel
            if (version == WSDLConstants.WSDLVersion.WSDL11) {
                @SuppressWarnings("unchecked")
                AbstractWSDLBuilder<Definition> builder = (AbstractWSDLBuilder<Definition>)frontend
                    .getWSDLBuilder();
                builder.setContext(context);
                builder.setBus(getBus());
                context.put(Bus.class, getBus());
                wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
                builder.build(wsdlURL);
                builder.customize();
                Definition definition = builder.getWSDLModel();

                context.put(Definition.class, definition);

                builder.validate(definition);

                WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
                serviceBuilder.setIgnoreUnknownBindings(true);
                String allowRefs = (String)context.get(ToolConstants.CFG_ALLOW_ELEMENT_REFS);
                if (!StringUtils.isEmpty(allowRefs)
                    || context.optionSet(ToolConstants.CFG_ALLOW_ELEMENT_REFS)) {
                    if (allowRefs.length() > 0 && allowRefs.charAt(0) == '=') {
                        allowRefs = allowRefs.substring(1);
                    }
                    if (StringUtils.isEmpty(allowRefs)) {
                        allowRefs = "true";
                    }
                    serviceBuilder.setAllowElementRefs(Boolean.valueOf(allowRefs));
                }
                String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);

                if (serviceName != null) {
                    List<ServiceInfo> services = serviceBuilder
                        .buildServices(definition, getServiceQName(definition));
                    serviceList.addAll(services);
                } else if (definition.getServices().size() > 0) {
                    serviceList = serviceBuilder.buildServices(definition);
                } else {
                    serviceList = serviceBuilder.buildMockServices(definition);
                }
                //remove definition from cache so that won't fail when encounter same wsdl file
                //name but different wsdl content(CXF-3340)
                getBus().getExtension(WSDLManager.class).removeDefinition(definition);
            } else {
                // TODO: wsdl2.0 support
            }
        }
        context.put(ToolConstants.SERVICE_LIST, serviceList);
       
        Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();

        ServiceInfo service0 = serviceList.get(0);
        SchemaCollection schemaCollection = service0.getXmlSchemaCollection();
        context.put(ToolConstants.XML_SCHEMA_COLLECTION, schemaCollection);
       
        context.put(ToolConstants.PORTTYPE_MAP, interfaces);
       
        context.put(ClassCollector.class, createClassCollector());
        Processor processor = frontend.getProcessor();
        if (processor instanceof ClassNameProcessor) {
            processor.setEnvironment(context);
            for (ServiceInfo service : serviceList) {

                context.put(ServiceInfo.class, service);

                ((ClassNameProcessor)processor).processClassNames();

                context.put(ServiceInfo.class, null);
            }
        }
       
        if (context.optionSet(ToolConstants.CFG_NO_TYPES)) {
            context.remove(ToolConstants.CFG_TYPES);
            context.remove(ToolConstants.CFG_ALL);
            context.remove(ToolConstants.CFG_COMPILE);
        }
       
        generateTypes();

        for (ServiceInfo service : serviceList) {

            context.put(ServiceInfo.class, service);

            validate(service);

            // Build the JavaModel from the ServiceModel
            processor.setEnvironment(context);
            processor.process();
        }
        if (!isSuppressCodeGen()) {
            // Generate artifacts
            for (FrontEndGenerator generator : frontend.getGenerators()) {
                generator.generate(context);
            }
        }
        context.remove(ToolConstants.SERVICE_LIST);
View Full Code Here

Examples of org.apache.cxf.tools.wsdlto.core.FrontEndProfile

    public void execute() throws ToolException {
        if (!hasInfoOption()) {
            buildToolContext();
            validate(context);

            FrontEndProfile frontend = context.get(FrontEndProfile.class);

            if (frontend == null) {
                Message msg = new Message("FOUND_NO_FRONTEND", LOG);
                throw new ToolException(msg);
            }

            WSDLConstants.WSDLVersion version = getWSDLVersion();

            String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);
            List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
            if (serviceList == null) {
                serviceList = new ArrayList<ServiceInfo>();

                // Build the ServiceModel from the WSDLModel
                if (version == WSDLConstants.WSDLVersion.WSDL11) {
                    AbstractWSDLBuilder<Definition> builder = (AbstractWSDLBuilder<Definition>)frontend
                        .getWSDLBuilder();
                    builder.setContext(context);
                    builder.setBus(getBus());
                    context.put(Bus.class, getBus());
                    builder.build(URIParserUtil.getAbsoluteURI(wsdlURL));
                    builder.customize();
                    Definition definition = builder.getWSDLModel();

                    context.put(Definition.class, definition);

                    builder.validate(definition);

                    WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
                    serviceBuilder.setCatalogResolvedMap(builder.getCataLogResolvedMap());
                    String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);

                    if (serviceName != null) {
                        List<ServiceInfo> services = serviceBuilder
                            .buildServices(definition, getServiceQName(definition));
                        serviceList.addAll(services);
                    } else if (definition.getServices().size() > 0) {
                        serviceList = serviceBuilder.buildServices(definition);
                    } else {
                        serviceList = serviceBuilder.buildMockServices(definition);
                    }

                } else {
                    // TODO: wsdl2.0 support
                }
            }
            Map<String, InterfaceInfo> interfaces = new HashMap<String, InterfaceInfo>();

            Map<String, Element> schemas = (Map<String, Element>)serviceList.get(0)
                .getProperty(WSDLServiceBuilder.WSDL_SCHEMA_ELEMENT_LIST);
            if (schemas == null) {
                schemas = new java.util.HashMap<String, Element>();
                ServiceInfo serviceInfo = serviceList.get(0);
                for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) {
                    if (schemaInfo.getElement() != null && schemaInfo.getSystemId() == null) {
                        String sysId = schemaInfo.getElement().getAttribute("targetNamespce");
                        if (sysId == null) {
                            sysId = serviceInfo.getTargetNamespace();
                        }
                        schemas.put(sysId, schemaInfo.getElement());
                    }
                    if (schemaInfo.getElement() != null && schemaInfo.getSystemId() != null) {
                        schemas.put(schemaInfo.getSystemId(), schemaInfo.getElement());
                    }
                }
            }
            context.put(ToolConstants.SCHEMA_MAP, schemas);
            context.put(ToolConstants.PORTTYPE_MAP, interfaces);
            context.put(ClassCollector.class, new ClassCollector());
            Processor processor = frontend.getProcessor();
            if (processor instanceof ClassNameProcessor) {
                processor.setEnvironment(context);
                for (ServiceInfo service : serviceList) {

                    context.put(ServiceInfo.class, service);

                    ((ClassNameProcessor)processor).processClassNames();

                    context.put(ServiceInfo.class, null);
                }
            }
            generateTypes();

            for (ServiceInfo service : serviceList) {

                context.put(ServiceInfo.class, service);

                validate(service);

                // Build the JavaModel from the ServiceModel
                processor.setEnvironment(context);
                processor.process();


                if (!isSuppressCodeGen()) {
                    // Generate artifacts
                    for (FrontEndGenerator generator : frontend.getGenerators()) {
                        generator.generate(context);
                    }
                }
            }
View Full Code Here

Examples of org.apache.cxf.tools.wsdlto.core.FrontEndProfile

    private void processWsdl() {
        // TODO: After runtime support w3c EPR mapping ,this will be removed
        //context.put(ToolConstants.CFG_NO_ADDRESS_BINDING,
        //            ToolConstants.CFG_NO_ADDRESS_BINDING);
        validate(context);
        FrontEndProfile frontend = context.get(FrontEndProfile.class);

        if (frontend == null) {
            throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG));
        }

        WSDLConstants.WSDLVersion version = getWSDLVersion();

        String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);

        @SuppressWarnings("unchecked")
        List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
        if (serviceList == null) {
            serviceList = new ArrayList<ServiceInfo>();

            // Build the ServiceModel from the WSDLModel
            if (version == WSDLConstants.WSDLVersion.WSDL11) {
                @SuppressWarnings("unchecked")
                AbstractWSDLBuilder<Definition> builder = (AbstractWSDLBuilder<Definition>)frontend
                    .getWSDLBuilder();
                builder.setContext(context);
                builder.setBus(getBus());
                context.put(Bus.class, getBus());
                wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
                builder.build(wsdlURL);
                builder.customize();
                Definition definition = builder.getWSDLModel();

                context.put(Definition.class, definition);

                builder.validate(definition);

                WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
                if (context.isVerbose()) {
                    serviceBuilder.setUnwrapLogLevel(Level.INFO);
                }
                serviceBuilder.setIgnoreUnknownBindings(true);
                String allowRefs = (String)context.get(ToolConstants.CFG_ALLOW_ELEMENT_REFS);
                if (!StringUtils.isEmpty(allowRefs)
                    || context.optionSet(ToolConstants.CFG_ALLOW_ELEMENT_REFS)) {
                    if (allowRefs.length() > 0 && allowRefs.charAt(0) == '=') {
                        allowRefs = allowRefs.substring(1);
                    }
                    if (StringUtils.isEmpty(allowRefs)) {
                        allowRefs = "true";
                    }
                    serviceBuilder.setAllowElementRefs(Boolean.valueOf(allowRefs));
                }
                String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);

                if (serviceName != null) {
                    List<ServiceInfo> services = serviceBuilder
                        .buildServices(definition, getServiceQName(definition));
                    serviceList.addAll(services);
                } else if (definition.getServices().size() > 0) {
                    serviceList = serviceBuilder.buildServices(definition);
                } else {
                    serviceList = serviceBuilder.buildMockServices(definition);
                }
                //remove definition from cache so that won't fail when encounter same wsdl file
                //name but different wsdl content(CXF-3340)
                getBus().getExtension(WSDLManager.class).removeDefinition(definition);
            } else {
                // TODO: wsdl2.0 support
            }
        }
        context.put(ToolConstants.SERVICE_LIST, serviceList);
       
        Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();

        ServiceInfo service0 = serviceList.get(0);
        SchemaCollection schemaCollection = service0.getXmlSchemaCollection();
        context.put(ToolConstants.XML_SCHEMA_COLLECTION, schemaCollection);
       
        context.put(ToolConstants.PORTTYPE_MAP, interfaces);
       
        context.put(ClassCollector.class, createClassCollector());
        Processor processor = frontend.getProcessor();
        if (processor instanceof ClassNameProcessor) {
            processor.setEnvironment(context);
            for (ServiceInfo service : serviceList) {

                context.put(ServiceInfo.class, service);

                ((ClassNameProcessor)processor).processClassNames();

                context.put(ServiceInfo.class, null);
            }
        }
       
        if (context.optionSet(ToolConstants.CFG_NO_TYPES)) {
            context.remove(ToolConstants.CFG_TYPES);
            context.remove(ToolConstants.CFG_ALL);
            context.remove(ToolConstants.CFG_COMPILE);
        }
       
        generateTypes();

        for (ServiceInfo service : serviceList) {

            context.put(ServiceInfo.class, service);

            validate(service);

            // Build the JavaModel from the ServiceModel
            processor.setEnvironment(context);
            processor.process();
        }
       
        if (context.optionSet(ToolConstants.CFG_CLIENT_JAR)) {
            enforceWSDLLocation(context);
        }
       
        if (!isSuppressCodeGen()) {
            // Generate artifacts
            for (FrontEndGenerator generator : frontend.getGenerators()) {
                generator.generate(context);
            }
        }
        context.remove(ToolConstants.SERVICE_LIST);
View Full Code Here

Examples of org.apache.cxf.tools.wsdlto.core.FrontEndProfile

        if (serviceList == null) {
            serviceList = new ArrayList<ServiceInfo>();

            PluginLoader pluginLoader = PluginLoader.newInstance();
            // for JavaScript generation, we always use JAX-WS.
            FrontEndProfile frontend = pluginLoader.getFrontEndProfile("jaxws");

            // Build the ServiceModel from the WSDLModel
            if (version == WSDLConstants.WSDLVersion.WSDL11) {
                AbstractWSDLBuilder<Definition> builder = frontend.getWSDLBuilder();
                builder.setContext(context);
                builder.setBus(getBus());
                context.put(Bus.class, getBus());
                builder.build(URIParserUtil.getAbsoluteURI(wsdlURL));
                builder.customize();
View Full Code Here

Examples of org.apache.cxf.tools.wsdlto.core.FrontEndProfile

    private void processWsdl() {
        // TODO: After runtime support w3c EPR mapping ,this will be removed
        //context.put(ToolConstants.CFG_NO_ADDRESS_BINDING,
        //            ToolConstants.CFG_NO_ADDRESS_BINDING);
        validate(context);
        FrontEndProfile frontend = context.get(FrontEndProfile.class);

        if (frontend == null) {
            throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG));
        }

        WSDLConstants.WSDLVersion version = getWSDLVersion();

        String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);

        @SuppressWarnings("unchecked")
        List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
        if (serviceList == null) {
            serviceList = new ArrayList<ServiceInfo>();

            // Build the ServiceModel from the WSDLModel
            if (version == WSDLConstants.WSDLVersion.WSDL11) {
                @SuppressWarnings("unchecked")
                AbstractWSDLBuilder<Definition> builder = (AbstractWSDLBuilder<Definition>)frontend
                    .getWSDLBuilder();
                builder.setContext(context);
                builder.setBus(getBus());
                context.put(Bus.class, getBus());
                wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
                builder.build(wsdlURL);
                builder.customize();
                Definition definition = builder.getWSDLModel();

                context.put(Definition.class, definition);

                builder.validate(definition);

                WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
                serviceBuilder.setIgnoreUnknownBindings(true);
                String allowRefs = (String)context.get(ToolConstants.CFG_ALLOW_ELEMENT_REFS);
                if (!StringUtils.isEmpty(allowRefs)
                    || context.optionSet(ToolConstants.CFG_ALLOW_ELEMENT_REFS)) {
                    if (allowRefs.length() > 0 && allowRefs.charAt(0) == '=') {
                        allowRefs = allowRefs.substring(1);
                    }
                    if (StringUtils.isEmpty(allowRefs)) {
                        allowRefs = "true";
                    }
                    serviceBuilder.setAllowElementRefs(Boolean.valueOf(allowRefs));
                }
                String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);

                if (serviceName != null) {
                    List<ServiceInfo> services = serviceBuilder
                        .buildServices(definition, getServiceQName(definition));
                    serviceList.addAll(services);
                } else if (definition.getServices().size() > 0) {
                    serviceList = serviceBuilder.buildServices(definition);
                } else {
                    serviceList = serviceBuilder.buildMockServices(definition);
                }

            } else {
                // TODO: wsdl2.0 support
            }
        }
        context.put(ToolConstants.SERVICE_LIST, serviceList);
       
        Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();

        ServiceInfo service0 = serviceList.get(0);
        SchemaCollection schemaCollection = service0.getXmlSchemaCollection();
        context.put(ToolConstants.XML_SCHEMA_COLLECTION, schemaCollection);
       
        context.put(ToolConstants.PORTTYPE_MAP, interfaces);
       
        ClassCollector collector = new ClassCollector();
        String reserved[] = (String[])context.get(ToolConstants.CFG_RESERVE_NAME);
        if (reserved != null) {
            for (String r : reserved) {
                collector.reserveClass(r);
            }
        }
        context.put(ClassCollector.class, collector);
        Processor processor = frontend.getProcessor();
        if (processor instanceof ClassNameProcessor) {
            processor.setEnvironment(context);
            for (ServiceInfo service : serviceList) {

                context.put(ServiceInfo.class, service);

                ((ClassNameProcessor)processor).processClassNames();

                context.put(ServiceInfo.class, null);
            }
        }
        generateTypes();

        for (ServiceInfo service : serviceList) {

            context.put(ServiceInfo.class, service);

            validate(service);

            // Build the JavaModel from the ServiceModel
            processor.setEnvironment(context);
            processor.process();
        }
        if (!isSuppressCodeGen()) {
            // Generate artifacts
            for (FrontEndGenerator generator : frontend.getGenerators()) {
                generator.generate(context);
            }
        }
        context.remove(ToolConstants.SERVICE_LIST);
View Full Code Here

Examples of org.apache.cxf.tools.wsdlto.core.FrontEndProfile

    private void processWsdl() {
        // TODO: After runtime support w3c EPR mapping ,this will be removed
        //context.put(ToolConstants.CFG_NO_ADDRESS_BINDING,
        //            ToolConstants.CFG_NO_ADDRESS_BINDING);
        validate(context);
        FrontEndProfile frontend = context.get(FrontEndProfile.class);

        if (frontend == null) {
            throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG));
        }

        WSDLConstants.WSDLVersion version = getWSDLVersion();

        String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);

        @SuppressWarnings("unchecked")
        List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
        if (serviceList == null) {
            serviceList = new ArrayList<ServiceInfo>();

            // Build the ServiceModel from the WSDLModel
            if (version == WSDLConstants.WSDLVersion.WSDL11) {
                @SuppressWarnings("unchecked")
                AbstractWSDLBuilder<Definition> builder = (AbstractWSDLBuilder<Definition>)frontend
                    .getWSDLBuilder();
                builder.setContext(context);
                builder.setBus(getBus());
                context.put(Bus.class, getBus());
                wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
                builder.build(wsdlURL);
                builder.customize();
                Definition definition = builder.getWSDLModel();

                context.put(Definition.class, definition);

                builder.validate(definition);

                WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
                serviceBuilder.setIgnoreUnknownBindings(true);
                String allowRefs = (String)context.get(ToolConstants.CFG_ALLOW_ELEMENT_REFS);
                if (!StringUtils.isEmpty(allowRefs)
                    || context.optionSet(ToolConstants.CFG_ALLOW_ELEMENT_REFS)) {
                    if (allowRefs.length() > 0 && allowRefs.charAt(0) == '=') {
                        allowRefs = allowRefs.substring(1);
                    }
                    if (StringUtils.isEmpty(allowRefs)) {
                        allowRefs = "true";
                    }
                    serviceBuilder.setAllowElementRefs(Boolean.valueOf(allowRefs));
                }
                String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);

                if (serviceName != null) {
                    List<ServiceInfo> services = serviceBuilder
                        .buildServices(definition, getServiceQName(definition));
                    serviceList.addAll(services);
                } else if (definition.getServices().size() > 0) {
                    serviceList = serviceBuilder.buildServices(definition);
                } else {
                    serviceList = serviceBuilder.buildMockServices(definition);
                }

            } else {
                // TODO: wsdl2.0 support
            }
        }
        context.put(ToolConstants.SERVICE_LIST, serviceList);
       
        Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();

        ServiceInfo service0 = serviceList.get(0);
        SchemaCollection schemaCollection = service0.getXmlSchemaCollection();
        context.put(ToolConstants.XML_SCHEMA_COLLECTION, schemaCollection);
       
        context.put(ToolConstants.PORTTYPE_MAP, interfaces);
       
        ClassCollector collector = new ClassCollector();
        String reserved[] = (String[])context.get(ToolConstants.CFG_RESERVE_NAME);
        if (reserved != null) {
            for (String r : reserved) {
                collector.reserveClass(r);
            }
        }
        context.put(ClassCollector.class, collector);
        Processor processor = frontend.getProcessor();
        if (processor instanceof ClassNameProcessor) {
            processor.setEnvironment(context);
            for (ServiceInfo service : serviceList) {

                context.put(ServiceInfo.class, service);

                ((ClassNameProcessor)processor).processClassNames();

                context.put(ServiceInfo.class, null);
            }
        }
        generateTypes();

        for (ServiceInfo service : serviceList) {

            context.put(ServiceInfo.class, service);

            validate(service);

            // Build the JavaModel from the ServiceModel
            processor.setEnvironment(context);
            processor.process();
        }
        if (!isSuppressCodeGen()) {
            // Generate artifacts
            for (FrontEndGenerator generator : frontend.getGenerators()) {
                generator.generate(context);
            }
        }
        context.remove(ToolConstants.SERVICE_LIST);
View Full Code Here

Examples of org.apache.cxf.tools.wsdlto.core.FrontEndProfile

    public void run(ToolContext context, OutputStream os) throws Exception {
        if (os != null) {
            this.out = (os instanceof PrintStream) ? (PrintStream)os : new PrintStream(os);
        }
        FrontEndProfile frontend = null;
        if (args != null) {
            context.put(ToolConstants.CFG_CMD_ARG, args);
            frontend = loadFrontEnd(getFrontEndName(args));
        } else {
            frontend = loadFrontEnd("");
        }


        context.put(FrontEndProfile.class, frontend);

        DataBindingProfile databinding = loadDataBinding(getDataBindingName(args));


        context.put(DataBindingProfile.class, databinding);

        Class<? extends ToolContainer> containerClass = frontend.getContainerClass();

        InputStream toolspecStream = getResourceAsStream(containerClass, frontend.getToolspec());

        ToolRunner.runTool(containerClass,
                           toolspecStream,
                           false,
                           args,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.