Package org.apache.juneau.rest
Class RestSession
java.lang.Object
org.apache.juneau.ContextSession
org.apache.juneau.rest.RestSession
Represents a single HTTP request.
Notes:
- This class is not thread safe.
See Also:
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic RestSession.Builder
create
(RestContext ctx) Creates a builder of this object.debug
(boolean value) Enables or disabled debug mode on this call.Identifies that an exception occurred during this call.finish()
Called at the end of a call to finish any remaining tasks such as flushing buffers and logging the response.Returns the bean store of this call.Returns the context that created this call.Returns the exception that occurred during this call.Returns the HTTP method name.Returns the operation session of this REST session.Shortcut for callinggetRequest().getPathInfo() .Same asgetPathInfo()
but doesn't decode encoded characters.Returns resolved variable values on this call.@Resource (path)Returns the query parameters on the request.jakarta.servlet.http.HttpServletRequest
Returns the HTTP servlet request of this REST call.Returns the REST object.jakarta.servlet.http.HttpServletResponse
Returns the HTTP servlet response of this REST call.Shortcut for callinggetRequest().getServletPath() .int
Shortcut for callinggetRequest().getStatus() .Returns the request path info as aUrlPath
bean.Returns the URL path pattern match on this call.logger
(CallLogger value) Sets the logger to use when logging this call.void
run()
Runs this session.status
(int value) Sets the HTTP status on this call.status
(StatusLine value) Sets the HTTP status on this call.urlPathMatch
(UrlPathMatch value) Sets the URL path pattern match on this call.Methods inherited from class org.apache.juneau.ContextSession
addWarning, checkForWarnings, getSessionProperties, getWarnings, isDebug, properties, toString
-
Constructor Details
-
RestSession
Constructor.- Parameters:
builder
- The builder for this object.
-
-
Method Details
-
create
Creates a builder of this object.- Parameters:
ctx
- The context creating this builder.- Returns:
- A new builder.
-
logger
Sets the logger to use when logging this call.- Parameters:
value
- The new value for this setting. Can benull .- Returns:
- This object.
-
debug
Enables or disabled debug mode on this call.- Parameters:
value
- The new value for this setting.- Returns:
- This object.
- Throws:
IOException
- Occurs if request content could not be cached into memory.
-
status
Sets the HTTP status on this call.- Parameters:
value
- The status code.- Returns:
- This object.
-
status
Sets the HTTP status on this call.- Parameters:
value
- The status code.- Returns:
- This object.
-
exception
Identifies that an exception occurred during this call.- Parameters:
value
- The thrown exception.- Returns:
- This object.
-
urlPathMatch
Sets the URL path pattern match on this call.- Parameters:
value
- The match pattern.- Returns:
- This object.
-
getRequest
Returns the HTTP servlet request of this REST call.- Returns:
- the HTTP servlet request of this REST call.
-
getResponse
Returns the HTTP servlet response of this REST call.- Returns:
- the HTTP servlet response of this REST call.
-
getBeanStore
Returns the bean store of this call.- Returns:
- The bean store of this call.
-
getPathVars
Returns resolved variable values on this call.@Resource (path)- Returns:
- Resolved
variable values on this call.@Resource (path)
-
getUrlPathMatch
Returns the URL path pattern match on this call.- Returns:
- The URL path pattern match on this call.
-
getException
Returns the exception that occurred during this call.- Returns:
- The exception that occurred during this call.
-
finish
Called at the end of a call to finish any remaining tasks such as flushing buffers and logging the response.- Returns:
- This object.
-
getServletPath
Shortcut for callinggetRequest().getServletPath() .- Returns:
- The request servlet path.
-
getUrlPath
Returns the request path info as aUrlPath
bean.- Returns:
- The request path info as a
UrlPath
bean.
-
getPathInfo
Shortcut for callinggetRequest().getPathInfo() .- Returns:
- The request servlet path info.
-
getPathInfoUndecoded
Same asgetPathInfo()
but doesn't decode encoded characters.- Returns:
- The undecoded request servlet path info.
-
getQueryParams
Returns the query parameters on the request.Unlike
ServletRequest.getParameterMap()
, this doesn't parse the content if it's a POST.- Returns:
- The query parameters on the request.
-
getMethod
Returns the HTTP method name.- Returns:
- The HTTP method name, always uppercased.
-
getStatus
Shortcut for callinggetRequest().getStatus() .- Returns:
- The response status code.
-
getContext
Returns the context that created this call.- Overrides:
getContext
in classContextSession
- Returns:
- The context that created this call.
-
getResource
Returns the REST object.- Returns:
- The rest object.
-
getOpSession
Returns the operation session of this REST session.The operation session is created once the Java method to be invoked has been determined.
- Returns:
- The operation session of this REST session.
- Throws:
InternalServerError
- If operation session has not been created yet.
-
run
Runs this session.Does the following:
- Finds the Java method to invoke and creates a
RestOpSession
for it. - Invokes
RestPreCall
methods by callingRestContext.preCall(RestOpSession)
. - Invokes Java method by calling
RestOpSession.run()
. - Invokes
RestPostCall
methods by callingRestContext.postCall(RestOpSession)
. - If the Java method produced output, finds the response processor for it and runs it by calling
RestContext.processResponse(RestOpSession)
. - If no Java method matched, generates a 404/405/412 by calling
RestContext.handleNotFound(RestSession)
.
- Throws:
Throwable
- Any throwable can be thrown.
- Finds the Java method to invoke and creates a
-