edu.sdsc.inca.protocol
Class MessageHandlerFactory

java.lang.Object
  extended by edu.sdsc.inca.protocol.MessageHandlerFactory

public class MessageHandlerFactory
extends java.lang.Object

Author:
Cathie Olschanowsky This factory reads a protocol stream and instantiates MessageHandler classes. MessageHandler classes can be added using the addTask method.

Constructor Summary
MessageHandlerFactory()
           
 
Method Summary
static MessageHandler newInstance(ProtocolReader reader)
          Returns an instance of a MessageHandler based on the next command coming over a connection.
static void registerMessageHandler(java.lang.String command, java.lang.String handler)
          Add a task to the known list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageHandlerFactory

public MessageHandlerFactory()
Method Detail

newInstance

public static MessageHandler newInstance(ProtocolReader reader)
                                  throws java.lang.IllegalAccessException,
                                         java.lang.InstantiationException,
                                         java.io.IOException,
                                         ProtocolException
Returns an instance of a MessageHandler based on the next command coming over a connection. Returns null on end of stream.

Parameters:
reader - the reader from which the next command is read
Returns:
the Task Handler mapped to the next command.
Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException - Some problem instatiating the implemenation
java.io.IOException - Problem reader next command
ProtocolException - Bad data/unknown command in the input stream

registerMessageHandler

public static void registerMessageHandler(java.lang.String command,
                                          java.lang.String handler)
Add a task to the known list. Every server that uses this class will need to do this.

Parameters:
command - The Command as it will be seen in the protocol
handler - The handler that should be invoked upon this command