Java Dynamic Management Kit 3.2 Programming Guide | ||||
---|---|---|---|---|
![]() | ![]() | Chapter 3. Design Patterns for Developing M-Beans | ![]() | ![]() |
Note - The methods for initializing and deleting an m-bean are not part of the JavaBeans component model, but are specific to the m-bean model.
The methods for initializing and deleting an m-bean are callbacks which the framework invokes. They are optional for an m-bean but if you want to provide them, you have to write them yourself. The methods are:
initCmf() - for initializing an m-bean. The framework invokes initCmf() when it is requested to register an instance of an m-bean that contains this method.
deleteCmf() - for preparing an m-bean for deletion. The framework invokes deleteCmf() when it is requested to delete an instance of an m-bean that contains this method.
The initCmf() method is invoked by the framework when it is requested to register an instance of an m-bean that contains this method.
The initCmf() method you define must have one of the following signatures:
public void initCmf(Framework cmf, ObjectName name) throws IllegalAccessException, ServiceNotFoundException, InstanceAlreadyExistException; |
public void initCmf(Framework cmf, ObjectName name, boolean persist, ModificationList list) throws IllegalAccessException, ServiceNotFoundException, InstanceAlreadyExistException; |
The parameters in the call to initCmf() are as follows:
cmf - the framework that the m-bean is to be registered with
name - the object name to be assigned to the m-bean
persist - true if persistent storage is required for the registered m-bean, false otherwise
list - additional information for registering the m-bean
The initCmf() method must include a call to one of these methods to register the m-bean:
addObject() for an m-bean instantiated by calling newObject()
addDBObject() for an m-bean instantiated by calling newDBObject()
Refer to Registering an Existing M-Bean in Chapter 4 for more information.
Defining an initCmf() method for an m-bean enables you to define actions to be carried out for the m-bean. For example, an m-bean could be implemented to:
Keep a reference to the framework that it is registered with.
Get information about its environment from the framework and to change its environment if necessary. For example, if the m-bean requires a service that is not present, it could request for that service to be created before registering itself.
Perform semantic checks on its object name before registering itself with the framework.
The services provided under com.sun.jaw.impl.agent.services contain an implementation of the initCmf() method.
The deleteCmf() method is invoked by the framework when it is requested to delete an instance of an m-bean that contains this method. This allows the m-bean to "clean-up" and free its resources before it is deleted.
The deleteCmf() method you define must have the following signature:
public void deleteCmf() |
The services provided under com.sun.jaw.impl.agent.services contain an implementation of the deleteCmf() method.
![]() | ![]() | ![]() |
Event Sources | ![]() | Actions |