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

java.lang.Object
  |
  +--com.sun.jaw.impl.agent.services.light.RepositorySrv
        |
        +--com.sun.jaw.impl.agent.services.persistent.PersistentRepSrv

public class PersistentRepSrv
extends RepositorySrv
implements MoRepSrvIf, com.sun.jaw.impl.agent.services.persistent.internal.ResolveLoaderIf

This class provides an implementation of a persistent repository. The repository contains a mixture of volatile and persistent m-beans. The repository stores volatile m-beans in memory. It stores persistent m-beans in a flat-file database. The framework should be the first object to register with the repository, enabling the synchronization of m-beans with the current framework. To enable framework synchronization the repository has to be a trusted class. i.e. It must be loaded by the premordial(system) classloader. Each persistent m-bean is stored as a serialized Java object. For each persistent m-bean, the repository stores:

The repository stores the object name of the class loader to enable it to locate the class loader when an agent deserializes the m-bean. To locate a class loader, the repository internally invokes these methods:

Note - Use the setConfig method to configure the repository before trying to register any m-beans with it.

See Also:
MoRepSrvIf, ObjectInputStream, ObjectOutputStream, Serializable, Externalizable, Serialized Form

Field Summary
protected  Framework cmf
          Reference to the Framework.
protected  java.lang.String domain
          The domain name of the server the repository is attached to.
 
Constructor Summary
PersistentRepSrv()
          Default constructor.
 
Method Summary
 boolean contains(java.lang.Object object)
          Verifies whether a singleton m-bean is registered with the repository.
 boolean contains(ObjectName name)
          Verifies whether an m-bean is registered with the repository.
protected  boolean containsDB(ObjectName name)
          Verifies whether an m-bean is in the database.
protected  void enableSync(Framework cmf)
          Enables the synhronization of m-beans with this framework.
protected  java.util.Vector getDBObject(ObjectName name, QueryExp query)
          Gets handles on m-beans in the database.
 java.lang.String getDomain()
          Gets the domain of the repository.
 java.lang.Integer getNbElements()
          Gets the number of m-beans registered with the repository.
 java.util.Vector getObject(ObjectName name, QueryExp query)
          Gets handles on m-beans controlled by the repository.
protected  boolean isFramework(java.lang.Object object)
          Tests if the object is an instance of a framework.
 boolean isPersistent()
          Indicates whether the repository offers persistent storage.
 boolean isQuerySrv()
          Indicates whether the repository supports filtering.
 void register(java.lang.Object object, ObjectName name)
          Invoked by the core management framework to register a volatile m-bean with the repository.
 void registerDB(java.lang.Object object, ObjectName name)
          Invoked by the core management framework to register a persistent m-bean with the repository.
 java.lang.ClassLoader resolveClassLoader(ObjectName aloader)
          Gets the class loader associated with an m-bean that is being deserialized.
 java.lang.Object retrieve(ObjectName name)
          Retrieves an m-bean from the repository.
 ObjectName retrieveClassLoaderName(java.lang.ClassLoader loader)
          Gets the object name of a class loader.
protected  java.lang.Object retrieveDB(ObjectName name)
          Retrieves an m-bean from the database.
 void setConfig(java.util.Vector params)
          Configures the repository and starts the database.
 void setDomain(java.lang.String domain)
          Sets the domain of the repository.
 void stop()
          Stop the repository and release allocated resources.
 void unregister(java.lang.Object object)
          Removes a singleton m-bean from the repository.
 void unregister(ObjectName name)
          Removes an m-bean from the repository.
protected  void unregisterDB(ObjectName name)
          Removes an m-bean from the database.
 void update(java.lang.Object object, ObjectName name)
          Updates an m-bean registered with the repository.
protected  void updateDB(java.lang.Object object, ObjectName name)
          Updates an m-bean in the database.
protected  boolean validateRegistration(ObjectName name)
          Validate the registration of a new m-bean.
 
Methods inherited from class com.sun.jaw.impl.agent.services.light.RepositorySrv
getClassVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

domain

protected java.lang.String domain
The domain name of the server the repository is attached to.

cmf

protected transient Framework cmf
Reference to the Framework.
Constructor Detail

PersistentRepSrv

public PersistentRepSrv()
Default constructor.
Method Detail

