org.rhq.enterprise.communications.command.server
Class MultipleCommandService.CommandTypeExecutor

java.lang.Object
  extended by org.rhq.enterprise.communications.command.server.MultipleCommandService.CommandTypeExecutor
Enclosing class:
MultipleCommandService

protected class MultipleCommandService.CommandTypeExecutor
extends Object

An inner class used only by the MultipleCommandService that encasulates a supported command type and the executor that should be used to execute commands of that type. Note the two constructors - one takes a java.lang.Class and one an instance of CommandExecutor. If the java.lang.Class constructor is used, then for each command request that is issued to this command service, a new instance should be created to handle each command. If the CommandExecutor constructor is used, that means each command that comes in should be handed off to that specific instance. In that case, the executor instance must ensure thread-safety, since commands may come in concurrently.

Subclasses create instances of these objects and return them in MultipleCommandService.getSupportedCommandTypeExecutors().

Author:
John Mazzitelli

Field Summary
 Class m_executorClass
          the executor's class - this must implement CommandExecutor
 CommandType m_type
          the type of command this executor will handle
 
Constructor Summary
MultipleCommandService.CommandTypeExecutor(CommandType type, Class executorClass)
          Creates a new object that defines what class to instantiate for each new command to execute.
MultipleCommandService.CommandTypeExecutor(CommandType type, CommandExecutor executorInstance)
          Creates a new object that defines what executor instance to use to execute all commands of the given type.
 
Method Summary
 CommandExecutor getExecutor()
          Returns the executor instance that should be used to execute the next command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_type

public final CommandType m_type
the type of command this executor will handle


m_executorClass

public final Class m_executorClass
the executor's class - this must implement CommandExecutor

Constructor Detail

MultipleCommandService.CommandTypeExecutor

public MultipleCommandService.CommandTypeExecutor(CommandType type,
                                                  Class executorClass)
Creates a new object that defines what class to instantiate for each new command to execute. Each new instantiation of the given class will handle only a single command execution.

Parameters:
type - the type of command to be handed off to new instances of the given executor class
executorClass - class of the executor to instantiate when new commands are to be executed
Throws:
IllegalArgumentException - if the given class is an interface, an abstract class or not assignable to CommandExecutor; also if any parameter is null. Note that this is also thrown if the class is a MultipleCommandService object, since that would result in an infinite recursive loop.

MultipleCommandService.CommandTypeExecutor

public MultipleCommandService.CommandTypeExecutor(CommandType type,
                                                  CommandExecutor executorInstance)
Creates a new object that defines what executor instance to use to execute all commands of the given type. Because all commands will be handed off to the given executor instance, that instance must ensure thread-safety.

Parameters:
type - the type of command that will be handled by the given executor instance
executorInstance - the executor that will handle all commands of the given type
Throws:
IllegalArgumentException - if any parameter is null or if the instance is a MultipleCommandService object, since that would result in an infinite recursive loop.
Method Detail

getExecutor

public CommandExecutor getExecutor()
Returns the executor instance that should be used to execute the next command.

Returns:
command executor that should be used to execute the next command
Throws:
RuntimeException - failed to create the executor instance (should rarely, if ever, occur)


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.