Package com.sun.tools.xjc

Examples of com.sun.tools.xjc.Options


        schemaCompiler.setErrorListener(listener);
        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        SchemaCollection schemas = (SchemaCollection) context.get(ToolConstants.XML_SCHEMA_COLLECTION);

        Options opts = null;
        opts = getOptions(schemaCompiler);

        List<String> args = new ArrayList<String>();

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
            args.add("-extension");
            String name = "/org/apache/cxf/tools/common/jaxb/W3CEPRJaxbBinding.xml";
            if (isJAXB22()) {
                name = "/org/apache/cxf/tools/common/jaxb/W3CEPRJaxbBinding_jaxb22.xml";
            }
            URL bindingFileUrl = getClass().getResource(name);
            InputSource ins = new InputSource(bindingFileUrl.toString());
            opts.addBindFile(ins);
        }

        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            Object o = context.get(ToolConstants.CFG_XJC_ARGS);
            if (o instanceof String) {
                o = new String[] {(String)o};
            }
            String[] xjcArgss = (String[])o;
            for (String xjcArgs : xjcArgss) {
                StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
                while (tokenizer.hasMoreTokens()) {
                    String arg = tokenizer.nextToken();
                    args.add(arg);
                    LOG.log(Level.FINE, "xjc arg:" + arg);
                }
            }
        }

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null
            || context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            try {
                // 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:";
                for (String arg : args) {
                    msg = msg + arg + " ";
                }
                LOG.log(Level.FINE, msg, e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    msg = msg + System.getProperty("line.separator");
                    if (args.contains("-X")) {
                        msg = pluginUsage;
                    } else {
                        msg += pluginUsage;
                    }
                }

                throw new ToolException(msg, 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);
            }
        }
View Full Code Here


        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        Map<String, Element> schemaLists = CastUtils.cast((Map<?, ?>)context.get(ToolConstants.SCHEMA_MAP));

       
        Options opts = null;
        opts = getOptions(schemaCompiler);
        List<String> args = new ArrayList<String>();
       
        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
            args.add("-extension");
            URL bindingFileUrl = getClass().getResource("W3CEPRJaxbBinding.xml");
            InputSource ins = new InputSource(bindingFileUrl.toString());
            opts.addBindFile(ins);
        }
       
        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            String xjcArgs = (String)context.get(ToolConstants.CFG_XJC_ARGS);
            StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
            while (tokenizer.hasMoreTokens()) {
                String arg = tokenizer.nextToken();
                args.add(arg);
                LOG.log(Level.FINE, "xjc arg:" + arg);
            }
        }

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null
            || context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            try {
                // 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:";
                for (String arg : args) {
                    msg = msg + arg + " ";
                }
                LOG.log(Level.FINE, msg, e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    msg = msg + System.getProperty("line.separator");
                    if (args.contains("-X")) {
                        msg = pluginUsage;
                    } else {
                        msg += pluginUsage;
                    }
                }

                throw new ToolException(msg, e);
            }
        }
       
       
        addSchemas(opts, schemaCompiler, schemaLists);

        for (InputSource binding : jaxbBindings) {
            opts.addBindFile(binding);
        }

                      
        for (String ns : context.getNamespacePackageMap().keySet()) {
            File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, context.mapPackageName(ns));
