Interface JESTCommand
- All Known Implementing Classes:
PropertiesCommand
public interface JESTCommand
Interface for JEST commands. A JEST command denotes a JPA operation such as
A qualifier qualifies the action to be performed. For example, a
An argument is an argument to the target JPA method. For example,
find
,
query
or domain
. Besides signifying a JPA operation, a command may have
zero or more qualifiers and arguments.
A qualifier qualifies the action to be performed. For example, a
query
command may be qualified
to return a single instance as its result, or limit its result to first 20 instances etc.
An argument is an argument to the target JPA method. For example,
find
command has
arguments for the type of the instance and the primary key. A query
command has the
query string as its argument.
A concrete command instance is an outcome of parsing a request
.
The path
segments are parsed for qualifiers.
The query string
is parsed for the arguments.
A JEST command often attaches special semantics to a standard URI syntax. For example, all JEST
URI enforces that the first segment of a servlet path denotes the command moniker e.g. the URI
http://www.jpa.com/jest/find/plan=myPlan?type=Person&1234
with context root http://www.jpa.com/jest
has the servlet path /find/plan=myPlan
and query string type=Person&1234
.
The first path segment find
will determine that the command is to find a
persistent entity of type Person
and primary key 1234
using a fetch plan
named myPlan
.
- Author:
- Pinaki Poddar
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetArgument
(String key) Get the value of this command's argument of the given name.Get this command's arguments.Get the execution context of this command.getQualifier
(String key) Get the value of this command's qualifier of the given name.Get this command's qualifiers.boolean
hasArgument
(String key) Affirm this command contains an argument of the given name.boolean
hasQualifier
(String key) Affirm this command contains an qualifier of the given name.void
parse()
Parse the given request to populate qualifiers and parameters of this command.void
process()
Process the given request and write the output on to the given response in the given context.
-
Method Details
-
getExecutionContext
JPAServletContext getExecutionContext()Get the execution context of this command.- Returns:
- the execution context. never null.
-
parse
Parse the given request to populate qualifiers and parameters of this command. A command can interpret and consume certain path segments or parameters of the original request. Duringprocessing
phase, the parameters and qualifiers are accessed from the parsed command itself rather than from the original HTTP request.- Throws:
ProcessingException
-
process
Process the given request and write the output on to the given response in the given context.- Throws:
ProcessingException
IOException
-
getArguments
Get this command's arguments.- Throws:
IllegalStateException
- if accessed prior to parsing.
-
getArgument
Get the value of this command's argument of the given name.- Returns:
- null if the argument does not exist.
- Throws:
IllegalStateException
- if accessed prior to parsing.
-
hasArgument
Affirm this command contains an argument of the given name.- Throws:
IllegalStateException
- if accessed prior to parsing.
-
getQualifiers
Get this command's qualifiers.- Throws:
IllegalStateException
- if accessed prior to parsing.
-
getQualifier
Get the value of this command's qualifier of the given name.- Returns:
- null if the qualifier does not exist.
- Throws:
IllegalStateException
- if accessed prior to parsing.
-
hasQualifier
Affirm this command contains an qualifier of the given name.- Throws:
IllegalStateException
- if accessed prior to parsing.
-