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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RestSession.Buildercreate(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.HttpServletRequestReturns the HTTP servlet request of this REST call.Returns the REST object.jakarta.servlet.http.HttpServletResponseReturns the HTTP servlet response of this REST call.Shortcut for callinggetRequest().getServletPath() .intShortcut for callinggetRequest().getStatus() .Returns the request path info as aUrlPathbean.Returns the URL path pattern match on this call.logger(CallLogger value) Sets the logger to use when logging this call.Returns the properties on this bean as a map for debugging.voidrun()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, 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.
Cannot benull .- Returns:
- A new builder.
-
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.
-
exception
Identifies that an exception occurred during this call.- Parameters:
value- The thrown exception.
Can benull (will clear the exception attribute and remove the exception from the bean store).- Returns:
- This object.
-
finish
Called at the end of a call to finish any remaining tasks such as flushing buffers and logging the response.- Returns:
- This object.
-
getBeanStore
Returns the bean store of this call.- Returns:
- The bean store of this call.
-
getContext
Returns the context that created this call.- Overrides:
getContextin classContextSession- Returns:
- The context that created this call.
-
getException
Returns the exception that occurred during this call.- Returns:
- The exception that occurred during this call.
-
getMethod
Returns the HTTP method name.- Returns:
- The HTTP method name, always uppercased.
- Throws:
NotFound- If the method parameter contains invalid/malformed characters.
-
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.
-
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.
-
getPathVars
Returns resolved variable values on this call.@Resource (path)- Returns:
- Resolved
variable values on this call.@Resource (path)
-
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.
-
getRequest
Returns the HTTP servlet request of this REST call.- Returns:
- the HTTP servlet request of this REST call.
-
getResource
Returns the REST object.- Returns:
- The rest object.
-
getResponse
Returns the HTTP servlet response of this REST call.- Returns:
- the HTTP servlet response of this REST call.
-
getServletPath
Shortcut for callinggetRequest().getServletPath() .- Returns:
- The request servlet path.
-
getStatus
Shortcut for callinggetRequest().getStatus() .- Returns:
- The response status code.
-
getUrlPath
Returns the request path info as aUrlPathbean.- Returns:
- The request path info as a
UrlPathbean.
-
getUrlPathMatch
Returns the URL path pattern match on this call.- Returns:
- The URL path pattern match on this call.
-
logger
Sets the logger to use when logging this call.- Parameters:
value- The new value for this setting.
Can benull (will use the default logger from the context if available).- Returns:
- This object.
-
run
Runs this session.Does the following:
- Finds the Java method to invoke and creates a
RestOpSessionfor it. - Invokes
RestPreCallmethods by callingRestContext.preCall(RestOpSession). - Invokes Java method by calling
RestOpSession.run(). - Invokes
RestPostCallmethods 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
-
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.
Can benull (ignored).- Returns:
- This object.
-
urlPathMatch
Sets the URL path pattern match on this call.- Parameters:
value- The match pattern.
Can benull .- Returns:
- This object.
-
properties
Description copied from class:ContextSessionReturns the properties on this bean as a map for debugging.- Overrides:
propertiesin classContextSession- Returns:
- The properties on this bean as a map for debugging.
-