Returns the flag to indicate if when a notification is received for the
unregistration of an MBean referenced in a relation, if an immediate
"purge" of the relations (look for the relations no longer valid)
has to be performed , or if that will be performed only when the
purgeRelations method will be explicitly called.

Sets the flag to indicate if when a notification is received for the
unregistration of an MBean referenced in a relation, if an immediate
"purge" of the relations (look for the relations no longer valid)
has to be performed , or if that will be performed only when the
purgeRelations method will be explicitly called.

Constructor Detail

RelationService

public RelationService(boolean immediatePurgeFlag)

Constructor.

Parameters:

immediatePurgeFlag - flag to indicate when a notification is
received for the unregistration of an MBean referenced in a relation, if
an immediate "purge" of the relations (look for the relations no
longer valid) has to be performed , or if that will be performed only
when the purgeRelations method will be explicitly called.

preRegister

Allows the MBean to perform any operations it needs before
being registered in the MBean Server. If the name of the MBean
is not specified, the MBean can provide a name for its
registration. If any exception is raised, the MBean will not be
registered in the MBean Server.

name - The object name of the MBean. This name is null if
the name parameter to one of the createMBean or
registerMBean methods in the MBeanServer
interface is null. In that case, this method must return a
non-null ObjectName for the new MBean.

Returns:

The name under which the MBean is to be registered.
This value must not be null. If the name
parameter is not null, it will usually but not necessarily be
the returned value.

postRegister

Allows the MBean to perform any operations needed after having been
registered in the MBean server or after the registration has failed.

If the implementation of this method throws a RuntimeException
or an Error, the MBean Server will rethrow those inside
a RuntimeMBeanException or RuntimeErrorException,
respectively. However, throwing an exception in postRegister
will not change the state of the MBean:
if the MBean was already registered (registrationDone is
true), the MBean will remain registered.

This might be confusing for the code calling createMBean()
or registerMBean(), as such code might assume that MBean
registration has failed when such an exception is raised.
Therefore it is recommended that implementations of
postRegister do not throw Runtime Exceptions or Errors if it
can be avoided.

postDeregister

Allows the MBean to perform any operations needed after having been
unregistered in the MBean server.

If the implementation of this method throws a RuntimeException
or an Error, the MBean Server will rethrow those inside
a RuntimeMBeanException or RuntimeErrorException,
respectively. However, throwing an exception in postDeregister
will not change the state of the MBean:
the MBean was already successfully deregistered and will remain so.

This might be confusing for the code calling
unregisterMBean(), as it might assume that MBean deregistration
has failed. Therefore it is recommended that implementations of
postDeregister do not throw Runtime Exceptions or Errors if it
can be avoided.

getPurgeFlag

public boolean getPurgeFlag()

Returns the flag to indicate if when a notification is received for the
unregistration of an MBean referenced in a relation, if an immediate
"purge" of the relations (look for the relations no longer valid)
has to be performed , or if that will be performed only when the
purgeRelations method will be explicitly called.

setPurgeFlag

public void setPurgeFlag(boolean purgeFlag)

Sets the flag to indicate if when a notification is received for the
unregistration of an MBean referenced in a relation, if an immediate
"purge" of the relations (look for the relations no longer valid)
has to be performed , or if that will be performed only when the
purgeRelations method will be explicitly called.

purgeRelations

Depending on the purgeFlag value, this method is either called
automatically when a notification is received for the unregistration of
an MBean referenced in a relation (if the flag is set to true), or not
(if the flag is set to false).

In that case it is up to the user to call it to maintain the
consistency of the relations. To be kept in mind that if an MBean is
unregistered and the purge not done immediately, if the ObjectName is
reused and assigned to another MBean referenced in a relation, calling
manually this purgeRelations() method will cause trouble, as will
consider the ObjectName as corresponding to the unregistered MBean, not
seeing the new one.

The behavior depends on the cardinality of the role where the
unregistered MBean is referenced:

- if removing one MBean reference in the role makes its number of
references less than the minimum degree, the relation has to be removed.

- if the remaining number of references after removing the MBean
reference is still in the cardinality range, keep the relation and
update it calling its handleMBeanUnregistration() callback.

relationTypeName - can be null; if specified, only the relations
of that type will be considered in the search. Else all relation types
are considered.

roleName - can be null; if specified, only the relations
where the MBean is referenced in that role will be returned. Else all
roles are considered.

Returns:

an HashMap, where the keys are the relation ids of the relations
where the MBean is referenced, and the value is, for each key,
an ArrayList of role names (as an MBean can be referenced in several
roles in the same relation).

relationTypeName - can be null; if specified, only the relations
of that type will be considered in the search. Else all
relation types are considered.

roleName - can be null; if specified, only the relations
where the MBean is referenced in that role will be considered. Else all
roles are considered.

Returns:

an HashMap, where the keys are the ObjectNames of the MBeans
associated to given MBean, and the value is, for each key, an ArrayList
of the relation ids of the relations where the key MBean is
associated to given one (as they can be associated in several different
relations).