Package org.forgerock.json.resource
Interface SynchronousRequestHandler
public interface SynchronousRequestHandler
An interface for implementing synchronous
RequestHandler
s. A
synchronous request handler will block the caller until an operation has
completed which may impact scalability in many environments, such as
application servers. Therefore it is recommended that request handlers which
are intended for use in production environments implement the asynchronous
RequestHandler
interface. This interface can be easily "mocked" and
is therefore suitable for use in unit tests.
A synchronous request handler can be adapted as a RequestHandler
using the Resources.asRequestHandler(SynchronousRequestHandler)
method.
For more documentation about the individual operations see
RequestHandler
.
-
Method Summary
Modifier and TypeMethodDescriptionhandleAction
(Context context, ActionRequest request) Handles performing an action on a resource, and optionally returns an associated result.handleCreate
(Context context, CreateRequest request) Adds a new JSON resource.handleDelete
(Context context, DeleteRequest request) Deletes a JSON resource.handlePatch
(Context context, PatchRequest request) Updates a JSON resource by applying a set of changes to its existing content.handleQuery
(Context context, QueryRequest request, Collection<ResourceResponse> resources) Searches for all JSON resources matching a user specified set of criteria.handleRead
(Context context, ReadRequest request) Reads a JSON resource.handleUpdate
(Context context, UpdateRequest request) Updates a JSON resource by replacing its existing content with new content.
-
Method Details
-
handleAction
Handles performing an action on a resource, and optionally returns an associated result. The execution of an action is allowed to incur side effects.- Parameters:
context
- The request server context, such as associated principal.request
- The action request.- Returns:
- The possibly
null
result of the action. - Throws:
ResourceException
- If the request failed for some reason.- See Also:
-
handleCreate
Adds a new JSON resource.- Parameters:
context
- The request server context, such as associated principal.request
- The create request.- Returns:
- The new resource.
- Throws:
ResourceException
- If the request failed for some reason.- See Also:
-
handleDelete
Deletes a JSON resource.- Parameters:
context
- The request server context, such as associated principal.request
- The delete request.- Returns:
- The deleted resource.
- Throws:
ResourceException
- If the request failed for some reason.- See Also:
-
handlePatch
Updates a JSON resource by applying a set of changes to its existing content.- Parameters:
context
- The request server context, such as associated principal.request
- The patch request.- Returns:
- The patched resource.
- Throws:
ResourceException
- If the request failed for some reason.- See Also:
-
handleQuery
QueryResponse handleQuery(Context context, QueryRequest request, Collection<ResourceResponse> resources) throws ResourceException Searches for all JSON resources matching a user specified set of criteria.- Parameters:
context
- The request server context, such as associated principal.request
- The query request.resources
- A non-null
collection into which matching resources should be put.- Returns:
- The query result.
- Throws:
ResourceException
- If the request failed for some reason.- See Also:
-
handleRead
Reads a JSON resource.- Parameters:
context
- The request server context, such as associated principal.request
- The read request.- Returns:
- The resource.
- Throws:
ResourceException
- If the request failed for some reason.- See Also:
-
handleUpdate
Updates a JSON resource by replacing its existing content with new content.- Parameters:
context
- The request server context, such as associated principal.request
- The update request.- Returns:
- The updated resource.
- Throws:
ResourceException
- If the request failed for some reason.- See Also:
-