org.norther.tammi.core.rt
Class VariableTree

java.lang.Object
  extended by org.norther.tammi.core.base.Referable
      extended by org.norther.tammi.core.relation.Relation
          extended by org.norther.tammi.core.rt.VariableTree
All Implemented Interfaces:
Serializable, EventListener, MBeanRegistration, NotificationBroadcaster, NotificationEmitter, NotificationListener, Relation, RelationSupportMBean, Identifiable, MBeanDelegate, NamePattern, ReferableMBean, RelationMBean, VariableTreeMBean
Direct Known Subclasses:
VariableRoot

public class VariableTree
extends Relation
implements VariableTreeMBean, NotificationListener

A default implementation of VariableTreeMBean.

Author:
Ilkka Priha
See Also:
Serialized Form

Nested Class Summary
protected static class VariableTree.VariableTreeType
          The relation type of tree relations.
 
Field Summary
static String VARIABLE_TREE_NOTIF_DESCRIPTION
          The notification description.
static MBeanNotificationInfo[] VARIABLE_TREE_NOTIFICATONS
          Variable tree notifications.
static String VARIABLE_TREE_TYPE
          The variable tree type name.
 
Fields inherited from class org.norther.tammi.core.relation.Relation
RELATION_NOTIF_DESCRIPTION, RELATION_NOTIFICATIONS, roleUpdate
 
Fields inherited from class org.norther.tammi.core.base.Referable
ID_LENGTH, REFERABLE_ATTRIBUTES, REFERABLE_NOTIF_DESCRIPTION, REFERABLE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.rt.VariableTreeMBean
BEAN_TREE_RELATION, ROLE_BASE, ROLE_BRANCH, ROLE_LEAF
 
Fields inherited from interface org.norther.tammi.core.base.ReferableMBean
DEFAULT_ID, ID, MBEAN, MBEAN_DESCRIPTION, TYPE
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
  VariableTree()
          Constructs a new relation.
  VariableTree(String id)
          Constructs a new relation with a relation id.
  VariableTree(String id, RoleList roles)
          Constructs a new relation with a relation id and initial roles.
protected VariableTree(String id, String relTypeName, RoleList roles)
          Constructs a new relation with a relation id, initial roles and customized relation type.
 
Method Summary
 boolean addBranchName(ObjectName name)
          Adds a new branch.
 boolean addBranchNames(Collection names)
          Adds new branches.
 boolean addLeafName(ObjectName name)
          Adds a new leaf.
 boolean addLeafNames(Collection names)
          Adds new leaves.
 boolean clearBranchNames()
          Clears all branches.
 boolean clearLeafNames()
          Clears all leaves.
 boolean containsBranchName(ObjectName name)
          Checks whether there is a specific branch.
 boolean containsLeafName(ObjectName name)
          Checks whether there is a specific leaf.
 Variable getBase()
          Gets the referent of the base MBean.
 ObjectName getBaseName()
          Gets the object name of the base.
 VariableTreeMBean getBranch(ObjectName name)
          Gets the referent of the named branch MBean.
 List getBranches()
          Gets referents of branch MBeans.
 List getBranchNames()
          Gets object names of branches.
 Variable getLeaf(ObjectName name)
          Gets the reference of the named leaf MBean.
 List getLeafNames()
          Gets object names of leaves.
 List getLeaves()
          Gets referents of leaf MBeans.
 MBeanNotificationInfo[] getNotificationInfo()
           
protected static RelationType getVariableTreeType()
          Gets the tree relation type.
 void handleNotification(Notification notif, Object handback)
          A notification handler, which passes all notifications coming from the tree forward and maintains internal consistency of the tree.
 boolean hasListeners()
          Returns true for listeners if removed actors are to be unregistered as the removal is performed in sendNotification and we need to get all notifications independently on registered listeners.
 boolean isUnregisterRemovedActors()
          Gets the unregister removed actors option.
 void notifyVariableTree()
          Notifies the tree by sending a modification notification.
 void postRegister(Boolean done)
          Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.
 boolean removeBranchName(ObjectName name)
          Removes a branch.
 boolean removeBranchNames(Collection names)
          Removes branches.
 boolean removeLeafName(ObjectName name)
          Removes a leaf.
 boolean removeLeafNames(Collection names)
          Removes leaves.
 void sendNotification(Notification notif)
          Handles unregistration of removed actors after sending the corresponding notifications.
 void setBaseName(ObjectName name)
          Sets the base.
 void setRelationServiceManagementFlag(Boolean theFlg)
          Removes and optionally unregisters all actors if the relation is removed from the relation service.