setConfig

public void setConfig(java.util.Vector params)
Configures the repository and starts the database.

The configuration parameters must be specified in the following order:

All parameters are String objects or null if not specified. If the parameter vector is empty or null, default values are used.

Specified by:
setConfig in interface MoRepSrvIf
Parameters:
params - A vector containing the configuration parameters of the repository.
Overrides:
setConfig in class RepositorySrv

isQuerySrv

public boolean isQuerySrv()
Indicates whether the repository supports filtering. If the repository does not support filtering, the core management framework will perform filtering for the repository.
Specified by:
isQuerySrv in interface MoRepSrvIf
Returns:
True if the filtering is supported, false otherwise.
Overrides:
isQuerySrv in class RepositorySrv

isPersistent

public boolean isPersistent()
Indicates whether the repository offers persistent storage.
Specified by:
isPersistent in interface MoRepSrvIf
Returns:
True if the repository offers persistent storage, false otherwise.
Overrides:
isPersistent in class RepositorySrv

contains

public boolean contains(ObjectName name)
Verifies whether an m-bean is registered with the repository.
Specified by:
contains in interface MoRepSrvIf
Parameters:
name - The object name of the m-bean.
Returns:
True if the m-bean is registered with the repository, false otherwise.
Overrides:
contains in class RepositorySrv

retrieve

public java.lang.Object retrieve(ObjectName name)
Retrieves an m-bean from the repository.
Specified by:
retrieve in interface MoRepSrvIf
Parameters:
name - The object name of the m-bean to be retrieved.
Returns:
The retrieved m-bean, or null if it could not be retrieved.
Overrides:
retrieve in class RepositorySrv

contains

public boolean contains(java.lang.Object object)
Verifies whether a singleton m-bean is registered with the repository. A singleton m-bean has no search key in its object name and is, therefore, the only instance of the class permitted in the domain.
Specified by:
contains in interface MoRepSrvIf
Parameters:
object - The m-bean.
Returns:
True if the m-bean is registered with the repository, false otherwise.
Overrides:
contains in class RepositorySrv

registerDB

public void registerDB(java.lang.Object object,
                       ObjectName name)
                throws InstanceAlreadyExistException
Invoked by the core management framework to register a persistent m-bean with the repository.
Specified by:
registerDB in interface MoRepSrvIf
Parameters:
object - The m-bean to be registered.
name - The object name with which the m-bean is to be registered.
Throws:
InstanceAlreadyExistException - The m-bean is already registered in the object repository.
Overrides:
registerDB in class RepositorySrv

register

public void register(java.lang.Object object,
                     ObjectName name)
              throws InstanceAlreadyExistException
Invoked by the core management framework to register a volatile m-bean with the repository.
Specified by:
register in interface MoRepSrvIf
Parameters:
object - The m-bean to be registered.
name - The object name with which the m-bean is to be registered.
Throws:
InstanceAlreadyExistException - The m-bean is already registered in the repository.
Overrides:
register in class RepositorySrv

update

public void update(java.lang.Object object,
                   ObjectName name)
            throws InstanceNotFoundException
Updates an m-bean registered with the repository.
Specified by:
update in interface MoRepSrvIf
Parameters:
object - The new instance of the m-bean.
name - The object name of the m-bean to be updated.
Throws:
InstanceNotFoundException - The specified m-bean was not found in the repository.
Overrides:
update in class RepositorySrv

unregister

public void unregister(ObjectName name)
                throws InstanceNotFoundException
Removes an m-bean from the repository.
Specified by:
unregister in interface MoRepSrvIf
Parameters:
name - The object name of the m-bean to be removed.
Throws:
InstanceNotFoundException - The specified m-bean was not found in the repository.
Overrides:
unregister in class RepositorySrv

unregister

public void unregister(java.lang.Object object)
                throws InstanceNotFoundException
Removes a singleton m-bean from the repository. A singleton m-bean has no search key in its object name and is, therefore, the only instance of the class permitted in the domain.
Specified by:
unregister in interface MoRepSrvIf
Parameters:
object - The m-bean to be removed from the repository.
Throws:
InstanceNotFoundException - The specified m-bean was not found in the repository.
Overrides:
unregister in class RepositorySrv

getObject

