com.sun.jaw.impl.agent.services.persistent
Class PersistentPropertySrv

java.lang.Object
  |
  +--com.sun.jaw.impl.agent.services.persistent.PersistentPropertySrv

public class PersistentPropertySrv
extends java.lang.Object
implements java.io.Serializable

This class provides a simple implementation of persistent m-bean properties.

The service analyzes an m-bean for information on all its read/write properties. The values of these properties are either extracted from the m-bean and saved in a text file (property file) or extracted from a property file and set in the m-bean. Non-null property values are saved in a property file using the following format: [Property name]=[Property value].

The properties of an m-bean must adhere to the following rules:

The following simple types are supported: NOTE: The service does not support simple or primitive array types.

See Also:
Properties, PropertyDescriptor, java.beans.Introspector, Serialized Form

Field Summary
protected  Framework cmf
          Reference to the Framework.
 
Constructor Summary
PersistentPropertySrv()
          Default constructor.
 
Method Summary
protected  java.util.Properties allocateProperties(java.lang.Object object)
          Allocates the m-bean's properties and populates a Properties object with the infromation.
protected  void applyProperties(java.util.Properties prpty, java.lang.Object object)
          Allocates the m-bean's properties and sets the properties as defined by the Properties object.
 void initCmf(Framework cmf, ObjectName name, boolean db, ModificationList list)
          For JDMK internal use only.
 void loadProperties(java.lang.Object object, java.lang.String file)
          Loads and sets object properties from a property file.
protected  java.util.Properties loadPropertyFile(java.lang.String file)
          Loads the properties from the specified file and populates a Properties object with the information.
 void performLoadProperties(ObjectName name, java.lang.String file)
          Loads and sets m-bean properties from a property file.
 void performSaveProperties(ObjectName name, java.lang.String file)
          Analyzes and saves m-bean properties to a property file.
 void saveProperties(java.lang.Object object, java.lang.String file)
          Analyzes and saves object properties to a property file.
protected  void savePropertyFile(java.util.Properties prpty, java.lang.String file)
          Saves the Properties object to the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cmf

protected Framework cmf
Reference to the Framework.
Constructor Detail

PersistentPropertySrv

public PersistentPropertySrv()
Default constructor.
Method Detail

performSaveProperties

public void performSaveProperties(ObjectName name,
                                  java.lang.String file)
                           throws InstanceNotFoundException,
                                  java.io.IOException
Analyzes and saves m-bean properties to a property file.
Parameters:
name - The object name of the object to be analyzed for properties.
file - The property file to save the property values in.
Throws:
InstanceNotFoundException - The specified m-bean does not exist in the m-bean repository.
java.io.IOException - Signals that an I/O exception of some sort has occurred.

performLoadProperties

public void performLoadProperties(ObjectName name,
                                  java.lang.String file)
                           throws InstanceNotFoundException,
                                  java.io.IOException,
                                  java.io.FileNotFoundException
Loads and sets m-bean properties from a property file.
Parameters:
name - The object name of the object to be analyzed for properties.
file - The property file to load the property values from.
Throws:
InstanceNotFoundException - The specified m-bean does not exist in the m-bean repository.
java.io.IOException - Signals that an I/O exception of some sort has occurred.
java.io.FileNotFoundException - Signals that a file could not be found.

saveProperties

public void saveProperties(java.lang.Object object,
                           java.lang.String file)
                    throws java.io.IOException
Analyzes and saves object properties to a property file.
Parameters:
object - The object to be analyzed for properties.
file - The property file to save the property values in.
Throws:
java.io.IOException - Signals that an I/O exception of some sort has occurred.

loadProperties

public void loadProperties(java.lang.Object object,
                           java.lang.String file)
                    throws java.io.IOException,
                           java.io.FileNotFoundException
Loads and sets object properties from a property file.
Parameters:
object - The object to be analyzed for properties.
file - The property file to load the property values from.
Throws:
java.io.IOException - Signals that an I/O exception of some sort has occurred.
java.io.FileNotFoundException - Signals that a file could not be found.

initCmf

public void initCmf(Framework cmf,
                    ObjectName name,
                    boolean db,
                    ModificationList list)
             throws InstanceAlreadyExistException
For JDMK internal use only.

Initializes the persistent property service.

Parameters:
cmf - The core management framework to register the service with.
name - Object name.
db - Indicates if persistent storage is required.
list - The modification list to use for setting up parameters.
Throws:
InstanceAlreadyExistException - The m-bean is already registered in the repository.

allocateProperties

protected java.util.Properties allocateProperties(java.lang.Object object)
Allocates the m-bean's properties and populates a Properties object with the infromation.
Parameters:
object - The object to be analyzed for properties.
Returns:
A Properties object containing a list of properties and values.

applyProperties

protected void applyProperties(java.util.Properties prpty,
                               java.lang.Object object)
Allocates the m-bean's properties and sets the properties as defined by the Properties object.
Parameters:
prpty - The Properties object containing a list of properties and values.
object - The object to be set with the property values.

savePropertyFile

protected void savePropertyFile(java.util.Properties prpty,
                                java.lang.String file)
                         throws java.io.IOException
Saves the Properties object to the specified file.
Parameters:
prpty - The Properties object containing a list of properties and values.
file - The property file to save the property values in.
Throws:
java.io.IOException - Signals that an I/O exception of some sort has occurred.

loadPropertyFile

protected java.util.Properties loadPropertyFile(java.lang.String file)
                                         throws java.io.IOException,
                                                java.io.FileNotFoundException
Loads the properties from the specified file and populates a Properties object with the information.
Parameters:
file - The property file to load the property values from.
Returns:
A Properties object containing a list of properties and values.
Throws:
java.io.IOException - Signals that an I/O exception of some sort has occurred.
java.io.FileNotFoundException - Signals that a file could not be found.