org.apache.geronimo.kernel.basic
Class BasicDependencyManager

java.lang.Object
  extended byorg.apache.geronimo.kernel.basic.BasicDependencyManager
All Implemented Interfaces:
DependencyManager

public class BasicDependencyManager
extends java.lang.Object
implements DependencyManager

DependencyManager is the record keeper of the dependencies in Geronimo. The DependencyManager does not enforce any dependencies, it is simply a place where components can register their intent to be dependent on another component. Since a JMX Component can pretty much do whatever it wants a component must watch the components it depends on to assure that they are following the J2EE-Management state machine.

The DependencyManager uses the nomenclature of parent-child where a child is dependent on a parent. The names parent and child have no other meaning are just a convience to make the code readable.

Version:
$Rev: 124822 $ $Date: 2005-01-10 11:01:13 -0800 (Mon, 10 Jan 2005) $

Nested Class Summary
private  class BasicDependencyManager.DependencyManagerLifecycleListener
           
 
Field Summary
private  java.util.Map childToParentMap
          A map from child names to a list of parents.
private  LifecycleListener lifecycleListener
          Listenes for GBeans to unregister and removes all dependencies associated with the dependency
private  LifecycleMonitor lifecycleMonitor
          The lifecycleMonitor informs us when gbeans go off line, so we can clean up the lingering dependencies.
private  java.util.Map parentToChildMap
          A map from parent back to a list of its children.
private  java.util.Map startHoldsMap
          A map from a component's ObjectName to the list of ObjectPatterns that the component is blocking from starting.
 
Constructor Summary
BasicDependencyManager(LifecycleMonitor lifecycleMonitor)
           
 
Method Summary
 void addDependencies(javax.management.ObjectName child, java.util.Set parents)
          Adds dependencies from the child to every parent in the parents set
 void addDependency(javax.management.ObjectName child, javax.management.ObjectName parent)
          Declares a dependency from a child to a parent.
 void addStartHolds(javax.management.ObjectName objectName, java.util.Collection holds)
          Adds a hold on a collection of object name patterns.
 javax.management.ObjectName checkBlocker(javax.management.ObjectName objectName)
          Gets the object name of the mbean blocking the start specified mbean.
 void close()
          Closes the dependency manager releasing all resources
 java.util.Set getChildren(javax.management.ObjectName parent)
          Gets all of the MBeans that have a dependency on the specified startParent.
 java.util.Set getParents(javax.management.ObjectName child)
          Gets the set of parents that the child is depending on
 void removeAllDependencies(javax.management.ObjectName child)
          Removes all dependencies for a child
 void removeAllStartHolds(javax.management.ObjectName objectName)
          Removes all of the holds owned by a component.
 void removeDependency(javax.management.ObjectName child, javax.management.ObjectName parent)
          Removes a dependency from a child to a parent
 void removeStartHolds(javax.management.ObjectName objectName, java.util.Collection holds)
          Removes a collection of holds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lifecycleMonitor

private final LifecycleMonitor lifecycleMonitor
The lifecycleMonitor informs us when gbeans go off line, so we can clean up the lingering dependencies.


lifecycleListener

private final LifecycleListener lifecycleListener
Listenes for GBeans to unregister and removes all dependencies associated with the dependency


childToParentMap

private final java.util.Map childToParentMap
A map from child names to a list of parents.


parentToChildMap

private final java.util.Map parentToChildMap
A map from parent back to a list of its children.


startHoldsMap

private final java.util.Map startHoldsMap
A map from a component's ObjectName to the list of ObjectPatterns that the component is blocking from starting.

Constructor Detail

BasicDependencyManager

public BasicDependencyManager(LifecycleMonitor lifecycleMonitor)
                       throws java.lang.Exception
Method Detail

close

public void close()
Description copied from interface: DependencyManager
Closes the dependency manager releasing all resources

Specified by:
close in interface DependencyManager

addDependency

public void addDependency(javax.management.ObjectName child,
                          javax.management.ObjectName parent)
Declares a dependency from a child to a parent.

Specified by:
addDependency in interface DependencyManager
Parameters:
child - the dependent component
parent - the component the child is depending on

removeDependency

public void removeDependency(javax.management.ObjectName child,
                             javax.management.ObjectName parent)
Removes a dependency from a child to a parent

Specified by:
removeDependency in interface DependencyManager
Parameters:
child - the dependnet component
parent - the component that the child wil no longer depend on

removeAllDependencies

public void removeAllDependencies(javax.management.ObjectName child)
Removes all dependencies for a child

Specified by:
removeAllDependencies in interface DependencyManager
Parameters:
child - the component that will no longer depend on anything

addDependencies

public void addDependencies(javax.management.ObjectName child,
                            java.util.Set parents)
Adds dependencies from the child to every parent in the parents set

Specified by:
addDependencies in interface DependencyManager
Parameters:
child - the dependent component
parents - the set of components the child is depending on

getParents

public java.util.Set getParents(javax.management.ObjectName child)
Gets the set of parents that the child is depending on

Specified by:
getParents in interface DependencyManager
Parameters:
child - the dependent component
Returns:
a collection containing all of the components the child depends on; will never be null

getChildren

public java.util.Set getChildren(javax.management.ObjectName parent)
Gets all of the MBeans that have a dependency on the specified startParent.

Specified by:
getChildren in interface DependencyManager
Parameters:
parent - the component the returned childen set depend on
Returns:
a collection containing all of the components that depend on the parent; will never be null

addStartHolds

public void addStartHolds(javax.management.ObjectName objectName,
                          java.util.Collection holds)
Adds a hold on a collection of object name patterns. If the name of a component matches an object name pattern in the collection, the component should not start.

Specified by:
addStartHolds in interface DependencyManager
Parameters:
objectName - the name of the component placing the holds
holds - a collection of object name patterns which should not start

removeStartHolds

public void removeStartHolds(javax.management.ObjectName objectName,
                             java.util.Collection holds)
Removes a collection of holds.

Specified by:
removeStartHolds in interface DependencyManager
Parameters:
objectName - the object name of the components owning the holds
holds - a collection of the holds to remove

removeAllStartHolds

public void removeAllStartHolds(javax.management.ObjectName objectName)
Removes all of the holds owned by a component.

Specified by:
removeAllStartHolds in interface DependencyManager
Parameters:
objectName - the object name of the component that will no longer have any holds

checkBlocker

public javax.management.ObjectName checkBlocker(javax.management.ObjectName objectName)
Gets the object name of the mbean blocking the start specified mbean.

Specified by:
checkBlocker in interface DependencyManager
Parameters:
objectName - the mbean to check for blockers
Returns:
the mbean blocking the specified mbean, or null if there are no blockers


Copyright © 2005 Apache Software Foundation. All Rights Reserved.