public abstract class AbstractHttpCommandCodec extends java.lang.Object implements CommandCodec<HttpRequest>
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractHttpCommandCodec.CommandSpec |
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.String> |
aliases |
private BeanToJsonConverter |
beanToJsonConverter |
private JsonToBeanConverter |
jsonToBeanConverter |
private java.util.concurrent.ConcurrentHashMap<java.lang.String,AbstractHttpCommandCodec.CommandSpec> |
nameToSpec |
private static com.google.common.base.Splitter |
PATH_SPLITTER |
private static java.lang.String |
SESSION_ID_PARAM |
Constructor and Description |
---|
AbstractHttpCommandCodec() |
Modifier and Type | Method and Description |
---|---|
void |
alias(java.lang.String commandName,
java.lang.String isAnAliasFor)
Allow commands to have aliases.
|
protected abstract java.util.Map<java.lang.String,?> |
amendParameters(java.lang.String name,
java.util.Map<java.lang.String,?> parameters) |
private java.lang.String |
buildUri(java.lang.String commandName,
SessionId sessionId,
java.util.Map<java.lang.String,?> parameters,
AbstractHttpCommandCodec.CommandSpec spec) |
Command |
decode(HttpRequest encodedCommand)
Decodes a command.
|
protected void |
defineCommand(java.lang.String name,
AbstractHttpCommandCodec.CommandSpec spec) |
void |
defineCommand(java.lang.String name,
HttpMethod method,
java.lang.String pathPattern)
Defines a new command mapping.
|
protected static AbstractHttpCommandCodec.CommandSpec |
delete(java.lang.String path) |
HttpRequest |
encode(Command command)
Encodes a command.
|
protected static AbstractHttpCommandCodec.CommandSpec |
get(java.lang.String path) |
private java.lang.String |
getParameter(java.lang.String parameterName,
java.lang.String commandName,
SessionId sessionId,
java.util.Map<java.lang.String,?> parameters) |
protected static AbstractHttpCommandCodec.CommandSpec |
post(java.lang.String path) |
private static final com.google.common.base.Splitter PATH_SPLITTER
private static final java.lang.String SESSION_ID_PARAM
private final java.util.concurrent.ConcurrentHashMap<java.lang.String,AbstractHttpCommandCodec.CommandSpec> nameToSpec
private final java.util.Map<java.lang.String,java.lang.String> aliases
private final BeanToJsonConverter beanToJsonConverter
private final JsonToBeanConverter jsonToBeanConverter
public HttpRequest encode(Command command)
CommandCodec
encode
in interface CommandCodec<HttpRequest>
command
- the command to encode.protected abstract java.util.Map<java.lang.String,?> amendParameters(java.lang.String name, java.util.Map<java.lang.String,?> parameters)
public Command decode(HttpRequest encodedCommand)
CommandCodec
decode
in interface CommandCodec<HttpRequest>
encodedCommand
- the command to decode.public void defineCommand(java.lang.String name, HttpMethod method, java.lang.String pathPattern)
defineCommand
in interface CommandCodec<HttpRequest>
name
- The command name.method
- The HTTP method to use for the command.pathPattern
- The URI path pattern for the command. When encoding a command, each
path segment prefixed with a ":" will be replaced with the corresponding parameter
from the encoded command.public void alias(java.lang.String commandName, java.lang.String isAnAliasFor)
CommandCodec
alias
in interface CommandCodec<HttpRequest>
commandName
- The command being added.isAnAliasFor
- The command name that this is an alias for.protected void defineCommand(java.lang.String name, AbstractHttpCommandCodec.CommandSpec spec)
protected static AbstractHttpCommandCodec.CommandSpec delete(java.lang.String path)
protected static AbstractHttpCommandCodec.CommandSpec get(java.lang.String path)
protected static AbstractHttpCommandCodec.CommandSpec post(java.lang.String path)
private java.lang.String buildUri(java.lang.String commandName, SessionId sessionId, java.util.Map<java.lang.String,?> parameters, AbstractHttpCommandCodec.CommandSpec spec)
private java.lang.String getParameter(java.lang.String parameterName, java.lang.String commandName, SessionId sessionId, java.util.Map<java.lang.String,?> parameters)