|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CommandRegistry
A registry for command objects.
The commands to be placed in the registry must have non-null identifiers available via their
AbstractCommand.getId()
method, and this id is expected to be unique amongst all the
commands in the application. Generally speaking, this uniqueness will not be enforced by the
framework but will instead allow commands to be overwritten by others with the same id.
Implementations may allow for the creation of hierarchical registries whereby a registry may have a parent registry. In this case, if a registry does not contain a requested command it will delegate to its parent to find the command. Commands in a child registry will override commands with the same ID in any ancestor registries.
Method Summary | |
---|---|
void |
addCommandRegistryListener(CommandRegistryListener listener)
Adds the given listener to the colleciton of listeners that will be notified of registry events. |
boolean |
containsActionCommand(String commandId)
Deprecated. Replaced by isTypeMatch(String, Class) |
boolean |
containsCommand(String commandId)
Returns true if the registry contains a command with the given identifier. |
boolean |
containsCommandGroup(String groupId)
Deprecated. Replaced by isTypeMatch(String, Class) |
ActionCommand |
getActionCommand(String commandId)
Deprecated. use getCommand(String, Class) instead. You may choose to either catch
the CommandNotOfRequiredTypeException or call isTypeMatch(String, Class) first. |
Object |
getCommand(String commandId)
Retrieves from the registry the command with the given identifier. |
Object |
getCommand(String commandId,
Class requiredType)
Retrieves from the registry the command with the given identifier. |
CommandGroup |
getCommandGroup(String groupId)
Deprecated. use getCommand(String, Class) instead. You may choose to either catch
the CommandNotOfRequiredTypeException or call isTypeMatch(String, Class) first. |
Class |
getType(String commandId)
Returns the type of the command with the given identifier, if it is contained in the registry. |
boolean |
isTypeMatch(String commandId,
Class targetType)
Returns true if the command with the given identifier is assignable to the given type. |
void |
registerCommand(AbstractCommand command)
Registers the given command with the registry. |
void |
removeCommandRegistryListener(CommandRegistryListener listener)
Remove the given listener from the collection of listeners that will be notified of registry events. |
void |
setTargetableActionCommandExecutor(String targetableCommandId,
ActionCommandExecutor commandExecutor)
Sets a command executor for the command with the given id. |
Method Detail |
---|
boolean containsCommand(String commandId)
commandId
- The ID of the command to search for.
IllegalArgumentException
- if commandId
is null.Object getCommand(String commandId)
commandId
- The ID of the command to be retrieved.
IllegalArgumentException
- if commandId
is null.Object getCommand(String commandId, Class requiredType) throws CommandNotOfRequiredTypeException
commandId
- The identifier of the command to be retrieved. Must not be null.requiredType
- The required type of the command with the given id.
CommandNotOfRequiredTypeException
- if the retrieved command is not assignable to
the required type.Class getType(String commandId)
commandId
- The ID of the command whose type is to be returned. Must not be null.
IllegalArgumentException
- if commandId
is null.boolean isTypeMatch(String commandId, Class targetType)
commandId
- The ID of the command whose type will be checked. Must not be null.targetType
- The type to be checked against the type of the command. Must not be null.
IllegalArgumentException
- if either argument is null.ActionCommand getActionCommand(String commandId)
getCommand(String, Class)
instead. You may choose to either catch
the CommandNotOfRequiredTypeException
or call isTypeMatch(String, Class)
first.
ActionCommand
that has the given id.
commandId
- The id of the action command to be returned.
IllegalArgumentException
- if commandId
is null.
CommandNotOfRequiredTypeException
- if there is a command with the given id in the
registry but it is not of type ActionCommand
.CommandGroup getCommandGroup(String groupId)
getCommand(String, Class)
instead. You may choose to either catch
the CommandNotOfRequiredTypeException
or call isTypeMatch(String, Class)
first.
CommandGroup
that has the given id.
groupId
- The id of the command group to be returned.
IllegalArgumentException
- if commandId
is null.
CommandNotOfRequiredTypeException
- if there is a command with the given id in the
registry but it is not of type CommandGroup
.boolean containsActionCommand(String commandId)
isTypeMatch(String, Class)
ActionCommand
with the
given id.
commandId
- The id of the command to be searched for.
ActionCommand
.boolean containsCommandGroup(String groupId)
isTypeMatch(String, Class)
CommandGroup
with the
given id.
groupId
- The id of the command group to be searched for.
CommandGroup
.void registerCommand(AbstractCommand command)
CommandRegistryListener.commandRegistered(CommandRegistryEvent)
method. If the
given command is an instance of CommandGroup
, its
CommandGroup.setCommandRegistry(CommandRegistry)
method must be called to set this
instance as the registry for the command group.
command
- The command to be registered. Must not be null.
IllegalArgumentException
- if command
is null or if its id is null.void setTargetableActionCommandExecutor(String targetableCommandId, ActionCommandExecutor commandExecutor)
TargetableActionCommand
.
targetableCommandId
- The id of the targetable command that will have its executor set.
Must not be null.commandExecutor
- The command executor. May be null.
IllegalArgumentException
- if targetableCommandId
is null.
CommandNotOfRequiredTypeException
- if the command with the given id is not a
TargetableActionCommand
.void addCommandRegistryListener(CommandRegistryListener listener)
listener
- The listener to be added. Must not be null.void removeCommandRegistryListener(CommandRegistryListener listener)
listener
- The listener to be removed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |