Package com.sun.tools.xjc.api.impl.s2j

Examples of com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl


     *
     * @return
     *      always return non-null object.
     */
    public static SchemaCompiler createSchemaCompiler() {
        return new SchemaCompilerImpl();
    }
View Full Code Here


    @SuppressWarnings("unchecked")
    private void initialize(ToolContext c) throws ToolException {
        this.context = c;

       
        SchemaCompilerImpl schemaCompiler = (SchemaCompilerImpl)XJC.createSchemaCompiler();
        ClassCollector classCollector = context.get(ClassCollector.class);
        ClassNameAllocatorImpl allocator = new ClassNameAllocatorImpl(classCollector);

        schemaCompiler.setClassNameAllocator(allocator);
          
        JAXBBindErrorListener listener = new JAXBBindErrorListener(context.isVerbose());
        schemaCompiler.setErrorListener(listener);
        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        Map<String, Element> schemaLists = (Map<String, Element>)context.get(ToolConstants.SCHEMA_MAP);

        Set<String> keys = schemaLists.keySet();
        for (String key : keys) {
            Element ele = schemaLists.get(key);
            this.removeImportElement(ele);
            String tns = ele.getAttribute("targetNamespace");
            if (StringUtils.isEmpty(tns)) {
                continue;
            }
            if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
                validateSchema(ele);
            }
            schemaCompiler.parseSchema(key, ele);

        }

        for (InputSource binding : jaxbBindings) {
            schemaCompiler.parseSchema(binding);
        }

        /*if (context.getPackageName() != null) {
            schemaCompiler.forcePackageName(context.getPackageName());
        } else {*/
           
           
        Map<String, String> nsPkgMap = context.getNamespacePackageMap();
        for (String ns : nsPkgMap.keySet()) {
            File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, context.mapPackageName(ns));
            InputSource ins = new InputSource(file.toURI().toString());
            schemaCompiler.parseSchema(ins);
            FileUtils.delete(file);
        }
       
        if (context.getPackageName() != null) {
            schemaCompiler.setDefaultPackageName(context.getPackageName());
       
       

        rawJaxbModelGenCode = schemaCompiler.bind();

        addedEnumClassToCollector(schemaLists, allocator);
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public void initialize(ToolContext c) throws ToolException {
        this.context = c;

       
        SchemaCompilerImpl schemaCompiler = (SchemaCompilerImpl)XJC.createSchemaCompiler();
        ClassCollector classCollector = context.get(ClassCollector.class);
        ClassNameAllocatorImpl allocator = new ClassNameAllocatorImpl(classCollector);

        schemaCompiler.setClassNameAllocator(allocator);
          
        JAXBBindErrorListener listener = new JAXBBindErrorListener(context.isVerbose());
        schemaCompiler.setErrorListener(listener);
        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        Map<String, Element> schemaLists = (Map<String, Element>)context.get(ToolConstants.SCHEMA_MAP);

        Set<String> keys = schemaLists.keySet();
        for (String key : keys) {
            Element ele = schemaLists.get(key);
            this.removeImportElement(ele);
            String tns = ele.getAttribute("targetNamespace");
            if (StringUtils.isEmpty(tns)) {
                continue;
            }
            if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
                validateSchema(ele);
            }          
            schemaCompiler.parseSchema(key, ele);

        }

        for (InputSource binding : jaxbBindings) {
            schemaCompiler.parseSchema(binding);
        }

                      
        Map<String, String> nsPkgMap = context.getNamespacePackageMap();
        for (String ns : nsPkgMap.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());
       
       

        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            String xjcArgs = (String)context.get(ToolConstants.CFG_XJC_ARGS);
            Vector<String> args = new Vector<String>();
            StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
            while (tokenizer.hasMoreTokens()) {
                String arg = tokenizer.nextToken();
                args.add(arg);
                LOG.log(Level.FINE, "xjc arg:" + arg);
            }
            Options opts = null;
            try {
                opts = getOptions(schemaCompiler);
                // keep parseArguments happy, supply dummy required command-line opts
                opts.addGrammar(new InputSource("null"));
                opts.parseArguments(args.toArray(new String[]{}));
            } catch (BadCommandLineException e) {
                String msg = "XJC reported 'BadCommandLineException' for -xjc argument:" + xjcArgs;
                LOG.log(Level.FINE, msg, e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    if ("-X".equals(xjcArgs)) {
                        msg = pluginUsage;
                    } else {
                        msg += pluginUsage;
                    }
                }
               
                throw new ToolException(msg, e);
            }
        }

        rawJaxbModelGenCode = schemaCompiler.bind();

        addedEnumClassToCollector(schemaLists, allocator);

        if (context.get(ToolConstants.CFG_DEFAULT_VALUES) != null) {
            String cname = (String)context.get(ToolConstants.CFG_DEFAULT_VALUES);
View Full Code Here

     *
     * @return
     *      always return non-null object.
     */
    public static SchemaCompiler createSchemaCompiler() {
        return new SchemaCompilerImpl();
    }
View Full Code Here

     *
     * @return
     *      always return non-null object.
     */
    public static SchemaCompiler createSchemaCompiler() {
        return new SchemaCompilerImpl();
    }
View Full Code Here

TOP

Related Classes of com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl

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.