View Full Code Here

        schemaCompiler.setErrorListener(listener);
        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        SchemaCollection schemas = (SchemaCollection) context.get(ToolConstants.XML_SCHEMA_COLLECTION);

        Options opts = null;
        opts = getOptions(schemaCompiler);

        List<String> args = new ArrayList<String>();

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
            args.add("-extension");
            String name = "/org/apache/cxf/tools/common/jaxb/W3CEPRJaxbBinding.xml";
            if (isJAXB22()) {
                name = "/org/apache/cxf/tools/common/jaxb/W3CEPRJaxbBinding_jaxb22.xml";
            }
            URL bindingFileUrl = getClass().getResource(name);
            InputSource ins = new InputSource(bindingFileUrl.toString());
            opts.addBindFile(ins);
        }

        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            Object o = context.get(ToolConstants.CFG_XJC_ARGS);
            if (o instanceof String) {
                o = new String[] {(String)o};
            }
            String[] xjcArgss = (String[])o;
            for (String xjcArgs : xjcArgss) {
                StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
                while (tokenizer.hasMoreTokens()) {
                    String arg = tokenizer.nextToken();
                    args.add(arg);
                    LOG.log(Level.FINE, "xjc arg:" + arg);
                }
            }
        }

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null
            || context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            try {
                // 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:";
                for (String arg : args) {
                    msg = msg + arg + " ";
                }
                LOG.log(Level.FINE, msg, e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    msg = msg + System.getProperty("line.separator");
                    if (args.contains("-X")) {
                        msg = pluginUsage;
                    } else {
                        msg += pluginUsage;
                    }
                }

                throw new ToolException(msg, 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);
            }
        }
View Full Code Here

        schemaCompiler.setErrorListener(listener);
        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        SchemaCollection schemas = (SchemaCollection) context.get(ToolConstants.XML_SCHEMA_COLLECTION);

        Options opts = null;
        opts = getOptions(schemaCompiler);

        List<String> args = new ArrayList<String>();

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
            args.add("-extension");
            String name = "/org/apache/cxf/tools/common/jaxb/W3CEPRJaxbBinding.xml";
            if (isJAXB22()) {
                name = "/org/apache/cxf/tools/common/jaxb/W3CEPRJaxbBinding_jaxb22.xml";
            }
            URL bindingFileUrl = getClass().getResource(name);
            InputSource ins = new InputSource(bindingFileUrl.toString());
            opts.addBindFile(ins);
        }

        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            Object o = context.get(ToolConstants.CFG_XJC_ARGS);
            if (o instanceof String) {
                o = new String[] {(String)o};
            }
            String[] xjcArgss = (String[])o;
            for (String xjcArgs : xjcArgss) {
                StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
                while (tokenizer.hasMoreTokens()) {
                    String arg = tokenizer.nextToken();
                    args.add(arg);
                    LOG.log(Level.FINE, "xjc arg:" + arg);
                }
            }
        }

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null
            || context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            try {
                // 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:";
                for (String arg : args) {
                    msg = msg + arg + " ";
                }
                LOG.log(Level.FINE, msg, e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    msg = msg + System.getProperty("line.separator");
                    if (args.contains("-X")) {
                        msg = pluginUsage;
                    } else {
                        msg += pluginUsage;
                    }
                }

                throw new ToolException(msg, 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);
            }
        }
View Full Code Here

        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        Map<String, Element> schemaLists = CastUtils.cast((Map<?, ?>)context.get(ToolConstants.SCHEMA_MAP));

       
        Options opts = null;
        opts = getOptions(schemaCompiler);
        List<String> args = new ArrayList<String>();
       
        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
            args.add("-extension");
            URL bindingFileUrl = getClass().getResource("W3CEPRJaxbBinding.xml");
            InputSource ins = new InputSource(bindingFileUrl.toString());
            opts.addBindFile(ins);
        }
       
        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            String xjcArgs = (String)context.get(ToolConstants.CFG_XJC_ARGS);
            StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
            while (tokenizer.hasMoreTokens()) {
                String arg = tokenizer.nextToken();
                args.add(arg);
                LOG.log(Level.FINE, "xjc arg:" + arg);
            }
        }

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null
            || context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            try {
                // 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:";
                for (String arg : args) {
                    msg = msg + arg + " ";
                }
                LOG.log(Level.FINE, msg, e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    msg = msg + System.getProperty("line.separator");
                    if (args.contains("-X")) {
                        msg = pluginUsage;
                    } else {
                        msg += pluginUsage;
                    }
                }

                throw new ToolException(msg, e);
            }
        }
       
       
        addSchemas(opts, schemaCompiler, schemaLists);

        for (InputSource binding : jaxbBindings) {
            opts.addBindFile(binding);
        }

                      
        for (String ns : context.getNamespacePackageMap().keySet()) {
            File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, context.mapPackageName(ns));
