public class CommandServiceDirectory extends CommandMBean implements CommandServiceDirectoryMBean, NotificationListener
CommandService MBean services for all
subsystems. In effect, it provides a service that allows a client to determine what MBean service provides support
and can execute a particular type of command.
Each set of command services are organized into separate subsystems. A command service belongs to a subsystem if,
in its ObjectName, it has the subsystem key property specified. If it does
not specify that key property in its name, it is considered in the unnamed, anonymous subsystem.
This directory service is used by the CommandProcessor invocation handler to help determine where to
direct a command request for processing.
This directory is part of the mechanism by which command services can be dynamically added/updated/removed. This service will listen for command services getting deployed and undeployed to/from the MBeanServer and will dynamically update itself accordingly.
| Constructor and Description |
|---|
CommandServiceDirectory()
Creates a new
CommandServiceDirectory object. |
| Modifier and Type | Method and Description |
|---|---|
CommandServiceDirectoryEntry[] |
getAllEntries()
This will return all the entries for all subsystems - in other words, all the supported command types and the
command services that provide them in all subsystems.
|
boolean |
getAllowDynamicDiscovery()
This attribute will indicate if new commands are allowed to be added dynamically at runtime.
|
CommandServiceDirectoryEntry |
getCommandTypeProvider(String subsystem,
CommandType commandType)
Finds the provider of the given command type by looking it up in the directory in a thread-safe way.
|
CommandServiceDirectoryEntry[] |
getSubsystemEntries(String subsystem)
Given a subsystem, this will return all the entries for that subsystem - in other words, all the supported
command types and the command services that provide them.
|
void |
handleNotification(Notification notification,
Object handback)
As command services are deployed and undeployed, this notification handler will detect this and update the
directory accordingly.
|
ObjectName |
preRegister(MBeanServer mbs,
ObjectName name)
Verifies that the
ObjectName of this directory MBean has the appropriate key properties and
initializes the directory with an inventory of the current set of supported command types/command services. |
void |
setAllowDynamicDiscovery(boolean flag)
This attribute will indicate if new commands are allowed to be added dynamically at runtime.
|
void |
startService()
Clears the directory of all entries then takes an inventory of existing command services and adds them to the
directory.
|
void |
stopService()
Clean up any resources that were initialized during start.
|
getLog, getMBeanServer, getObjectName, postDeregister, postRegister, preDeregisterpublic CommandServiceDirectory()
CommandServiceDirectory object.public ObjectName preRegister(MBeanServer mbs, ObjectName name) throws Exception
ObjectName of this directory MBean has the appropriate key properties and
initializes the directory with an inventory of the current set of supported command types/command services.preRegister in interface MBeanRegistrationpreRegister in class CommandMBeanExceptionMBeanRegistration.preRegister(MBeanServer, ObjectName)public void startService()
startService in class CommandMBeanRuntimeExceptionpublic void stopService()
stopService in class CommandMBeanpublic void handleNotification(Notification notification, Object handback)
This method ensures thread-safety during its modifications to the directory data structures.
If the directory is not allowed to perform dynamic discovery, this method
does nothing; the notification is ignored.
handleNotification in interface NotificationListenerNotificationListener.handleNotification(Notification, Object)public CommandServiceDirectoryEntry getCommandTypeProvider(String subsystem, CommandType commandType)
getCommandTypeProvider in interface CommandServiceDirectoryMBeansubsystem - the subsystem to look in (may be null)commandType - find a provider for this command typenull if no provider existsCommandServiceDirectoryMBean.getCommandTypeProvider(String, CommandType)public CommandServiceDirectoryEntry[] getSubsystemEntries(String subsystem)
CommandServiceDirectoryMBeanIf no command service providers exists for the given subsystem, an empty array is returned.
subsystem may be null to denote the unnamed, anonymous subsystem.
getSubsystemEntries in interface CommandServiceDirectoryMBeansubsystem - the subsystem to look in (may be null)CommandServiceDirectoryMBean.getSubsystemEntries(String)public CommandServiceDirectoryEntry[] getAllEntries()
CommandServiceDirectoryMBeanIf no command service providers exists, an empty array is returned.
getAllEntries in interface CommandServiceDirectoryMBeanCommandServiceDirectoryMBean.getAllEntries()public void setAllowDynamicDiscovery(boolean flag)
CommandServiceDirectoryMBean
false, only those command services currently installed at the time of this directory's registration will
be found in the directory. If true, the directory will add new command services to the directory as
they come online.
Note that this has no effect on dynamically discovering the removal of command services. The directory will always detect the removal of commands and remove their entries from the directory.
setAllowDynamicDiscovery in interface CommandServiceDirectoryMBeanflag - true will allow the directory to discovery changes during runtime. false
means only those command services already in existence at the time the directory service is
registered will be stored in the directory.CommandServiceDirectoryMBean.setAllowDynamicDiscovery(boolean)public boolean getAllowDynamicDiscovery()
CommandServiceDirectoryMBean
false, only those command services currently installed at the time of this directory's registration will
be found in the directory. If true, the directory will add new command services to the directory as
they come online.
Note that this has no effect on dynamically discovering the removal of command services. The directory will always detect the removal of commands and remove their entries from the directory.
getAllowDynamicDiscovery in interface CommandServiceDirectoryMBeantrue will allow the directory to discovery changes during runtime. false means
only those command services already in existence at the time the directory service is registered will be
stored in the directory.CommandServiceDirectoryMBean.getAllowDynamicDiscovery()Copyright © 2008-2013 Red Hat, Inc.. All Rights Reserved.