compile.java
来自「对xml很好的java处理引擎,编译中绑定xml」· Java 代码 · 共 418 行 · 第 1/2 页
JAVA
418 行
} } // report summary information for files unchanged or deleted if (m_verbose) { files = lists[1]; System.out.println("\nKept " + files.length + " files unchanged:"); for (int i = 0; i < files.length; i++) { System.out.println(" " + files[i].getName()); } files = lists[2]; System.out.println("\nDeleted " + files.length + " files:"); for (int i = 0; i < files.length; i++) { System.out.println(" " + files[i].getName()); } } } /** * Set control flag for test loading generated/modified classes. * * @param load test load generated/modified classes flag */ public void setLoad(boolean load) { m_load = load; } /** * Set control flag for verbose processing reports. * * @param verbose report verbose information in processing bindings flag */ public void setVerbose(boolean verbose) { m_verbose = verbose; } /** * Set control flag for verifying generated/modified classes with BCEL. * * @param verify use BCEL verification for generated/modified classes flag */ public void setVerify(boolean verify) { m_verify = verify; } /** * Set control flag for skipping binding validation. This flag is intended * only for use while processing the binding model components within JiBX. * Otherwise it'd be impossible to correct errors in the binding validation. * * @param skip test load generated/modified classes flag */ public void setSkipValidate(boolean skip) { m_skipValidate = skip; } /** * Compile a set of bindings using supplied classpaths. * * @param paths list of paths for loading classes * @param files list of binding definition files * @exception JiBXException if error in processing the binding definition */ public void compile(String[] paths, String[] files) throws JiBXException { try { // include current version information in verbose output if (m_verbose) { System.out.println("Running binding compiler version " + BindingDefinition.CURRENT_VERSION_NAME); } // set paths to be used for loading referenced classes ClassCache.setPaths(paths); ClassFile.setPaths(paths); // reset static information accumulation for binding BoundClass.reset(); MungedClass.reset(); BindingDefinition.reset(); BranchWrapper.setTracking(m_trackBranches); BranchWrapper.setErrorOverride(m_errorOverride); // load all supplied bindings BindingDefinition[] defs = new BindingDefinition[files.length]; for (int i = 0; i < files.length; i++) { defs[i] = Utility.loadFileBinding(files[i], !m_skipValidate); if (m_verbose) { defs[i].print(); } } // modify the class files with JiBX hooks for (int i = 0; i < defs.length; i++) { try { defs[i].generateCode(m_verbose); } catch (RuntimeException e) { throw new JiBXException ("\n*** Error during code generation for file '" + files[i] + "' - please enter a bug report for this " + "error in Jira if the problem is not listed as fixed " + "on the online status page ***\n", e); } } // handle file and reporting output handleOutput(paths); } catch (IOException ex) { throw new JiBXException("IOException in compile", ex); } catch (ExceptionInInitializerError ex) { throw new JiBXException("Error during initialization;" + " is jibx-run.jar in load classpath?", ex.getException()); } catch (Throwable ex) { throw new JiBXException("Error running binding compiler", ex); } } /** * Main method for running compiler as application. * * @param args command line arguments */ public static void main(String[] args) { if (args.length > 0) { try { // check for various flags set boolean verbose = false; boolean load = false; boolean verify = false; boolean track = false; boolean over = false; boolean skip = false; int offset = 0; for (; offset < 5 && offset < args.length; offset++) { String arg = args[offset]; if ("-v".equalsIgnoreCase(arg)) { verbose = true; } else if ("-l".equalsIgnoreCase(arg)) { load = true; } else if ("-b".equalsIgnoreCase(arg)) { verify = true; } else if ("-o".equalsIgnoreCase(arg)) { over = true; } else if ("-s".equalsIgnoreCase(arg)) { skip = true; } else if ("-t".equalsIgnoreCase(arg)) { track = true; } else { break; } } // set up path and binding lists String[] clsspths = Utility.getClassPaths(); String[] bindings = new String[args.length - offset]; System.arraycopy(args, offset, bindings, 0, bindings.length); // report on the configuration if (verbose) { System.out.println("Using paths:"); for (int i = 0; i < clsspths.length; i++) { System.out.println(" " + clsspths[i]); } System.out.println("Using bindings:"); for (int i = 0; i < bindings.length; i++) { System.out.println(" " + bindings[i]); } } // compile the bindings Compile compiler = new Compile(verbose, load, verify, track, over); compiler.setSkipValidate(skip); compiler.compile(clsspths, bindings); } catch (JiBXException ex) { ex.printStackTrace(System.out); System.exit(1); } } else { System.out.println ("\nUsage: java org.jibx.binding.Compile [-b] [-l] [-v] " + "binding1 binding2 ...\nwhere:\n -b turns on BCEL " + "verification (debug option),\n -l turns on test loading of " + "modified or generated classes for validation, and\n" + " -v turns on verbose output\nThe bindingn files are " + "different bindings to be compiled.\n"); System.exit(1); } } /** * Direct class loader. This is optionally used for test loading the * modified class files to make sure they're still valid. */ private static class DirectLoader extends URLClassLoader { protected DirectLoader(URL[] urls) { super(urls, DirectLoader.class.getClassLoader()); } protected Class load(String name, byte[] data) { return defineClass(name, data, 0, data.length); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?