C
- The type of wrapped connection.public abstract class AbstractConnectionWrapper<C extends Connection> extends Object implements Connection, Describable<ApiDescription,Request>
Describable.Listener
Modifier and Type | Field and Description |
---|---|
protected C |
connection
The wrapped connection.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractConnectionWrapper(C connection)
Creates a new connection wrapper.
|
Modifier and Type | Method and Description |
---|---|
ActionResponse |
action(Context context,
ActionRequest request)
Performs an action against a specific resource, or set of resources.
|
Promise<ActionResponse,ResourceException> |
actionAsync(Context context,
ActionRequest request)
Asynchronously performs an action against a specific resource, or set of
resources.
|
void |
addDescriptorListener(Describable.Listener listener)
Add a listener for API Descriptor changes.
|
ApiDescription |
api(ApiProducer<ApiDescription> producer)
Provide the API description for the component.
|
void |
close()
Releases any resources associated with this connection.
|
ResourceResponse |
create(Context context,
CreateRequest request)
Adds a new JSON resource.
|
Promise<ResourceResponse,ResourceException> |
createAsync(Context context,
CreateRequest request)
Asynchronously adds a new JSON resource.
|
ResourceResponse |
delete(Context context,
DeleteRequest request)
Deletes a JSON resource.
|
Promise<ResourceResponse,ResourceException> |
deleteAsync(Context context,
DeleteRequest request)
Asynchronously deletes a JSON resource.
|
ApiDescription |
handleApiRequest(Context context,
Request request)
Handle a request for the API Descriptor.
|
boolean |
isClosed()
Indicates whether or not this connection has been explicitly closed by
calling
close . |
boolean |
isValid()
Returns
true if this connection has not been closed and no fatal
errors have been detected. |
ResourceResponse |
patch(Context context,
PatchRequest request)
Updates a JSON resource by applying a set of changes to its existing
content.
|
Promise<ResourceResponse,ResourceException> |
patchAsync(Context context,
PatchRequest request)
Asynchronously updates a JSON resource by applying a set of changes to
its existing content.
|
QueryResponse |
query(Context context,
QueryRequest request,
Collection<? super ResourceResponse> results)
Searches for all JSON resources matching a user specified set of
criteria, and places the results in the provided collection.
|
QueryResponse |
query(Context context,
QueryRequest request,
QueryResourceHandler handler)
Searches for all JSON resources matching a user specified set of
criteria, and returns a
Promise that will be completed with the
results of the search. |
Promise<QueryResponse,ResourceException> |
queryAsync(Context context,
QueryRequest request,
QueryResourceHandler handler)
Asynchronously searches for all JSON resources matching a user specified
set of criteria, and returns a
Promise that will be completed with the
results of the search. |
ResourceResponse |
read(Context context,
ReadRequest request)
Reads a JSON resource.
|
Promise<ResourceResponse,ResourceException> |
readAsync(Context context,
ReadRequest request)
Asynchronously reads a JSON resource.
|
void |
removeDescriptorListener(Describable.Listener listener)
Remove a listener from API Descriptor changes.
|
protected Context |
transform(Context context)
Optional Context-transformation function if the implementer has
requirements to override the
Context provided in the
Connection 's method invocations. |
ResourceResponse |
update(Context context,
UpdateRequest request)
Updates a JSON resource by replacing its existing content with new
content.
|
Promise<ResourceResponse,ResourceException> |
updateAsync(Context context,
UpdateRequest request)
Asynchronously updates a JSON resource by replacing its existing content
with new content.
|
protected final C extends Connection connection
protected AbstractConnectionWrapper(C connection)
connection
- The connection to be wrapped.protected Context transform(Context context)
Context
provided in the
Connection
's method invocations.
The default implementation is a pass-through no-op.
context
- the request contextpublic ActionResponse action(Context context, ActionRequest request) throws ResourceException
The default implementation is to delegate.
action
in interface Connection
context
- The request context, such as associated principal.request
- The action request.ResourceException
- If the action could not be performed.public Promise<ActionResponse,ResourceException> actionAsync(Context context, ActionRequest request)
The default implementation is to delegate.
actionAsync
in interface Connection
context
- The request context, such as associated principal.request
- The action request.public void close()
Other connection implementations may behave differently. For example, a pooled connection will be released and returned to its connection pool.
Calling close
on a connection that is already closed has no
effect.
The default implementation is to delegate.
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Connection
public ResourceResponse create(Context context, CreateRequest request) throws ResourceException
The default implementation is to delegate.
create
in interface Connection
context
- The request context, such as associated principal.request
- The create request.ResourceException
- If the JSON resource could not be created.public Promise<ResourceResponse,ResourceException> createAsync(Context context, CreateRequest request)
The default implementation is to delegate.
createAsync
in interface Connection
context
- The request context, such as associated principal.request
- The create request.public ResourceResponse delete(Context context, DeleteRequest request) throws ResourceException
The default implementation is to delegate.
delete
in interface Connection
context
- The request context, such as associated principal.request
- The delete request.ResourceException
- If the JSON resource could not be deleted.public Promise<ResourceResponse,ResourceException> deleteAsync(Context context, DeleteRequest request)
The default implementation is to delegate.
deleteAsync
in interface Connection
context
- The request context, such as associated principal.request
- The delete request.public boolean isClosed()
close
. This method will not return true
if a
fatal error has occurred on the connection unless close
has been
called.
The default implementation is to delegate.
isClosed
in interface Connection
true
if this connection has been explicitly closed by
calling close
, or false
otherwise.public boolean isValid()
true
if this connection has not been closed and no fatal
errors have been detected. This method is guaranteed to return
false
only when it is called after the method close
has
been called.
The default implementation is to delegate.
isValid
in interface Connection
true
if this connection is valid, false
otherwise.public ResourceResponse patch(Context context, PatchRequest request) throws ResourceException
The default implementation is to delegate.
patch
in interface Connection
context
- The request context, such as associated principal.request
- The update request.ResourceException
- If the JSON resource could not be updated.public Promise<ResourceResponse,ResourceException> patchAsync(Context context, PatchRequest request)
The default implementation is to delegate.
patchAsync
in interface Connection
context
- The request context, such as associated principal.request
- The patch request.public QueryResponse query(Context context, QueryRequest request, QueryResourceHandler handler) throws ResourceException
Promise
that will be completed with the
results of the search.
Result processing happens-before this method returns to the caller.
The default implementation is to delegate.
query
in interface Connection
context
- The request context, such as associated principal.request
- The query request.handler
- A query resource handler which can be used to process
matching resources as they are received.ResourceException
- If the query could not be performed.public QueryResponse query(Context context, QueryRequest request, Collection<? super ResourceResponse> results) throws ResourceException
The default implementation is to delegate.
query
in interface Connection
context
- The request context, such as associated principal.request
- The query request.results
- A collection into which matching resources will be added as
they are received.ResourceException
- If the query could not be performed.public Promise<QueryResponse,ResourceException> queryAsync(Context context, QueryRequest request, QueryResourceHandler handler)
Promise
that will be completed with the
results of the search.
Result processing happens-before the returned future completes.
The default implementation is to delegate.
queryAsync
in interface Connection
context
- The request context, such as associated principal.request
- The create request.handler
- A non-null
query resource handler which should be
used to process matching resources as they are received.public ResourceResponse read(Context context, ReadRequest request) throws ResourceException
The default implementation is to delegate.
read
in interface Connection
context
- The request context, such as associated principal.request
- The read request.ResourceException
- If the JSON resource could not be read.public Promise<ResourceResponse,ResourceException> readAsync(Context context, ReadRequest request)
The default implementation is to delegate.
readAsync
in interface Connection
context
- The request context, such as associated principal.request
- The read request.public ResourceResponse update(Context context, UpdateRequest request) throws ResourceException
The default implementation is to delegate.
update
in interface Connection
context
- The request context, such as associated principal.request
- The update request.ResourceException
- If the JSON resource could not be updated.public Promise<ResourceResponse,ResourceException> updateAsync(Context context, UpdateRequest request)
The default implementation is to delegate.
updateAsync
in interface Connection
context
- The request context, such as associated principal.request
- The update request.public ApiDescription api(ApiProducer<ApiDescription> producer)
Describable
api
in interface Describable<ApiDescription,Request>
producer
- The API producer that provides general information to be built into the descriptor.public ApiDescription handleApiRequest(Context context, Request request)
Describable
handleApiRequest
in interface Describable<ApiDescription,Request>
context
- The request context.request
- The request.public void addDescriptorListener(Describable.Listener listener)
Describable
addDescriptorListener
in interface Describable<ApiDescription,Request>
listener
- The listener.public void removeDescriptorListener(Describable.Listener listener)
Describable
removeDescriptorListener
in interface Describable<ApiDescription,Request>
listener
- The listener.Copyright © 2010-2018, ForgeRock All Rights Reserved.