Package com.sap.cds.services.runtime
Interface RequestContextRunner
public interface RequestContextRunner
RequestContextRunner
is the main entry to spawn a new RequestContext
with adapted UserInfo
or ParameterInfo
.
The current parameters of the calling RequestContext
are not affected.-
Method Summary
Modifier and TypeMethodDescriptionSets theUserInfo
for theRequestContext
to the anonymous user.Resets theMessages
for theRequestContext
being opened.Resets theParameterInfo
for theRequestContext
being opened.default RequestContextRunner
Resets theUserInfo
for theRequestContext
being opened.featureToggles
(FeatureTogglesInfo featureTogglesInfo) Sets a dedicatedFeatureTogglesInfo
for theRequestContext
being opened.modifyParameters
(Consumer<ModifiableParameterInfo> contextParameters) Opens aRequestContext
with an adaptedParameterInfo
.modifyUser
(Consumer<ModifiableUserInfo> contextUser) Opens aRequestContext
with an adaptedUserInfo
.parameters
(ParameterInfo parameterInfo) Sets a dedicatedParameterInfo
for theRequestContext
being opened.Sets theUserInfo
for theRequestContext
to the internal privileged user who passes all authorization checks.void
run
(Consumer<RequestContext> requestHandler) Opens aRequestContext
and runs the given handler within its scope.<T> T
run
(Function<RequestContext, T> requestHandler) Opens aRequestContext
and runs the given handler within its scope.Sets a dedicatedUserInfo
for theRequestContext
being opened.
-
Method Details
-
user
Sets a dedicatedUserInfo
for theRequestContext
being opened.- Parameters:
userInfo
- TheUserInfo
.- Returns:
- this instance
-
clearUser
Resets theUserInfo
for theRequestContext
being opened. The empty user is anonymous.- Returns:
- this instance
-
anonymousUser
RequestContextRunner anonymousUser()Sets theUserInfo
for theRequestContext
to the anonymous user. This user is the base-line also used byclearUser()
.- Returns:
- this instance
-
providedUser
RequestContextRunner providedUser()Sets theUserInfo
for theRequestContext
as provided by theUserInfoProvider
. By default this means theUserInfo
is resolved from the HTTP request. You may override the default provider during runtime configuration phase by means ofCdsRuntimeConfigurer.provider(UserInfoProvider)
.- Returns:
- this instance
-
privilegedUser
RequestContextRunner privilegedUser()Sets theUserInfo
for theRequestContext
to the internal privileged user who passes all authorization checks.- Returns:
- this instance
-
modifyUser
Opens aRequestContext
with an adaptedUserInfo
. The passedModifiableUserInfo
API can be used to define modifications which are valid within the scope of the newRequestContext
.The modifications are done on the
UserInfo
of the outerRequestContext
if existing. Otherwise they are done on the providedUserInfo
fromUserInfoProvider
.- Parameters:
contextUser
- theModifiableUserInfo
as modification layer on top of currentUserInfo
- Returns:
- this instance
-
parameters
Sets a dedicatedParameterInfo
for theRequestContext
being opened.- Parameters:
parameterInfo
- theParameterInfo
.- Returns:
- this instance
-
featureToggles
Sets a dedicatedFeatureTogglesInfo
for theRequestContext
being opened. Throws an exception in case theRequestContext
being opened has a parent (i.e. is nested).- Parameters:
featureTogglesInfo
- theFeatureTogglesInfo
.- Returns:
- this instance
-
clearParameters
RequestContextRunner clearParameters()Resets theParameterInfo
for theRequestContext
being opened.- Returns:
- this instance
-
providedParameters
RequestContextRunner providedParameters()Sets theParameterInfo
for theRequestContext
as provided by theParameterInfoProvider
. By default this means theParameterInfo
is resolved from the HTTP request. You may override the default provider during runtime configuration phase by means ofCdsRuntimeConfigurer.provider(ParameterInfoProvider)
.- Returns:
- this instance
-
modifyParameters
Opens aRequestContext
with an adaptedParameterInfo
. The passedModifiableParameterInfo
API can be used to define modifications which are valid within the scope of the newRequestContext
.The modifications are done on the
ParameterInfo
of the outerRequestContext
if existing. Otherwise they are done on the providedParameterInfo
fromParameterInfoProvider
.- Parameters:
contextParameters
- theModifiableParameterInfo
as modification layer on top of currentParameterInfo
- Returns:
- this instance
-
clearMessages
RequestContextRunner clearMessages()Resets theMessages
for theRequestContext
being opened.- Returns:
- this instance
-
run
Opens aRequestContext
and runs the given handler within its scope. TheRequestContext
will be propagated to allEventContext
instances in the service call hierarchy.- Type Parameters:
T
- The type of the response- Parameters:
requestHandler
- The handler for processing the request within the context- Returns:
- A generic response object of the handler
-
run
Opens aRequestContext
and runs the given handler within its scope. TheRequestContext
will be propagated to allEventContext
instances in the service call hierarchy.If
UserInfo
has not been specified explicitly, it is taken from the outerRequestContext
or, if there is no outer context, fromUserInfoProvider
. The same holds forParameterInfo
.- Parameters:
requestHandler
- The handler for processing the request within the context
-