Ejemplo n.º 1
0
  /**
   * This method returns the properties that are located within the given property file. If the
   * properties have been cached and the cache is still fresh, then it will return the values from
   * the cache. If the properties are cached, but the cache is not fresh, then the cache will be
   * updated with the current values in the properties file and then the property values will be
   * returned. If the properties for that file are not cached at all, the property will be retrieved
   * from the properties file and returned.
   *
   * <p>NOTE: THIS IS AN EXPENSIVE OPERATION. IT WILL CREATE A DEEP COPY OF THE PROPERTIES AND
   * RETURN IT. THAT MEANS IT WILL CREATE AN EXACT REPLICA WITH ALL DATA. THIS IS A PROTECTION TO
   * MAKE SURE THAT A PROPERTY IS NOT INADVERTANTLY CHANGED OUTSIDE OF THIS CLASS.
   *
   * @param propertyFile The name of the properties file without the path or extension.
   * @throws PropertyAccessException This is thrown if an error occurs accessing the property.
   */
  public final synchronized Properties getProperties(String propertyFile)
      throws PropertyAccessException {
    validateInput(propertyFile);
    checkForRefreshAndLoad(propertyFile);

    return propertyFileDAO.getProperties(propertyFile);
  }
Ejemplo n.º 2
0
  /**
   * This will return the duration in milliseconds before the next refresh of the properties file. A
   * value of -1 indicates that no refresh will occur.
   *
   * @param propertyFile The name of the property file.
   * @throws PropertyAccessException This is thrown if an error occurs accessing the property.
   */
  public synchronized int getDurationBeforeNextRefresh(String propertyFile)
      throws PropertyAccessException {
    validateInput(propertyFile);
    checkForRefreshAndLoad(propertyFile);

    return refreshHandler.getDurationBeforeNextRefresh(propertyFile);
  }
Ejemplo n.º 3
0
  /**
   * This will return the long value conversion of the property. If the property value cannot be
   * converted to a long, an exception will be thrown.
   *
   * @param propertyFile The name of the property file.
   * @param propertyName The name of the property that contains a boolean value.
   * @return This will return the long representation of the value.
   * @throws PropertyAccessException This is thrown if an error occurs accessing the property.
   */
  public synchronized long getPropertyLong(String propertyFile, String propertyName)
      throws PropertyAccessException {
    validateInput(propertyFile, propertyName);
    checkForRefreshAndLoad(propertyFile);

    return propertyFileDAO.getPropertyLong(propertyFile, propertyName);
  }
Ejemplo n.º 4
0
  /**
   * This method dumps the properties and associated values for a properties file to the log file.
   *
   * @param propertyFile The name of the property file.
   * @throws PropertyAccessException This is thrown if an error occurs accessing the property.
   */
  public void dumpPropsToLog(String propertyFile) throws PropertyAccessException {
    validateInput(propertyFile);

    refreshHandler.printToLog(propertyFile);
    propertyFileDAO.printToLog(propertyFile);
  }
Ejemplo n.º 5
0
  /**
   * If a property file has been cached, this will force a refresh of the property file. If a
   * property file is not cached, then this operation will do nothing.
   *
   * @param propertyFile The name of the property file.
   * @throws PropertyAccessException This is thrown if an error occurs accessing the property.
   */
  public synchronized void forceRefresh(String propertyFile) throws PropertyAccessException {
    validateInput(propertyFile);

    loadPropertyFile(propertyFile);
  }