protected  Object setRoleWithStatus(Role theRole, ObjectName added, ObjectName removed, boolean update, boolean forced)
          Maintains the tree.
 void setUnregisterRemovedActors(boolean flag)
          Sets the unregister removed actors option.
protected  void unregisterRemovedActors(String roleName, Collection removed)
          Unregisters removed actors.
 
Methods inherited from class org.norther.tammi.core.relation.Relation
addActorName, addActorName, addActorNames, addToService, clearRole, getActor, getActor, getActor, getActorName, getActorName, getAllRoles, getReferencedMBeans, getRelationId, getRelationService, getRelationServiceName, getRelationTypeName, getRole, getRoleActors, getRoleCardinality, getRoleDirect, getRoles, getRoleWithStatus, handleMBeanUnregistration, isActorInDirectRole, isInRelationService, isNamedActorInRole, postDeregister, preDeregister, preRegister, removeActorName, removeActorName, removeActorNames, removeFromService, retrieveAllRoles, retrieveRole, roleCollection, setActorName, setActorName, setRelationId, setRelationTypeName, setRole, setRoleDirect, setRoles
 
Methods inherited from class org.norther.tammi.core.base.Referable
addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNamePattern, getObjectName, getQueryPattern, getRegistrationTime, getSequenceNumber, getUniqueName, isUnregistered, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, setCanonicalName, setMBeanServer, setNamePattern, setObjectName, setQueryPattern, unregister, unregistered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.relation.RelationMBean
addActorName, addActorName, addActorNames, addToService, clearRole, getActor, getActor, getActor, getActorName, getActorName, getRelationService, getRoleActors, isNamedActorInRole, removeActorName, removeActorName, removeActorNames, removeFromService, retrieveRole, setActorName, setActorName
 
Methods inherited from interface javax.management.relation.RelationSupportMBean
isInRelationService
 
Methods inherited from interface javax.management.relation.Relation
getAllRoles, getReferencedMBeans, getRelationId, getRelationServiceName, getRelationTypeName, getRole, getRoleCardinality, getRoles, handleMBeanUnregistration, retrieveAllRoles, setRole, setRoles
 
Methods inherited from interface org.norther.tammi.core.base.ReferableMBean
getMBean
 

Field Detail

VARIABLE_TREE_TYPE

public static final String VARIABLE_TREE_TYPE
The variable tree type name.

See Also:
Constant Field Values

VARIABLE_TREE_NOTIF_DESCRIPTION

public static final String VARIABLE_TREE_NOTIF_DESCRIPTION
The notification description.

See Also:
Constant Field Values

VARIABLE_TREE_NOTIFICATONS

public static final MBeanNotificationInfo[] VARIABLE_TREE_NOTIFICATONS
Variable tree notifications.

Constructor Detail

VariableTree

public VariableTree()
Constructs a new relation.


VariableTree

public VariableTree(String id)
Constructs a new relation with a relation id.

Parameters:
id - the relation id.

VariableTree

public VariableTree(String id,
                    RoleList roles)
Constructs a new relation with a relation id and initial roles.

Parameters:
id - the relation id.
roles - an optional role list for initializing the relation.

VariableTree

protected VariableTree(String id,
                       String relTypeName,
                       RoleList roles)
Constructs a new relation with a relation id, initial roles and customized relation type. The type must be consistent with the tree relation type.

Parameters:
id - the relation id.
relTypeName - the customized relation type name.
roles - an optional role list for initializing the relation.
Method Detail

getVariableTreeType

protected static RelationType getVariableTreeType()
Gets the tree relation type.

Returns:
the tree relation type.

postRegister

public void postRegister(Boolean done)
Description copied from class: Referable
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.

Specified by:
postRegister in interface MBeanRegistration
Overrides:
postRegister in class Relation
Parameters:
done - indicates whether or not the MBean has been registered.

setRelationServiceManagementFlag

public void setRelationServiceManagementFlag(Boolean theFlg)
Removes and optionally unregisters all actors if the relation is removed from the relation service.

Specified by:
setRelationServiceManagementFlag in interface RelationSupportMBean
Overrides:
setRelationServiceManagementFlag in class Relation
Parameters:
theFlg - the flag.

getBaseName

public ObjectName getBaseName()
Description copied from interface: VariableTreeMBean
Gets the object name of the base.

