com.infoengine.au
Class IEProperties

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byjava.util.Properties
              extended bycom.infoengine.au.IEProperties
All Implemented Interfaces:
Cloneable, Map, Serializable

public class IEProperties
extends Properties

Properties object meant to replace the System Properties object. This class facilitates Info*Engine properties that can be re-loaded at runtime and allows for multiple services within the same JVM to use independant property sets. All regular java.util.Properties and java.util.Hashtable methods are over-ridden to route method calls to the appropriate property set. Info*Engine classes that usually instantiate the NamingService and that wish to allow for multiple property sets during runtime should reset the System Properties object prior to setting any properties and creating the namingService like: // // retrieve the singleton IEProperties // IEProperties p = NamingService.getIEProperties(); // tell the properties who you are p.registerThread ( ); // create an empty property set for yourself p.initializeProperties(); // see if you should register as the global service if ( p.getGlobalServiceName() == null ) p.setGlobalServiceName ( ); Info*Engine classes that make use of static objects references (that aren't final) should store and retrieve those references from this Properties object using the *StaticObjectReference methods. If they don't do so Info*Engine services may be sharing object references that are not applicable to one another.

See Also:
Serialized Form

Nested Class Summary
(package private)  class IEProperties.PropertiesWrapper
           
(package private)  class IEProperties.PropertyAssociation
          simple class to associate parent services with child services
(package private)  class IEProperties.ThreadRegistration
          simple class representing a thread's registration
 
Nested classes inherited from class java.util.Hashtable
 
Field Summary
private  Vector associations
           
private  Properties defaults
           
private  long globalCreationTime
           
private  Vector globalPropertyListeners
           
private  String globalPropertySource
           
private  String globalServiceName
           
private  Hashtable globalStaticObjects
           
private  long globalTimeToLive
           
private  Hashtable localStaticObjects
           
private  Hashtable properties
           
private static String[] propertyNameMap
           
private static String[] propertyNamePrefixes
           
private  Hashtable propertySources
           
private  Vector registeredThreads
           
 
Fields inherited from class java.util.Properties
 
Fields inherited from class java.util.Hashtable
 
Constructor Summary
IEProperties()
          create an empty set of IEProperties
IEProperties(Properties defaults)
          create a set of IEProperties with defaults
 
Method Summary
private  void _registerThread(String serviceName)
          add a thread to the list of registered threads
 void associate(String parent, String child)
          associate service1 with service2.
private  Properties backUpProperties(Properties old)
           
 void clear()
          Clears this hashtable so that it contains no keys.
 Object clone()
          Creates a shallow copy of this hashtable.
 boolean contains(Object value)
          Tests if some key maps into the specified value in this hashtable.
 boolean containsKey(Object key)
          Tests if the specified object is a key in this hashtable.
 boolean containsValue(Object value)
          Returns true if this Hashtable maps one or more keys to this value.
 void echoAllProperties()
          list all Property sets to stderr
 void echoStatus()
          send current status to stderr
 Enumeration elements()
          Returns an enumeration of the values in this hashtable.
 Set entrySet()
          Returns a Set view of the entries contained in this Hashtable.
 boolean equals(Object o)
          Compares the specified Object with this Map for equality, as per the definition in the Map interface.
private  void expire()
          remove the association between any dead threads and their serviceNames.
private  IEProperties.PropertyAssociation findAssociation(String serviceName)
          find an association to serviceName
 String findCurrentServiceName()
          used to resolve the current service name even if the currently running thread isn't registered.
private  Properties findProperties(String serviceName)
          utility method used to search for a property set
private  IEProperties.ThreadRegistration findRegistration(Thread t)
          find a reference to a Thread's registration or null.
 void firePropertiesChange()
          notifiy all listeners for the current thread's properties that the properties have changed.
private  void firePropertiesChange(Properties props)
          notify all listeners on a specific set of properties that they have changed.
 void firePropertiesChange(String serviceName)
          notifiy all listeners for a specific service's properties that the properties have changed.
 Object get(Object key)
          Returns the value to which the specified key is mapped in this hashtable.
 String getCurrentServiceName()
          get the serviceName associated with the currently running thread name returned may actually be name of a parent Thread.
 String getGlobalServiceName()
          gets the globalServiceName
 String getParentServiceName()
          return serviceName of parent thread or null if either no parent Thread or no registered parent Thread.
 Properties getProperties()
          get the properties associated with the currently running thread
 Properties getProperties(String serviceName)
          get the properties associated with a specific serviceName
 String getProperty(String key)
          return the property value associated with key or null
 String getProperty(String key, String defaultValue)
          return the property value associated with key or defaultValue
