/** * Saves the lookup table to the filesystem resource. */ protected void save() { try { OutputStream out = file.getOutputStream(); try { Properties properties = new Properties(); for (Map.Entry<String, Integer> entry : stringToIndex.entrySet()) { properties.setProperty( entry.getKey(), entry.getValue().toString()); } properties.store(out, "string index"); } finally { out.close(); } lastModified = file.lastModified(); } catch (Exception e) { throw new IllegalStateException("Unable to store lookup table", e); } }
/** * Checks if the synonym properties file has been updated and this provider * should reload the synonyms. This method performs the actual check at most * every {@link #CHECK_INTERVAL}. If reloading fails an error is logged and * this provider will retry after {@link #CHECK_INTERVAL}. */ private synchronized void checkConfigUpdated() { if (lastCheck + CHECK_INTERVAL > System.currentTimeMillis()) { return; } // check last modified try { if (configLastModified != config.lastModified()) { synonyms = getSynonyms(config); configLastModified = config.lastModified(); log.info("Reloaded synonyms from {}", config.getPath()); } } catch (Exception e) { log.error("Exception while reading synonyms", e); } // update lastCheck timestamp, even if error occurred (retry later) lastCheck = System.currentTimeMillis(); }
/** * Saves the lookup table to the filesystem resource. */ protected void save() { try { OutputStream out = file.getOutputStream(); try { Properties properties = new Properties(); for (Map.Entry<String, Integer> entry : stringToIndex.entrySet()) { properties.setProperty( entry.getKey(), entry.getValue().toString()); } properties.store(out, "string index"); } finally { out.close(); } lastModified = file.lastModified(); } catch (Exception e) { throw new IllegalStateException("Unable to store lookup table", e); } }
/** * Checks if the synonym properties file has been updated and this provider * should reload the synonyms. This method performs the actual check at most * every {@link #CHECK_INTERVAL}. If reloading fails an error is logged and * this provider will retry after {@link #CHECK_INTERVAL}. */ private synchronized void checkConfigUpdated() { if (lastCheck + CHECK_INTERVAL > System.currentTimeMillis()) { return; } // check last modified try { if (configLastModified != config.lastModified()) { synonyms = getSynonyms(config); configLastModified = config.lastModified(); log.info("Reloaded synonyms from {}", config.getPath()); } } catch (Exception e) { log.error("Exception while reading synonyms", e); } // update lastCheck timestamp, even if error occurred (retry later) lastCheck = System.currentTimeMillis(); }
/** * Loads the lookup table from the filesystem resource. */ protected void load() { try { long modTime = file.lastModified(); if (modTime != lastModified) { lastModified = modTime; InputStream in = file.getInputStream(); try { Properties properties = new Properties(); properties.load(in); for (Object name : Collections.list(properties.propertyNames())) { String string = name.toString(); Integer index = Integer.valueOf(properties.getProperty(string)); stringToIndex.put(string, index); indexToString.put(index, string); } } finally { in.close(); } } } catch (Exception e) { throw new IllegalStateException("Unable to load lookup table", e); } }
/** * {@inheritDoc} */ public synchronized void initialize(FileSystemResource fsr) throws IOException { if (fsr == null) { throw new IOException("PropertiesSynonymProvider requires a path configuration"); } try { config = fsr; synonyms = getSynonyms(config); configLastModified = config.lastModified(); lastCheck = System.currentTimeMillis(); } catch (FileSystemException e) { throw Util.createIOException(e); } }
/** * Loads the lookup table from the filesystem resource. */ protected void load() { try { long modTime = file.lastModified(); if (modTime != lastModified) { lastModified = modTime; InputStream in = file.getInputStream(); try { Properties properties = new Properties(); properties.load(in); for (Object name : Collections.list(properties.propertyNames())) { String string = name.toString(); Integer index = Integer.valueOf(properties.getProperty(string)); stringToIndex.put(string, index); indexToString.put(index, string); } } finally { in.close(); } } } catch (Exception e) { throw new IllegalStateException("Unable to load lookup table", e); } }
/** * {@inheritDoc} */ public synchronized void initialize(FileSystemResource fsr) throws IOException { if (fsr == null) { throw new IOException("PropertiesSynonymProvider requires a path configuration"); } try { config = fsr; synonyms = getSynonyms(config); configLastModified = config.lastModified(); lastCheck = System.currentTimeMillis(); } catch (FileSystemException e) { throw Util.createIOException(e); } }
&& (identifiersToDeleteFile.lastModified() + (delayedDeleteSleep * 1000)) < System .currentTimeMillis()) { deleteDelayedIdentifiersTaskThread = new Thread(
&& (identifiersToDeleteFile.lastModified() + (delayedDeleteSleep * 1000)) < System .currentTimeMillis()) { deleteDelayedIdentifiersTaskThread = new Thread(
&& (identifiersToDeleteFile.lastModified() + (delayedDeleteSleep * 1000)) < System .currentTimeMillis()) { deleteDelayedIdentifiersTaskThread = new Thread(