public boolean check() { final Properties oldProps = new Properties(); if (BindingFileSearch.CACHE_LIST.exists()) { try { Reader propIn = Files.newReader(BindingFileSearch.CACHE_LIST, Charset.defaultCharset()); oldProps.load(propIn); } catch (Exception ex) { LOG.debug(ex, ex); } } Map<String, String> oldBindings = Maps.fromProperties(oldProps); Map<String, String> newBindings = Maps.fromProperties(BindingFileSearch.CURRENT_PROPS); if (oldBindings.equals(newBindings)) { LOG.info("Found up-to-date binding class cache: skipping message binding."); return true; } else { MapDifference<String, String> diffBindings = Maps.difference(oldBindings, newBindings); LOG.info("Binding class cache expired (old,new): \n" + diffBindings.entriesDiffering()); try { Files.deleteRecursively(SubDirectory.CLASSCACHE.getFile()); } catch (IOException ex) { LOG.error(ex, ex); } SubDirectory.CLASSCACHE.getFile().mkdir(); return false; } }
private BindingFileSearch() { try { CACHE_CLASS_LOADER = new URLClassLoader(new URL[] {SubDirectory.CLASSCACHE.getFile().toURL()}); MSG_BASE_CLASS = Class.forName("edu.ucsb.eucalyptus.msgs.BaseMessage"); MSG_DATA_CLASS = Class.forName("edu.ucsb.eucalyptus.msgs.EucalyptusData"); } catch (Exception ex) { LOG.error(ex, ex); throw Exceptions.toUndeclared(ex); } }
public void store() throws IOException { Writer propOut = new FileWriter(CACHE_LIST); try { try { CURRENT_PROPS.store(propOut, "Binding class cache generated on: "); propOut.close(); } catch (Exception ex) { LOG.error(ex, ex); propOut.close(); } } catch (IOException ex) { for (File f : SubDirectory.CLASSCACHE.getFile().listFiles()) { try { LOG.info("Cleaning up class cache: " + f.getCanonicalPath()); Files.deleteRecursively(f); } catch (IOException ex1) { LOG.error(ex1, ex1); } } throw ex; } }
public InternalSoapBindingGenerator() { this.outFile = new File(SubDirectory.CLASSCACHE.getFile().getAbsolutePath() + "/msgs-binding.xml"); }