public java.util.Vector getObject(ObjectName name,
                                  QueryExp query)
Gets handles on m-beans controlled by the repository.
Specified by:
getObject in interface MoRepSrvIf
Parameters:
name - An object name that specifies the m-beans to be selected.
query - A query to be applied to the selected m-beans.
Returns:
A list of named objects corresponding to the selected m-beans.
Overrides:
getObject in class RepositorySrv

getNbElements

public java.lang.Integer getNbElements()
Gets the number of m-beans registered with the repository.
Specified by:
getNbElements in interface MoRepSrvIf
Returns:
The number of m-beans registered with the repository.
Overrides:
getNbElements in class RepositorySrv

getDomain

public java.lang.String getDomain()
Gets the domain of the repository.
Specified by:
getDomain in interface MoRepSrvIf
Returns:
The domain of the repository.
Overrides:
getDomain in class RepositorySrv

setDomain

public void setDomain(java.lang.String domain)
Sets the domain of the repository.
Specified by:
setDomain in interface MoRepSrvIf
Overrides:
setDomain in class RepositorySrv

resolveClassLoader

public java.lang.ClassLoader resolveClassLoader(ObjectName aloader)
Gets the class loader associated with an m-bean that is being deserialized. It is the class loader that loaded the m-bean when it was instantiated. The repository internally invokes this method when the m-bean is deserialized. The method searches the repository to find the class loader.
Specified by:
resolveClassLoader in interface com.sun.jaw.impl.agent.services.persistent.internal.ResolveLoaderIf
Parameters:
aloader - The object name of the class loader.
Returns:
The required class loader, or null if the class loader could not be retrieved.

retrieveClassLoaderName

public ObjectName retrieveClassLoaderName(java.lang.ClassLoader loader)
Gets the object name of a class loader. The repository internally invokes this method when an m-bean is deserialized. The method analyzes the specified loader to find the method getLoaderName with the following signature:

ObjectName getLoaderName()

The getLoaderName method found is invoked with no parameters and returns the object name of the class loader.

Parameters:
loader - The class loader.
Returns:
The object name of the class loader, or null if the object name could not be retrieved.

stop

public void stop()
Stop the repository and release allocated resources.

containsDB

protected boolean containsDB(ObjectName name)
Verifies whether an m-bean is in the database.
Parameters:
name - The object name of the m-bean.
Returns:
True if the m-bean is in the database, false otherwise.

retrieveDB

protected java.lang.Object retrieveDB(ObjectName name)
Retrieves an m-bean from the database.
Parameters:
name - The object name of the m-bean to be retrieved.
Returns:
The retrieved m-bean, or null if it could not be retrieved.

updateDB

protected void updateDB(java.lang.Object object,
                        ObjectName name)
                 throws InstanceNotFoundException
Updates an m-bean in the database.
Parameters:
object - The new instance of the m-bean.
name - The object name of the m-bean to be updated.
Throws:
InstanceNotFoundException - The specified m-bean was not found in the database.

unregisterDB

protected void unregisterDB(ObjectName name)
                     throws InstanceNotFoundException
Removes an m-bean from the database.
Parameters:
name - The object name of the m-bean to be removed.
Throws:
InstanceNotFoundException - The specified m-bean was not found in the database.

getDBObject

protected java.util.Vector getDBObject(ObjectName name,
                                       QueryExp query)
Gets handles on m-beans in the database.
Parameters:
name - An object name that specifies the m-beans to be selected.
query - A query to be applied to the selected m-beans.
Returns:
A list of named objects corresponding to the selected m-beans.

validateRegistration

protected boolean validateRegistration(ObjectName name)
Validate the registration of a new m-bean.
Parameters:
name - The object name of the m-bean to be registered. For a registration to be valid two things are checked: 1) If the m-bean is a singleton, no other m-beans of this class are registered. 2) If the m-bean is not a singleton, no singleton of this class is regitered.

isFramework

protected boolean isFramework(java.lang.Object object)
Tests if the object is an instance of a framework.
Parameters:
object - The object to be tested.
Returns:
True if the object is an instance of a framework, false otherwise.

enableSync

protected void enableSync(Framework cmf)
Enables the synhronization of m-beans with this framework.
Parameters:
cmf - The reference to the framework.