View Full Code Here

        schemaCompiler.setErrorListener(listener);
        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        SchemaCollection schemas = (SchemaCollection) context.get(ToolConstants.XML_SCHEMA_COLLECTION);

        Options opts = null;
        opts = getOptions(schemaCompiler);

        List<String> args = new ArrayList<String>();

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
            args.add("-extension");
            String name = "/org/apache/cxf/tools/common/jaxb/W3CEPRJaxbBinding.xml";
            if (isJAXB22()) {
                name = "/org/apache/cxf/tools/common/jaxb/W3CEPRJaxbBinding_jaxb22.xml";
            }
            URL bindingFileUrl = getClass().getResource(name);
            InputSource ins = new InputSource(bindingFileUrl.toString());
            opts.addBindFile(ins);
        }

        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            Object o = context.get(ToolConstants.CFG_XJC_ARGS);
            if (o instanceof String) {
                o = new String[] {(String)o};
            }
            String[] xjcArgss = (String[])o;
            for (String xjcArgs : xjcArgss) {
                StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
                while (tokenizer.hasMoreTokens()) {
                    String arg = tokenizer.nextToken();
                    args.add(arg);
                    LOG.log(Level.FINE, "xjc arg:" + arg);
                }
            }
        }

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null
            || context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            try {
                // 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:";
                for (String arg : args) {
                    msg = msg + arg + " ";
                }
                LOG.log(Level.FINE, msg, e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    msg = msg + System.getProperty("line.separator");
                    if (args.contains("-X")) {
                        msg = pluginUsage;
                    } else {
                        msg += pluginUsage;
                    }
                }

                throw new ToolException(msg, 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);
            }
        }
View Full Code Here

        schemaCompiler.setErrorListener(listener);
        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        SchemaCollection schemas = (SchemaCollection) context.get(ToolConstants.XML_SCHEMA_COLLECTION);
       
        Options opts = null;
        opts = getOptions(schemaCompiler);
       
        List<String> args = new ArrayList<String>();
       
        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
            args.add("-extension");
            String name = "W3CEPRJaxbBinding.xml";
            if (isJAXB22()) {
                name = "W3CEPRJaxbBinding_jaxb22.xml";
            }
            URL bindingFileUrl = getClass().getResource(name);
            InputSource ins = new InputSource(bindingFileUrl.toString());
            opts.addBindFile(ins);
        }
       
        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            Object o = context.get(ToolConstants.CFG_XJC_ARGS);
            if (o instanceof String) {
                o = new String[] {(String)o};
            }
            String[] xjcArgss = (String[])o;
            for (String xjcArgs : xjcArgss) {
                StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
                while (tokenizer.hasMoreTokens()) {
                    String arg = tokenizer.nextToken();
                    args.add(arg);
                    LOG.log(Level.FINE, "xjc arg:" + arg);
                }
            }
        }

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null
            || context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            try {
                // 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:";
                for (String arg : args) {
                    msg = msg + arg + " ";
                }
View Full Code Here

        schemaCompiler.setErrorListener(listener);
        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        SchemaCollection schemas = (SchemaCollection) context.get(ToolConstants.XML_SCHEMA_COLLECTION);
       
        Options opts = null;
        opts = getOptions(schemaCompiler);
       
        List<String> args = new ArrayList<String>();
       
        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
            args.add("-extension");
            String name = "W3CEPRJaxbBinding.xml";
            if (isJAXB22()) {
                name = "W3CEPRJaxbBinding_jaxb22.xml";
            }
            URL bindingFileUrl = getClass().getResource(name);
            InputSource ins = new InputSource(bindingFileUrl.toString());
            opts.addBindFile(ins);
        }
       
        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            Object o = context.get(ToolConstants.CFG_XJC_ARGS);
            if (o instanceof String) {
                o = new String[] {(String)o};
            }
            String[] xjcArgss = (String[])o;
            for (String xjcArgs : xjcArgss) {
                StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
                while (tokenizer.hasMoreTokens()) {
                    String arg = tokenizer.nextToken();
                    args.add(arg);
                    LOG.log(Level.FINE, "xjc arg:" + arg);
                }
            }
        }

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null
            || context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            try {
                // 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:";
                for (String arg : args) {
                    msg = msg + arg + " ";
                }
                LOG.log(Level.FINE, msg, e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    msg = msg + System.getProperty("line.separator");
                    if (args.contains("-X")) {
                        msg = pluginUsage;
                    } else {
                        msg += pluginUsage;
                    }
                }

                throw new ToolException(msg, 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);
            }
        }
