public static void processFiles() { final File libDir = new File(BaseDirectory.LIB.toString()); for (final File f : libDir.listFiles()) { if (f.getName().startsWith("eucalyptus") && f.getName().endsWith(".jar") && !f.getName().matches(".*-ext-.*")) { EventRecord.here( ServiceJarDiscovery.class, EventType.BOOTSTRAP_INIT_SERVICE_JAR, f.getName()) .info(); try { BindingFileSearch.INSTANCE.process(f); } catch (final Throwable e) { LOG.error(e.getMessage()); continue; } } } for (String pathName : ClassPath.SYSTEM_CLASS_PATH.getClassPath().split(File.pathSeparator)) { File pathFile = new File(pathName); if (pathFile.isDirectory()) { try { BindingFileSearch.INSTANCE.process(pathFile); } catch (final Throwable e) { LOG.error(e.getMessage()); continue; } ; } } }
public static void compile() { LOG.info("Binding cache: processing message and binding files."); processFiles(); if (BindingFileSearch.INSTANCE.check()) { LOG.info("Binding cache: nothing to do."); } else { LOG.info("Binding cache: regenerating cache."); try { LOG.info("Binding cache: generating internal bindings."); // generate msgs-binding InternalSoapBindingGenerator gen = new InternalSoapBindingGenerator(); for (Class genBindClass : BindingFileSearch.BINDING_CLASS_MAP.values()) { Logs.extreme().debug("Generating binding: " + genBindClass); gen.processClass(genBindClass); } gen.close(); BINDING_LIST.add(gen.getOutFile().toURI()); LOG.info("Binding cache: populating cache from transitive closure of bindings."); // load *-binding.xml, populate cache w/ all referenced files BindingFileSearch.reset(Utility.getClassPaths()); Iterables.all(BindingFileSearch.BINDING_LIST, BindingFileSearch.INSTANCE); BindingFileSearch.reset(Utility.getClassPaths()); LOG.info("Binding cache: loading and validating bindings."); Map<URI, BindingDefinition> bindingDefs = Maps.newHashMap(); PrintStream oldOut = System.out, oldErr = System.err; for (URI binding : BINDING_LIST) { String shortPath = binding.toURL().getPath().replaceAll(".*!/", ""); String sname = Utility.bindingFromFileName(shortPath); BindingDefinition def = Utility.loadBinding( binding.toASCIIString(), sname, binding.toURL().openStream(), binding.toURL(), true); bindingDefs.put(binding, def); def.print(); } LOG.info("Binding cache: compiling bindings."); for (Entry<URI, BindingDefinition> def : bindingDefs.entrySet()) { try { LOG.debug("Binding cache: " + def.getKey()); def.getValue() .generateCode( BindingFileSearch.BINDING_DEBUG, BindingFileSearch.BINDING_DEBUG_EXTREME); } catch (RuntimeException e) { throw new JiBXException( "\n*** Error during code generation for file '" + def.getKey() + "' -\n this may be due to an error in " + "your binding or classpath, or to an error in the " + "JiBX code ***\n", e); } } ClassFile[][] lists = MungedClass.fixDispositions(); for (BindingDefinition def : bindingDefs.values()) { def.addClassList(lists[0], lists[1]); } MungedClass.writeChanges(); LOG.info("Binding cache: wrote " + lists[0].length + " files"); LOG.info("Binding cache: kept " + lists[1].length + " files unchanged:"); LOG.info("Binding cache: deleted " + lists[2].length + " files:"); BindingFileSearch.INSTANCE.store(); System.exit(123); // success! now we restart. } catch (Exception ex) { LOG.error(ex, ex); System.exit(1); throw new Error( "Failed to prepare the system while trying to compile bindings: " + ex.getMessage(), ex); } } }