@Retention(value=RUNTIME) @Target(value=METHOD) public @interface Routed
Controller
method.
For conflicting URIs like /foo/:1
should handle everything but /foo/special
, use a
priority below PriorityCollector.DEFAULT_PRIORITY
for /foo/special
Modifier and Type | Required Element and Description |
---|---|
String |
value
Returns the URI pattern which describes matching request.
|
Modifier and Type | Optional Element and Description |
---|---|
boolean |
jsonCall
Determines if the annotated method is used to generate a JSON response.
|
boolean |
preDispatchable
Determines if the annotated method supports pre-dispatching.
|
int |
priority
Sets the priority used for this route.
|
public abstract String value
The pattern should start with a / character, which is also use to separate path elements. Each element can be one of the following:
WebContext.setAttribute(String, Object)
NLS
. The resulting
string must match the part in the request URIpublic abstract int priority
For non-conflicting URIs, this can be skipped. For everything else, the lower the better ;-)
PriorityCollector.DEFAULT_PRIORITY
.public abstract boolean preDispatchable
A pre-dispatchable method takes care of the requests payload itself. Therefore the method must declare an
additional parameter of type InputStreamHandler
which will be used to consume
the data sent via POST or PUT.
public abstract boolean jsonCall
This can be used to handle AJAX requests directly within a controller. In such simple cases if is often
feasible to keep the logic in one place (controller) instead for creating a StructuredService
.
A method having jsonCall set to true has to accept
JSONStructuredOutput
as 2nd parameter. This parameter is filled with a
pre-initialized output writer, which has JSONStructuredOutput.beginResult()
and JSONStructuredOutput.endResult()
automatically called.
Also the properties success and error are automatically filled. In case on an exception within the controller method, a result with success, errro and message is automatically created.
Note: If implementing method does fork a new thread and pass the given output along,
the method must return a Promise
or Future
so that the dispatcher knowns when the generated output is complete.
Copyright © 2018. All rights reserved.