View Full Code Here

        schemaCompiler.setErrorListener(listener);
        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        SchemaCollection schemas = (SchemaCollection) context.get(ToolConstants.XML_SCHEMA_COLLECTION);

        Options opts = null;
        opts = getOptions(schemaCompiler);

        List<String> args = new ArrayList<String>();

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
            args.add("-extension");
            String name = "/org/apache/cxf/tools/common/jaxb/W3CEPRJaxbBinding.xml";
            if (isJAXB22()) {
                name = "/org/apache/cxf/tools/common/jaxb/W3CEPRJaxbBinding_jaxb22.xml";
            }
            URL bindingFileUrl = getClass().getResource(name);
            InputSource ins = new InputSource(bindingFileUrl.toString());
            opts.addBindFile(ins);
        }

        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            Object o = context.get(ToolConstants.CFG_XJC_ARGS);
            if (o instanceof String) {
                o = new String[] {(String)o};
            }
            String[] xjcArgss = (String[])o;
            for (String xjcArgs : xjcArgss) {
                StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
                while (tokenizer.hasMoreTokens()) {
                    String arg = tokenizer.nextToken();
                    args.add(arg);
                    LOG.log(Level.FINE, "xjc arg:" + arg);
                }
            }
        }

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null
            || context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            try {
                // 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:";
                for (String arg : args) {
                    msg = msg + arg + " ";
                }
                LOG.log(Level.FINE, msg, e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    msg = msg + System.getProperty("line.separator");
                    if (args.contains("-X")) {
                        msg = pluginUsage;
                    } else {
                        msg += pluginUsage;
                    }
                }

                throw new ToolException(msg, 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);
            }
        }
View Full Code Here

        schemaCompiler.setErrorListener(listener);
        // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
        List<InputSource> jaxbBindings = context.getJaxbBindingFile();
        SchemaCollection schemas = (SchemaCollection) context.get(ToolConstants.XML_SCHEMA_COLLECTION);

        Options opts = null;
        opts = getOptions(schemaCompiler);

        List<String> args = new ArrayList<String>();

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
            //hard code to enable jaxb extensions
            args.add("-extension");
            String name = "W3CEPRJaxbBinding.xml";
            if (isJAXB22()) {
                name = "W3CEPRJaxbBinding_jaxb22.xml";
            }
            URL bindingFileUrl = getClass().getResource(name);
            InputSource ins = new InputSource(bindingFileUrl.toString());
            opts.addBindFile(ins);
        }

        if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            Object o = context.get(ToolConstants.CFG_XJC_ARGS);
            if (o instanceof String) {
                o = new String[] {(String)o};
            }
            String[] xjcArgss = (String[])o;
            for (String xjcArgs : xjcArgss) {
                StringTokenizer tokenizer = new StringTokenizer(xjcArgs, ",", false);
                while (tokenizer.hasMoreTokens()) {
                    String arg = tokenizer.nextToken();
                    args.add(arg);
                    LOG.log(Level.FINE, "xjc arg:" + arg);
                }
            }
        }

        if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null
            || context.get(ToolConstants.CFG_XJC_ARGS) != null) {
            try {
                // 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:";
                for (String arg : args) {
                    msg = msg + arg + " ";
                }
                LOG.log(Level.FINE, msg, e);
                if (opts != null) {
                    String pluginUsage = getPluginUsageString(opts);
                    msg = msg + System.getProperty("line.separator");
                    if (args.contains("-X")) {
                        msg = pluginUsage;
                    } else {
                        msg += pluginUsage;
                    }
                }

                throw new ToolException(msg, 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);
            }
        }
View Full Code Here

TOP

Related Classes of com.sun.tools.xjc.Options

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.