Package org.apache.cxf.tools.common

Examples of org.apache.cxf.tools.common.ToolException


            Definition def = visitor.getDefinition();
            Binding[] bindings = visitor.getCorbaBindings();
            generateCORBAService(def, bindings);
            visitor.writeDefinition(outputWriter);
        } catch (Exception ex) {
            throw new ToolException(ex.getMessage(), ex);
        }
    }
View Full Code Here


        for (int i = 0; i < bindingFiles.length; i++) {
            try {
                addBinding(bindingFiles[i]);
            } catch (XMLStreamException xse) {
                Message msg = new Message("STAX_PARSER_ERROR", LOG);
                throw new ToolException(msg, xse);
            }
        }
       
        if (env.get(WadlToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
View Full Code Here

        DataBinding dataBinding;
        String databindingBeanName = databindingNameToBeanName(databindingName);
        try {
            dataBinding = (DataBinding)applicationContext.getBean(databindingBeanName);
        } catch (RuntimeException e) {
            throw new ToolException("Cannot get databinding bean " + databindingBeanName
                                    + " for databinding " + databindingName);
        }

        String beanName = getBuilderBeanName(s);
        ServiceBuilder builder = null;

        try {
            builder = applicationContext.getBean(beanName, ServiceBuilder.class);
            AbstractServiceFactory serviceFactory = (AbstractServiceFactory)builder;
            serviceFactory.setDataBinding(dataBinding);
        } catch (RuntimeException e) {
            throw new ToolException("Can not get ServiceBuilder bean " + beanName
                                    + "to initialize the ServiceBuilder for style: " + s + " Reason: \n"
                                    + e.getMessage(), e);
        }
        builder.setServiceClass(serviceClass);
        return builder;
View Full Code Here

        try {
            URIResolver resolver = new URIResolver(bindingFile);
            root = StaxUtils.read(resolver.getInputStream()).getDocumentElement();
        } catch (Exception e1) {
            Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] {bindingFile});
            throw new ToolException(msg, e1);
        }
        XMLStreamReader reader = StaxUtils.createXMLStreamReader(root);
        StaxUtils.toNextTag(reader);
        if (isValidJaxbBindingFile(reader)) {
            String schemaLocation = root.getAttribute("schemaLocation");
            String resolvedSchemaLocation = resolveByCatalog(schemaLocation);
            if (resolvedSchemaLocation == null) {
                resolvedSchemaLocation = schemaLocation.length() == 0
                    ? wadlPath : getBaseWadlPath() + schemaLocation;
            }
            InputSource tmpIns = null;
            try {
                tmpIns = convertToTmpInputSource(root, resolvedSchemaLocation);
            } catch (Exception e1) {
                Message msg = new Message("FAILED_TO_ADD_SCHEMALOCATION", LOG, bindingFile);
                throw new ToolException(msg, e1);
            }
            jaxbBindings.add(tmpIns);
            
        }
    }
View Full Code Here

       
        for (String pathname : additionalFilePathnames) {
            try {
                reader.loadBeanDefinitions(new FileSystemResource(pathname));
            } catch (BeanDefinitionStoreException bdse) {
                throw new ToolException("Unable to open bean definition file " + pathname, bdse.getCause());
            }
        }
        appContext.refresh();
        return appContext;
    }
View Full Code Here

        try {
            return new OASISCatalogManagerHelper().resolve(catalogResolver,
                                                           url, null);
        } catch (Exception e1) {
            Message msg = new Message("FAILED_RESOLVE_CATALOG", LOG, url);
            throw new ToolException(msg, e1);
        }
    }
View Full Code Here

                LOG.log(Level.FINE, msg.toString(), e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    msg.append(System.getProperty("line.separator"));
                    if (args.contains("-X")) {
                        throw new ToolException(pluginUsage, e);
                    } else {
                        msg.append(pluginUsage);
                    }
                }

                throw new ToolException(msg.toString(), e);
            }
        }
       
        if (context.optionSet(ToolConstants.CFG_MARK_GENERATED)) {
            // Add the @Generated annotation in the Java files generated. This is done by passing
            // '-mark-generated' attribute to jaxb xjc.
            try {
                opts.parseArgument(new String[] {"-mark-generated" }, 0);
            } catch (BadCommandLineException e) {
                LOG.log(Level.SEVERE, e.getMessage());
                throw new ToolException(e);
            }
        }
        addSchemas(opts, schemaCompiler, schemas);
        addBindingFiles(opts, jaxbBindings, schemas);


        for (String ns : context.getNamespacePackageMap().keySet()) {
            File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, context.mapPackageName(ns));
            try {
                InputSource ins = new InputSource(file.toURI().toString());
                schemaCompiler.parseSchema(ins);
            } finally {
                FileUtils.delete(file);
            }
        }

        if (context.getPackageName() != null) {
            schemaCompiler.setDefaultPackageName(context.getPackageName());
        }

       
        rawJaxbModelGenCode = schemaCompiler.bind();

        addedEnumClassToCollector(schemas, allocator);

        if (context.get(ToolConstants.CFG_DEFAULT_VALUES) != null) {
            String cname = (String)context.get(ToolConstants.CFG_DEFAULT_VALUES);
            if (StringUtils.isEmpty(cname)) {
                defaultValues = new RandomValueProvider();
            } else {
                if (cname.charAt(0) == '=') {
                    cname = cname.substring(1);
                }
                try {
                    defaultValues = (DefaultValueProvider)Class.forName(cname).newInstance();
                } catch (Exception e) {
                    LOG.log(Level.SEVERE, e.getMessage());
                    throw new ToolException(e);
                }
            }
        }

        initialized = true;
View Full Code Here

                is.setPublicId(key);
                opts.addGrammar(is);
                try {
                    schemaCompiler.parseSchema(key, createNoCDATAReader(StaxUtils.createXMLStreamReader(ele, key)));
                } catch (XMLStreamException e) {
                    throw new ToolException(e);
                }
            }
        }
        for (XmlSchema schema : schemaCollection.getXmlSchemas()) {
            if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(schema.getTargetNamespace())) {
View Full Code Here

            }

            return;
        } catch (IOException e) {
            Message msg = new Message("FAIL_TO_GENERATE_TYPES", LOG);
            throw new ToolException(msg, e);
        }
    }
View Full Code Here

        } catch (SAXException e) {
            if (e.getLocalizedMessage().indexOf("src-resolve.4.2") > -1)  {
                //Ignore schema resolve error and do nothing
            } else {
                //e.printStackTrace();
                throw new ToolException("Schema Error : " + e.getLocalizedMessage(), e);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.tools.common.ToolException

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.