org.jmx4odp.dynamicManagement
Class PropertyReaderFactory

java.lang.Object
  extended by org.jmx4odp.dynamicManagement.PropertyReaderFactory

public final class PropertyReaderFactory
extends java.lang.Object

This object fetches PropertyReaders. If this object exists within the same JVM as a JMX agent, it will keep track of all PropertyReaders created by resource files and will make sure that there are only on instance per resource. So if five processes request a PropertyReader for resource X, they will all get the same property reader.

This Factory will also try to register itself with the local JMX agent.

The follow snippet will load the log4j.properies file out of the class path and create a PropertyReader object. The PropertyReader will be instrumented as an mbean. At this point, the properties will be stored in an in memory singleton tracked by the PropertyReaderFactory. To create PropertyReader objects:
PropertyReader pr = PropertyReaderFactory.getPropertyReader("log4j");

Author:
Lucas McGregor

Method Summary
static PropertyReader getPropertyReader(java.lang.Class classDef, java.util.HashMap map)
          Create a new property reader based upon this hash map.
static PropertyReader getPropertyReader(java.lang.Class classDef, java.lang.String resource)
          Get a propertyReader from a resource bundle.
static PropertyReader getPropertyReader(java.util.HashMap map)
          Create a new property reader based upon this hash map.
static PropertyReader getPropertyReader(java.lang.String resource)
          same as getpropertyReader(resource, true);
static PropertyReader getPropertyReader(java.lang.String resource, boolean keep)
          Get a propertyReader from a resource bundle.
static void initialize()
          If possible, create the hash cache for PropertyReaders and register itself as a MBean with the local JMX agent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initialize

public static void initialize()
If possible, create the hash cache for PropertyReaders and register itself as a MBean with the local JMX agent.


getPropertyReader

public static PropertyReader getPropertyReader(java.lang.String resource)
same as getpropertyReader(resource, true);


getPropertyReader

public static PropertyReader getPropertyReader(java.lang.String resource,
                                               boolean keep)
Get a propertyReader from a resource bundle. If possible, use the same reader per bundle.

Parameters:
resource, - name of resource bundle
keep, - true to keep reference to property reader, false to just create and let go

getPropertyReader

public static PropertyReader getPropertyReader(java.util.HashMap map)
Create a new property reader based upon this hash map. Each one will be unique


getPropertyReader

public static PropertyReader getPropertyReader(java.lang.Class classDef,
                                               java.lang.String resource)
                                        throws java.lang.Exception
Get a propertyReader from a resource bundle. If possible, use the same reader per bundle.

Throws:
exception - if it cannot instantiate the class
java.lang.Exception

getPropertyReader

public static PropertyReader getPropertyReader(java.lang.Class classDef,
                                               java.util.HashMap map)
                                        throws java.lang.Exception
Create a new property reader based upon this hash map. Each one will be unique

Throws:
exception - if it cannot instantiate the class
java.lang.Exception