org.productivity.java.habitat4j
Class PropertyListReloadInhibitor

java.lang.Object
  extended by org.productivity.java.habitat4j.PropertyListReloadInhibitor

public class PropertyListReloadInhibitor
extends java.lang.Object

PropertyListReloadInhibitor provides a facility to globally inhibit reloading of PropertyList files. It is primarily used when a block of code obtaining a group of properties is sensitive to property changes that may change some of the values and badly affect others in that group.

## LICENSE INFORMATION ##

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Version:
$Id: PropertyListReloadInhibitor.html,v 1.2 2008/11/24 15:15:20 cvs Exp $
Author:
Justin Yunke <habitat4j@productivity.org>

Field Summary
protected  java.util.Hashtable reloadHash
           
 
Method Summary
 void disable()
          Disables the reload inhibitor.
 void enable()
          Enables the reload inhibitor.
 void enable(long expiration)
          Enables the reload inhibitor.
protected  java.lang.Integer getCurrentThreadHash()
           
static PropertyListReloadInhibitor getInstance()
           
 boolean isReloadInhibited()
           
protected  void removeAnyStaleEntries()
          Checks for and removes stale entries in the reloadHash Hashtable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reloadHash

protected java.util.Hashtable reloadHash
Method Detail

getInstance

public static PropertyListReloadInhibitor getInstance()
Returns:
Returns the Singleton instance of this class.

getCurrentThreadHash

protected java.lang.Integer getCurrentThreadHash()
Returns:
Returns the Integer value of the current Thread's hashCode().

enable

public void enable(long expiration)
Enables the reload inhibitor. This will stop Habitat4J from reloading PropertyList files.

Parameters:
expiration - - time in milliseconds for the calling Thread to inhibit reloading

enable

public void enable()
Enables the reload inhibitor. This will stop Habitat4J from reloading PropertyList files.


disable

public void disable()
Disables the reload inhibitor. This will allow Habitat4J to reload PropertyList files.


removeAnyStaleEntries

protected void removeAnyStaleEntries()
Checks for and removes stale entries in the reloadHash Hashtable. Does not need to be synchronized, since the only calling method (isReloadInhibited) has a synchronize block within it.


isReloadInhibited

public boolean isReloadInhibited()
Returns:
Returns whether reload capabilities within Habitat4J are inhibited