Specified by:
getBaseName in interface VariableTreeMBean
Returns:
the object name of the base or null.

getBase

public Variable getBase()
Description copied from interface: VariableTreeMBean
Gets the referent of the base MBean.

Specified by:
getBase in interface VariableTreeMBean
Returns:
the referent of the base MBean or null.

setBaseName

public void setBaseName(ObjectName name)
                 throws LogException
Description copied from interface: VariableTreeMBean
Sets the base.

Note that the base can be set only once the relation is included in the relation service.

Specified by:
setBaseName in interface VariableTreeMBean
Parameters:
name - the object name of the base.
Throws:
LogException - on errors.

getLeaf

public Variable getLeaf(ObjectName name)
Description copied from interface: VariableTreeMBean
Gets the reference of the named leaf MBean.

Specified by:
getLeaf in interface VariableTreeMBean
Parameters:
name - the name of the leaf.
Returns:
the referent of the leaf MBean or null.

getLeafNames

public List getLeafNames()
Description copied from interface: VariableTreeMBean
Gets object names of leaves.

Specified by:
getLeafNames in interface VariableTreeMBean
Returns:
a list of object names of leaves.

getLeaves

public List getLeaves()
Description copied from interface: VariableTreeMBean
Gets referents of leaf MBeans.

Specified by:
getLeaves in interface VariableTreeMBean
Returns:
a list of referents of leaf MBeans.

addLeafName

public boolean addLeafName(ObjectName name)
                    throws LogException
Description copied from interface: VariableTreeMBean
Adds a new leaf.

Specified by:
addLeafName in interface VariableTreeMBean
Parameters:
name - the object name of the leaf.
Returns:
true if added, otherwise false.
Throws:
LogException - on errors.

addLeafNames

public boolean addLeafNames(Collection names)
                     throws LogException
Description copied from interface: VariableTreeMBean
Adds new leaves.

Specified by:
addLeafNames in interface VariableTreeMBean
Parameters:
names - a collection of object names.
Returns:
true if added, otherwise false.
Throws:
LogException - on errors.

removeLeafName

public boolean removeLeafName(ObjectName name)
Description copied from interface: VariableTreeMBean
Removes a leaf.

Specified by:
removeLeafName in interface VariableTreeMBean
Parameters:
name - the object name of the leaf.
Returns:
true if removed, otherwie false.

removeLeafNames

public boolean removeLeafNames(Collection names)
Description copied from interface: VariableTreeMBean
Removes leaves.

Specified by:
removeLeafNames in interface VariableTreeMBean
Parameters:
names - a collection of object names.
Returns:
true if removed, otherwise false.

containsLeafName

public boolean containsLeafName(ObjectName name)
Description copied from interface: VariableTreeMBean
Checks whether there is a specific leaf.

Specified by:
containsLeafName in interface VariableTreeMBean
Parameters:
name - the object name of the leaf.
Returns:
true if the leaf exists, otherwise false.

clearLeafNames

public boolean clearLeafNames()
Description copied from interface: VariableTreeMBean
Clears all leaves.

Specified by:
clearLeafNames in interface VariableTreeMBean
Returns:
true if clearing was succesful.

getBranch

public VariableTreeMBean getBranch(ObjectName name)
Description copied from interface: VariableTreeMBean
Gets the referent of the named branch MBean.

Specified by:
getBranch in interface VariableTreeMBean
Parameters:
name - the name of the branch.
Returns:
the referent of the branch MBean or null.

getBranchNames

public List getBranchNames()
Description copied from interface: VariableTreeMBean
Gets object names of branches.

Specified by:
getBranchNames in interface VariableTreeMBean
Returns:
a list of object names of branches.

getBranches

public List getBranches()
Description copied from interface: VariableTreeMBean
Gets referents of branch MBeans.

Specified by:
getBranches in interface VariableTreeMBean
Returns:
a list of referents of branch MBeans.

addBranchName

public boolean addBranchName(ObjectName name)
                      throws LogException
Description copied from interface: VariableTreeMBean
Adds a new branch. The branch must be registered, included in the relation service and contain a valid base.

Specified by:
addBranchName in interface VariableTreeMBean
Parameters:
name - the object name of the branch.
Returns:
true if added, otherwise false.
Throws:
LogException - on errors.

addBranchNames

public boolean addBranchNames(Collection names)
                       throws LogException