private  String getPropertyMap(String serviceName, String key)
           
 String getPropertySource()
          return the property source associated with the currently running thread
 String getPropertySource(String serviceName)
          return the property source associated with a serviceName
 Vector getRegisteredServiceNames()
          return a list of registered serviceNames
 Object getStaticObjectReference(Object key)
          return a static object references specific to the currently running thread.
 int hashCode()
          Returns the hash code value for this Map as per the definition in the Map interface.
 void initializeProperties()
          set Properties for currently running thread to an empty Properties object
 void initializeProperties(String serviceName)
          set Properties for serviceName to an empty Properties object
 boolean isEmpty()
          Tests if this hashtable maps no keys to values.
 Enumeration keys()
          Returns an enumeration of the keys in this hashtable.
 Set keySet()
          Returns a Set view of the keys contained in this Hashtable.
 void list(PrintStream out)
          Prints this property list out to the specified output stream.
 void list(PrintWriter out)
          Prints this property list out to the specified output stream.
 void load(InputStream inStream)
          Reads a property list (key and element pairs) from the input stream.
private static void preload()
          preload all infoengine classes IEProperties uses to avoid issues with iPlanet's classloader
 Enumeration propertyNames()
          Returns an enumeration of all the keys in this property list, including the keys in the default property list.
 Object put(Object key, Object value)
          Maps the specified key to the specified value in this hashtable.
 void putAll(Map t)
          Copies all of the mappings from the specified Map to this Hashtable These mappings will replace any mappings that this Hashtable had for any of the keys currently in the specified Map.
 void registerPropertyListener(PropertyListener listener)
          Adds a listener to the list that's notified each time this thread's properties change.
 void registerThread(String serviceName)
          associate the currently running thread with a serviceName.
 void reloadProperties(String serviceName)
          re-initialized and re-load properties within the same method to avoid access to properties between the re-ininitialization and re-loading.
 Object remove(Object key)
          Removes the key (and its corresponding value) from this hashtable.
 Object removeStaticObjectReference(Object key)
          remove a static object reference specific to the currently running Thread.
 void resetProperties()
          re-load the properties for the currently running thread
 void resetProperties(String serviceName)
          re-load the properties for serviceName
private  void resetProperties(String serviceName, String resource, Properties props)
          re-load properties for serviceName from resource
private  void restoreProperties(String serviceName, Properties saved)
           
 void save(OutputStream out, String header)
          Deprecated.  
 void setGlobalServiceName(String globalServiceName)
          sets the globalServiceName this allows a service's properties to be served up when a thread is not already registered (allows for backward compatibility for 6.0 tag extension and 5.x use:bean JSPs)
 void setProperties(Properties props)
          set Properties object for currently running thread.
 void setProperties(String serviceName, Properties props)
          set Properties object for serviceName if props is null Properties object is removed.
 Object setProperty(String key, String value)
          return previous property value associated with key
 void setPropertySource(String source)
          associate the serviceName associated with the currently running thread with its property source.
 void setPropertySource(String serviceName, String source)
          associate a serviceName with a property source.
 Object setStaticObjectReference(Object key, Object object)
          set a static object reference specific to the currently running thread
 int size()
          Returns the number of keys in this hashtable.
 String status()
          return a string representation of the current status of the IEProperties object.
 void store(OutputStream out, String header)
          Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the load method.
 boolean threadRegistered()
          determines whether or not the current thread is registered
 String toString()
          Returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters ", " (comma and space).
 void unregisterPropertyListener(PropertyListener listener)
          Removes a listener from the list that's notified each time this thread's properties change.
 void unregisterThread()
          remove the association between the currently running thread and a serviceName.
 Collection values()
          Returns a Collection view of the values contained in this Hashtable.
 
Methods inherited from class java.util.Properties
 
Methods inherited from class java.util.Hashtable
rehash
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

propertySources

private Hashtable propertySources

globalPropertySource

private String globalPropertySource

properties

private Hashtable properties

defaults

private Properties defaults

globalServiceName

private String globalServiceName

globalCreationTime

private long globalCreationTime

globalTimeToLive

private long globalTimeToLive

registeredThreads

private Vector registeredThreads

associations

private Vector associations

globalPropertyListeners

private Vector globalPropertyListeners

localStaticObjects

private Hashtable localStaticObjects

globalStaticObjects

private Hashtable globalStaticObjects

propertyNameMap

private static final String[] propertyNameMap

propertyNamePrefixes

private static final String[] propertyNamePrefixes
Constructor Detail

IEProperties

public IEProperties()
create an empty set of IEProperties


IEProperties

public IEProperties(Properties defaults)
create a set of IEProperties with defaults

Method Detail

preload

private static void preload()
preload all infoengine classes IEProperties uses to avoid issues with iPlanet's classloader


