Package com.ibm.websphere.command
Class TargetPolicyDefault
- java.lang.Object
- 
- com.ibm.websphere.command.TargetPolicyDefault
 
- 
- All Implemented Interfaces:
- TargetPolicy,- java.io.Serializable
 
 public class TargetPolicyDefault extends java.lang.Object implements TargetPolicy, java.io.Serializable The TargetPolicyDefault class provides an implementation of the TargetPolicy interface. It provides serveral way to specify the target for a command, and it implements an evaluation routine for retrieving the target in its implementation of the getCommandTarget() method.The TargetPolicyDefault class allows a client to set the target of a command in several ways: - The target can be set directly on the command by using the setCommandTarget() method in the TargetableCommand interface.
- The name of the target can be set directly on the command by using the setCommandTargetName() method on the TargetableCommand interface.
- A command can be mapped to a target using the local registerCommand() method. The TargetPolicyDefault class also provides methods for managing these mappings.
- A default target can be established by using the local setDefaultTargetName() method.
 The getCommandTarget() method implements the following ordered steps for determining the target that to be returned for a given command. The getCommandTarget() method stops when it finds a target. - If the command contains a target object, use it.
- If the command contains a name for a target, use it.
- If there is a mapping registered on the TargetPolicyDefault object between the command and a target, use it.
- If there is a default target name defined on the TargetPolicyDefault object, use it.
- Return null if no target can be found.
 The class sets the default target name to the LocalTarget class. - See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description TargetPolicyDefault()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandTargetgetCommandTarget(TargetableCommand command)The getCommandTarget() method implements the method in the TargetPolicy interface.java.util.DictionarylistMappings()Lists all the command-to-target mappings.voidregisterCommand(java.lang.String commandBeanName, java.lang.String targetBeanName)Registers a single command-to-target mapping.voidsetDefaultTargetName(java.lang.String defaultTargetName)Sets the default target name, used if no other target is found.voidunregisterCommand(java.lang.String commandBeanName)Unregisters a single command-to-target mapping.
 
- 
- 
- 
Method Detail- 
getCommandTargetpublic CommandTarget getCommandTarget(TargetableCommand command) The getCommandTarget() method implements the method in the TargetPolicy interface. This implementation uses the following ordered steps for determining the target that to be returned for a given command. It stops when it finds a target.- If the command contains a target object, use it.
- If the command contains a name for a target, use it.
- If there is a mapping registered on the TargetPolicyDefault object between the command and a target, use it.
- If there is a default target name defined on the TargetPolicyDefault object, use it.
- Return null if no target can be found.
 - Specified by:
- getCommandTargetin interface- TargetPolicy
- Parameters:
- command- The TargetableCommand whose CommandTarget is needed.
- Returns:
- The CommandTarget for the command.
 
 - 
listMappingspublic java.util.Dictionary listMappings() Lists all the command-to-target mappings.- Returns:
- A Dictionary of mappings between command names and target names. The key is the name of the command; the value is the name of the target.
 
 - 
registerCommandpublic void registerCommand(java.lang.String commandBeanName, java.lang.String targetBeanName)Registers a single command-to-target mapping.- Parameters:
- commandBeanName- The name of the command.
- targetBeanName- The name of the target.
 
 - 
setDefaultTargetNamepublic void setDefaultTargetName(java.lang.String defaultTargetName) Sets the default target name, used if no other target is found. This implementation uses the LocalTarget class as the default target name.- Parameters:
- defaultTargetName- The name of the default target.
 
 - 
unregisterCommandpublic void unregisterCommand(java.lang.String commandBeanName) Unregisters a single command-to-target mapping.- Parameters:
- commandBeanName- The name of the command.
 
 
- 
 
-