com.ibm.websphere.command

Class TargetPolicyDefault

  1. java.lang.Object
  2. extended bycom.ibm.websphere.command.TargetPolicyDefault
All implemented interfaces:
TargetPolicy, java.io.Serializable

  1. public class TargetPolicyDefault
  2. extends java.lang.Object
  3. 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 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.

  1. If the command contains a target object, use it.
  2. If the command contains a name for a target, use it.
  3. If there is a mapping registered on the TargetPolicyDefault object between the command and a target, use it.
  4. If there is a default target name defined on the TargetPolicyDefault object, use it.
  5. Return null if no target can be found.

The class sets the default target name to the LocalTarget class.

See Also:
Serialized Form

Field Summary

Modifier and Type Field and Description
  1. protected
  2. CommandTarget
defaultTarget
The default target object, used if no other target is found.
  1. protected
  2. java.lang.String
defaultTargetName
The default target name, used if no other target is found.
  1. protected
  2. java.util.Dictionary
mapping
Contains the registered mappings between commands and targets.
  1. protected
  2. java.util.Hashtable
targetTable
Contains active targets.

Constructor Summary

Constructor and Description
TargetPolicyDefault()

Method Summary

Modifier and Type Method and Description
  1. CommandTarget
getCommandTarget(TargetableCommand command)
The getCommandTarget() method implements the method in the TargetPolicy interface.
  1. java.util.Dictionary
listMappings()
Lists all the command-to-target mappings.
  1. void
registerCommand(java.lang.String commandBeanName,java.lang.String targetBeanName)
Registers a single command-to-target mapping.
  1. void
setDefaultTargetName(java.lang.String defaultTargetName)
Sets the default target name, used if no other target is found.
  1. void
unregisterCommand(java.lang.String commandBeanName)
Unregisters a single command-to-target mapping.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

mapping

  1. protected java.util.Dictionary mapping
Contains the registered mappings between commands and targets. The key is the name of the command; the value is the name of the target.

targetTable

  1. protected java.util.Hashtable targetTable
Contains active targets. The key is the name of the target; the value is the target object.

defaultTargetName

  1. protected java.lang.String defaultTargetName
The default target name, used if no other target is found.

defaultTarget

  1. protected transient CommandTarget defaultTarget
The default target object, used if no other target is found.

Constructor Detail

TargetPolicyDefault

  1. public TargetPolicyDefault()

Method Detail

getCommandTarget

  1. public 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.
  1. If the command contains a target object, use it.
  2. If the command contains a name for a target, use it.
  3. If there is a mapping registered on the TargetPolicyDefault object between the command and a target, use it.
  4. If there is a default target name defined on the TargetPolicyDefault object, use it.
  5. Return null if no target can be found.

Specified by:
Parameters:
command - The TargetableCommand whose CommandTarget is needed.
Returns:
The CommandTarget for the command.

listMappings

  1. public 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.

registerCommand

  1. public void registerCommand(java.lang.String commandBeanName,
  2. java.lang.String targetBeanName)
Registers a single command-to-target mapping.
Parameters:
commandBeanName - The name of the command.
targetBeanName - The name of the target.

setDefaultTargetName

  1. public 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.

unregisterCommand

  1. public void unregisterCommand(java.lang.String commandBeanName)
Unregisters a single command-to-target mapping.
Parameters:
commandBeanName - The name of the command.