Description copied from interface: VariableTreeMBean
Adds new branches. The branches must be registered, included in the relation service and contain a valid base.

Specified by:
addBranchNames in interface VariableTreeMBean
Parameters:
names - a collection of object names.
Returns:
true if added, otherwise false.
Throws:
LogException - on errors.

removeBranchName

public boolean removeBranchName(ObjectName name)
Description copied from interface: VariableTreeMBean
Removes a branch.

Specified by:
removeBranchName in interface VariableTreeMBean
Parameters:
name - the object name of the branch.
Returns:
true if removed, otherwise false.

removeBranchNames

public boolean removeBranchNames(Collection names)
Description copied from interface: VariableTreeMBean
Removes branches.

Specified by:
removeBranchNames in interface VariableTreeMBean
Parameters:
names - a collection of object names.
Returns:
true if removed, otherwise false.

containsBranchName

public boolean containsBranchName(ObjectName name)
Description copied from interface: VariableTreeMBean
Checks whether there is a specific branch.

Specified by:
containsBranchName in interface VariableTreeMBean
Parameters:
name - the object name of the branch.
Returns:
true if the branch exists, otherwise false.

clearBranchNames

public boolean clearBranchNames()
Description copied from interface: VariableTreeMBean
Clears all branches.

Specified by:
clearBranchNames in interface VariableTreeMBean
Returns:
true if clearing was succesful.

isUnregisterRemovedActors

public boolean isUnregisterRemovedActors()
Description copied from interface: VariableTreeMBean
Gets the unregister removed actors option.

Specified by:
isUnregisterRemovedActors in interface VariableTreeMBean
Returns:
true if removed leaves and branches should be unregistered.

setUnregisterRemovedActors

public void setUnregisterRemovedActors(boolean flag)
Description copied from interface: VariableTreeMBean
Sets the unregister removed actors option.

Specified by:
setUnregisterRemovedActors in interface VariableTreeMBean
Parameters:
flag - the option value to set.

notifyVariableTree

public void notifyVariableTree()
Description copied from interface: VariableTreeMBean
Notifies the tree by sending a modification notification.

Specified by:
notifyVariableTree in interface VariableTreeMBean

sendNotification

public void sendNotification(Notification notif)
Handles unregistration of removed actors after sending the corresponding notifications. We must receive all removal notications to maintain consistency.

Specified by:
sendNotification in interface MBeanDelegate
Overrides:
sendNotification in class Referable
Parameters:
notif - the notification.

hasListeners

public boolean hasListeners()
Returns true for listeners if removed actors are to be unregistered as the removal is performed in sendNotification and we need to get all notifications independently on registered listeners.

Specified by:
hasListeners in interface MBeanDelegate
Overrides:
hasListeners in class Referable
Returns:
true if notications can be send, otherwise false.

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
Specified by:
getNotificationInfo in interface NotificationBroadcaster
Overrides:
getNotificationInfo in class Relation

handleNotification

public void handleNotification(Notification notif,
                               Object handback)
A notification handler, which passes all notifications coming from the tree forward and maintains internal consistency of the tree.

Specified by:
handleNotification in interface NotificationListener
Overrides:
handleNotification in class Relation
Parameters:
notif - the notification.
handback - a hand-back object.

setRoleWithStatus

protected Object setRoleWithStatus(Role theRole,
                                   ObjectName added,
                                   ObjectName removed,
                                   boolean update,
                                   boolean forced)
                            throws RoleNotFoundException,
                                   InvalidRoleValueException,
                                   RelationNotFoundException,
                                   RelationTypeNotFoundException,
                                   RelationServiceNotRegisteredException
Maintains the tree.

Overrides:
setRoleWithStatus in class Relation
Parameters:
theRole - the role to be set.
added - an optional added actor.
removed - an optional removed actor.
update - a flag to update configurable actors.
forced - a flag for forced writing without a check.
Returns:
the new role or the status of the operation.
Throws:
RoleNotFoundException - if there is no role with the given name.
InvalidRoleValueException - if the value provided for the role is not valid.
RelationNotFoundException - if the relation has not been added in the service.
RelationTypeNotFoundException - if the relation type has not been declared.
RelationServiceNotRegisteredException - if the service is not registered.

unregisterRemovedActors

protected void unregisterRemovedActors(String roleName,
                                       Collection removed)
Unregisters removed actors.

Parameters:
roleName - the role name.
removed - a collection of removed actors.


Copyright © 2004 The Norther Organization. All rights reserved.