Interface JESTCommand
-
- All Known Implementing Classes:
PropertiesCommand
public interface JESTCommandInterface for JEST commands. A JEST command denotes a JPA operation such asfind,queryordomain. 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, aquerycommand 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,findcommand has arguments for the type of the instance and the primary key. Aquerycommand has the query string as its argument.A concrete command instance is an outcome of parsing a
request. Thepathsegments are parsed for qualifiers. Thequery stringis 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 roothttp://www.jpa.com/jesthas the servlet path/find/plan=myPlanand query stringtype=Person&1234.
The first path segmentfindwill determine that the command is to find a persistent entity of typePersonand primary key1234using a fetch plan namedmyPlan.- Author:
- Pinaki Poddar
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classJESTCommand.FormatSupported format monikers.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringgetArgument(String key)Get the value of this command's argument of the given name.Map<String,String>getArguments()Get this command's arguments.JPAServletContextgetExecutionContext()Get the execution context of this command.StringgetQualifier(String key)Get the value of this command's qualifier of the given name.Map<String,String>getQualifiers()Get this command's qualifiers.booleanhasArgument(String key)Affirm this command contains an argument of the given name.booleanhasQualifier(String key)Affirm this command contains an qualifier of the given name.voidparse()Parse the given request to populate qualifiers and parameters of this command.voidprocess()Process the given request and write the output on to the given response in the given context.
-
-
-
Method Detail
-
getExecutionContext
JPAServletContext getExecutionContext()
Get the execution context of this command.- Returns:
- the execution context. never null.
-
parse
void parse() throws ProcessingExceptionParse 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. Duringprocessingphase, the parameters and qualifiers are accessed from the parsed command itself rather than from the original HTTP request.- Throws:
ProcessingException
-
process
void process() throws ProcessingException, IOExceptionProcess the given request and write the output on to the given response in the given context.- Throws:
ProcessingExceptionIOException
-
getArguments
Map<String,String> getArguments()
Get this command's arguments.- Throws:
IllegalStateException- if accessed prior to parsing.
-
getArgument
String getArgument(String key)
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
boolean hasArgument(String key)
Affirm this command contains an argument of the given name.- Throws:
IllegalStateException- if accessed prior to parsing.
-
getQualifiers
Map<String,String> getQualifiers()
Get this command's qualifiers.- Throws:
IllegalStateException- if accessed prior to parsing.
-
getQualifier
String getQualifier(String key)
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
boolean hasQualifier(String key)
Affirm this command contains an qualifier of the given name.- Throws:
IllegalStateException- if accessed prior to parsing.
-
-