getProperty

public String getProperty(String key)
return the property value associated with key or null

Returns:
String property value or null

getProperty

public String getProperty(String key,
                          String defaultValue)
return the property value associated with key or defaultValue

Returns:
String property value or defaultValue

getPropertyMap

private String getPropertyMap(String serviceName,
                              String key)

setProperty

public Object setProperty(String key,
                          String value)
return previous property value associated with key

Returns:
previous property value or null

list

public void list(PrintStream out)
Prints this property list out to the specified output stream.


list

public void list(PrintWriter out)
Prints this property list out to the specified output stream.


load

public void load(InputStream inStream)
          throws IOException
Reads a property list (key and element pairs) from the input stream.

Throws:
IOException

propertyNames

public Enumeration propertyNames()
Returns an enumeration of all the keys in this property list, including the keys in the default property list.


store

public void store(OutputStream out,
                  String header)
           throws IOException
Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the load method.

Throws:
IOException

save

public void save(OutputStream out,
                 String header)
Deprecated.  

Deprecated. This method does not throw an IOException if an I/O error occurs while saving the property list. As of the Java 2 platform v1.2, the preferred way to save a properties list is via the store(OutputStream out, String header) method.


clear

public void clear()
Clears this hashtable so that it contains no keys.


clone

public Object clone()
Creates a shallow copy of this hashtable.


contains

public boolean contains(Object value)
Tests if some key maps into the specified value in this hashtable.


containsKey

public boolean containsKey(Object key)
Tests if the specified object is a key in this hashtable.


containsValue

public boolean containsValue(Object value)
Returns true if this Hashtable maps one or more keys to this value.


elements

public Enumeration elements()
Returns an enumeration of the values in this hashtable.


entrySet

public Set entrySet()
Returns a Set view of the entries contained in this Hashtable.


equals

public boolean equals(Object o)
Compares the specified Object with this Map for equality, as per the definition in the Map interface.


get

public Object get(Object key)
Returns the value to which the specified key is mapped in this hashtable.


hashCode

public int hashCode()
Returns the hash code value for this Map as per the definition in the Map interface.


isEmpty

public boolean isEmpty()
Tests if this hashtable maps no keys to values.


keys

public Enumeration keys()
Returns an enumeration of the keys in this hashtable.


keySet

public Set keySet()
Returns a Set view of the keys contained in this Hashtable.


put

public Object put(Object key,
                  Object value)
Maps the specified key to the specified value in this hashtable.


putAll

public void putAll(Map t)
Copies all of the mappings from the specified Map to this Hashtable These mappings will replace any mappings that this Hashtable had for any of the keys currently in the specified Map.


remove

public Object remove(Object key)
Removes the key (and its corresponding value) from this hashtable.


size

public int size()
Returns the number of keys in this hashtable.


toString

public String toString()
Returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters ", " (comma and space).


values

public Collection values()
Returns a Collection view of the values contained in this Hashtable.


setGlobalServiceName

public void setGlobalServiceName(String globalServiceName)
sets the globalServiceName this allows a service's properties to be served up when a thread is not already registered (allows for backward compatibility for 6.0 tag extension and 5.x use:bean JSPs)

Parameters:
globalServiceName -

getGlobalServiceName

public String getGlobalServiceName()
gets the globalServiceName

Returns:
String globalServiceName or null if not set

initializeProperties

public void initializeProperties()
set Properties for currently running thread to an empty Properties object


initializeProperties

public void initializeProperties(String serviceName)
set Properties for serviceName to an empty Properties object

Parameters:
serviceName - - name of service to initialize properties for

setProperties

public void setProperties(Properties props)
set Properties object for currently running thread. if props is null Properties object is removed.

Parameters:
props - - the new Properties object

setProperties

public void setProperties(String serviceName,
                          Properties props)
set Properties object for serviceName if props is null Properties object is removed.

Parameters:
serviceName - - the serviceName for new Properties object
props - - the new Properties object

findRegistration

private IEProperties.ThreadRegistration findRegistration(Thread t)
find a reference to a Thread's registration or null.

Parameters:
t - - Thread to search for
Returns:
ThreadRegistration

getParentServiceName

public String getParentServiceName()
return serviceName of parent thread or null if either no parent Thread or no registered parent Thread.

Returns:
parent serviceName or null

findCurrentServiceName

public String findCurrentServiceName()
used to resolve the current service name even if the currently running thread isn't registered.


getCurrentServiceName

public String getCurrentServiceName()
get the serviceName associated with the currently running thread name returned may actually be name of a parent Thread.

Returns:
a serviceName or null

findAssociation

private IEProperties.PropertyAssociation findAssociation(String serviceName)
find an association to serviceName

