org.jboss.mx.persistence
Class ObjectStreamPersistenceManager

java.lang.Object
  extended byorg.jboss.mx.persistence.ObjectStreamPersistenceManager
All Implemented Interfaces:
PersistenceManager (src)

public class ObjectStreamPersistenceManager
extends java.lang.Object
implements PersistenceManager (src)

Object Stream Persistence Manager.

Persists the MBean to the file system using an Object Stream. Includes code based on examples in Juha's JMX Book.

Object Streams written to disk are admittedly lacking in the area of "long-term", "portable", or "human-readable" persistence. They are fairly straightforward, however. Primarily, this class is useful for demonstration and "quick & dirty" persistence.


Field Summary
protected  boolean isLoading
          A flag set to true to prevent attribute updates from within load triggering stores.
protected static Logger (src) log
           
 
Constructor Summary
ObjectStreamPersistenceManager()
           
 
Method Summary
protected  java.io.File getStoreFile(MBeanInfo (src)  metadata, boolean createFile)
           
protected  boolean isLoading()
           
 void load(ModelMBeanInvoker (src)  mbean, MBeanInfo (src)  metadata)
          deserializes state from the object input stream
protected  void loadFromMetadata(ModelMBeanInvoker (src)  mbean, ModelMBeanInfo (src)  metadata)
          Obtain the attribute values from the metadata and invoke setAttributes on the mbean invoker.
protected  void setIsLoading(boolean newIsLoading)
           
 void store(MBeanInfo (src)  metadata)
          What we need to get here is 1) the persist location, and 2) the entire contents of the mbean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Logger (src)  log

isLoading

protected boolean isLoading
A flag set to true to prevent attribute updates from within load triggering stores.

Constructor Detail

ObjectStreamPersistenceManager

public ObjectStreamPersistenceManager()
Method Detail

load

public void load(ModelMBeanInvoker (src)  mbean,
                 MBeanInfo (src)  metadata)
          throws MBeanException (src) 
deserializes state from the object input stream

Specified by:
load in interface PersistenceManager (src)
Parameters:
mbean -
metadata -
Throws:
MBeanException (src)

store

public void store(MBeanInfo (src)  metadata)
           throws MBeanException (src) 
What we need to get here is 1) the persist location, and 2) the entire contents of the mbean. #2 contains the entire contents (state) of the model object, as well as the meta data that the mbean provides. As such, serializing this (MBeanInfo) object (brute force) in effect serializes the model as well.

Specified by:
store in interface PersistenceManager (src)
Parameters:
metadata -
Throws:
MBeanException (src)

loadFromMetadata

protected void loadFromMetadata(ModelMBeanInvoker (src)  mbean,
                                ModelMBeanInfo (src)  metadata)
Obtain the attribute values from the metadata and invoke setAttributes on the mbean invoker.

Parameters:
mbean - the invoker and assocaited mbean resource
metadata - the metadata to use as the attributes value source

isLoading

protected boolean isLoading()

setIsLoading

protected void setIsLoading(boolean newIsLoading)

getStoreFile

protected java.io.File getStoreFile(MBeanInfo (src)  metadata,
                                    boolean createFile)
                             throws MBeanException (src) 
Throws:
MBeanException (src)