public class CommandDispatcher<Session extends ProtocolSession> extends Object implements ExtensibleHandler, LineHandler<Session>
CommandHandler
for a given CommandConstructor and Description |
---|
CommandDispatcher() |
CommandDispatcher(Collection<String> mandatoryCommands) |
Modifier and Type | Method and Description |
---|---|
protected void |
addToMap(String commandName,
CommandHandler<Session> cmdHandler)
Add it to map (key as command name, value is an array list of CommandHandlers)
|
protected Response |
dispatchCommandHandlers(Session session,
Request request)
Dispatch the
CommandHandler 's for the given Request and return a Response or null if non should get written
back to the client |
protected List<CommandHandler<Session>> |
getCommandHandlers(String command,
ProtocolSession session)
Returns all the configured CommandHandlers for the specified command
|
List<Class<?>> |
getMarkerInterfaces()
Return a List of interfaces of plugins that will
extend this.
|
protected String |
getUnknownCommandHandlerIdentifier()
Return the identifier to lookup the UnknownCmdHandler in the handler map
|
Response |
onLine(Session session,
ByteBuffer line)
Processing the give line.
|
protected Request |
parseRequest(Session session,
ByteBuffer buffer)
Parse the line into a
Request |
void |
wireExtensions(Class interfaceName,
List extension)
Method called during initialization after all the handlers have been declared
in the ProtocolHandlerChain.
|
public CommandDispatcher(Collection<String> mandatoryCommands)
public CommandDispatcher()
protected void addToMap(String commandName, CommandHandler<Session> cmdHandler)
commandName
- the command name which will be keycmdHandler
- The CommandHandler objectprotected List<CommandHandler<Session>> getCommandHandlers(String command, ProtocolSession session)
command
- the command name which will be keysession
- not nullpublic void wireExtensions(Class interfaceName, List extension) throws WiringException
ExtensibleHandler
wireExtensions
in interface ExtensibleHandler
extension
- a list of objects implementing the marker interfaceWiringException
ExtensibleHandler.wireExtensions(java.lang.Class, java.util.List)
public Response onLine(Session session, ByteBuffer line)
LineHandler
ProtocolSession.getLineDelimiter()
delimiter.onLine
in interface LineHandler<Session extends ProtocolSession>
session
- not nullprotected Response dispatchCommandHandlers(Session session, Request request)
CommandHandler
's for the given Request
and return a Response
or null
if non should get written
back to the clientsession
- request
- protected Request parseRequest(Session session, ByteBuffer buffer) throws Exception
Request
session
- line
- Exception
public List<Class<?>> getMarkerInterfaces()
ExtensibleHandler
getMarkerInterfaces
in interface ExtensibleHandler
ExtensibleHandler.getMarkerInterfaces()
protected String getUnknownCommandHandlerIdentifier()
Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.