Returns:
PropertyAssociation

associate

public void associate(String parent,
                      String child)
associate service1 with service2. used to tie a child service to a parent service so the child can access the parent's properties and objects under its own name.

Parameters:
parent - - name of the parent service
child - - name of the child service

getProperties

public Properties getProperties()
get the properties associated with the currently running thread

Returns:
properties if found or null

findProperties

private Properties findProperties(String serviceName)
utility method used to search for a property set

Parameters:
serviceName - - service associated with a property set

getProperties

public Properties getProperties(String serviceName)
get the properties associated with a specific serviceName

Parameters:
serviceName -
Returns:
properties if found or null

registerThread

public void registerThread(String serviceName)
associate the currently running thread with a serviceName.

Parameters:
serviceName - the serviceName to associate with this thread

_registerThread

private void _registerThread(String serviceName)
add a thread to the list of registered threads

Parameters:
serviceName - - the serviceName to tie the thread to

threadRegistered

public boolean threadRegistered()
determines whether or not the current thread is registered

Returns:
true if registered false otherwise

unregisterThread

public void unregisterThread()
remove the association between the currently running thread and a serviceName.


setPropertySource

public void setPropertySource(String source)
associate the serviceName associated with the currently running thread with its property source.

Parameters:
source - the property source for the properties associated with this thread.

setPropertySource

public void setPropertySource(String serviceName,
                              String source)
associate a serviceName with a property source.

Parameters:
serviceName -
source -

getPropertySource

public String getPropertySource(String serviceName)
return the property source associated with a serviceName

Parameters:
serviceName -
Returns:
the property source or null

getPropertySource

public String getPropertySource()
return the property source associated with the currently running thread

Returns:
the property source or null

expire

private void expire()
remove the association between any dead threads and their serviceNames.


reloadProperties

public void reloadProperties(String serviceName)
                      throws IOException
re-initialized and re-load properties within the same method to avoid access to properties between the re-ininitialization and re-loading. intended for use by Reload-Properties ADMIN webject

Parameters:
serviceName - - name of service
Throws:
IOException

resetProperties

public void resetProperties()
                     throws IOException
re-load the properties for the currently running thread

Throws:
IOException

resetProperties

public void resetProperties(String serviceName)
                     throws IOException
re-load the properties for serviceName

Parameters:
serviceName -
Throws:
IOException

resetProperties

private void resetProperties(String serviceName,
                             String resource,
                             Properties props)
                      throws IOException
re-load properties for serviceName from resource

Parameters:
serviceName - - name of the service
resource - - property source
props - - Property set if null reseting global properties
Throws:
IOException

firePropertiesChange

public void firePropertiesChange(String serviceName)
notifiy all listeners for a specific service's properties that the properties have changed.

Parameters:
serviceName - - the service name who's properties have changed

firePropertiesChange

public void firePropertiesChange()
notifiy all listeners for the current thread's properties that the properties have changed.


firePropertiesChange

private void firePropertiesChange(Properties props)
notify all listeners on a specific set of properties that they have changed.

Parameters:
props - - the properties that have changed

getRegisteredServiceNames

public Vector getRegisteredServiceNames()
return a list of registered serviceNames

Returns:
Vector - list of String serviceNames or null if none

setStaticObjectReference

public Object setStaticObjectReference(Object key,
                                       Object object)
set a static object reference specific to the currently running thread

Parameters:
key - - key to store object under
object - - object to store
Returns:
previous Object stored under key or null if no previous object reference

getStaticObjectReference

public Object getStaticObjectReference(Object key)
return a static object references specific to the currently running thread.

Parameters:
key - - key used to look up the object
Returns:
Object reference or null

removeStaticObjectReference

public Object removeStaticObjectReference(Object key)
remove a static object reference specific to the currently running Thread.

Parameters:
key - - the key used to look up the object to remove
Returns:
the object reference previously stored under this key or null

registerPropertyListener

public void registerPropertyListener(PropertyListener listener)
Adds a listener to the list that's notified each time this thread's properties change.

Parameters:
listener - - the PropertyListener to register
See Also:
unregisterPropertyListener()

unregisterPropertyListener

public void unregisterPropertyListener(PropertyListener listener)
Removes a listener from the list that's notified each time this thread's properties change.

Parameters:
listener - - the PropertyListener to register
See Also:
unregisterPropertyListener()

backUpProperties

private Properties backUpProperties(Properties old)

restoreProperties

private void restoreProperties(String serviceName,
                               Properties saved)

status

public String status()
return a string representation of the current status of the IEProperties object.

Returns:
String

echoStatus

public void echoStatus()
send current status to stderr


echoAllProperties

public void echoAllProperties()
list all Property sets to stderr