Class AbstractConnectionWrapper<C extends Connection>
- java.lang.Object
- 
- org.forgerock.json.resource.AbstractConnectionWrapper<C>
 
- 
- Type Parameters:
- C- The type of wrapped connection.
 - All Implemented Interfaces:
- Closeable,- AutoCloseable,- Connection,- Describable<org.forgerock.api.models.ApiDescription,Request>
 
 public abstract class AbstractConnectionWrapper<C extends Connection> extends Object implements Connection, Describable<org.forgerock.api.models.ApiDescription,Request> An abstract base class from which connection wrappers may be easily implemented. The default implementation of each method is to delegate to the wrapped connection.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.forgerock.services.descriptor.DescribableDescribable.Listener
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected CconnectionThe wrapped connection.
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAbstractConnectionWrapper(C connection)Creates a new connection wrapper.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ActionResponseaction(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.voidaddDescriptorListener(Describable.Listener listener)Add a listener for API Descriptor changes.org.forgerock.api.models.ApiDescriptionapi(ApiProducer<org.forgerock.api.models.ApiDescription> producer)Provide the API description for the component.voidclose()Releases any resources associated with this connection.ResourceResponsecreate(Context context, CreateRequest request)Adds a new JSON resource.Promise<ResourceResponse,ResourceException>createAsync(Context context, CreateRequest request)Asynchronously adds a new JSON resource.ResourceResponsedelete(Context context, DeleteRequest request)Deletes a JSON resource.Promise<ResourceResponse,ResourceException>deleteAsync(Context context, DeleteRequest request)Asynchronously deletes a JSON resource.org.forgerock.api.models.ApiDescriptionhandleApiRequest(Context context, Request request)Handle a request for the API Descriptor.booleanisClosed()Indicates whether or not this connection has been explicitly closed by callingclose.booleanisValid()Returnstrueif this connection has not been closed and no fatal errors have been detected.ResourceResponsepatch(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.QueryResponsequery(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.QueryResponsequery(Context context, QueryRequest request, QueryResourceHandler handler)Searches for all JSON resources matching a user specified set of criteria, and returns aPromisethat 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 aPromisethat will be completed with the results of the search.ResourceResponseread(Context context, ReadRequest request)Reads a JSON resource.Promise<ResourceResponse,ResourceException>readAsync(Context context, ReadRequest request)Asynchronously reads a JSON resource.voidremoveDescriptorListener(Describable.Listener listener)Remove a listener from API Descriptor changes.protected Contexttransform(Context context)Optional Context-transformation function if the implementer has requirements to override theContextprovided in theConnection's method invocations.ResourceResponseupdate(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.
 
- 
- 
- 
Field Detail- 
connectionprotected final C extends Connection connection The wrapped connection.
 
- 
 - 
Constructor Detail- 
AbstractConnectionWrapperprotected AbstractConnectionWrapper(C connection) Creates a new connection wrapper.- Parameters:
- connection- The connection to be wrapped.
 
 
- 
 - 
Method Detail- 
transformprotected Context transform(Context context) Optional Context-transformation function if the implementer has requirements to override theContextprovided in theConnection's method invocations.The default implementation is a pass-through no-op. - Parameters:
- context- the request context
- Returns:
- the transformed context
 
 - 
actionpublic ActionResponse action(Context context, ActionRequest request) throws ResourceException Performs an action against a specific resource, or set of resources. Bulk updates are an example of an action request.The default implementation is to delegate. - Specified by:
- actionin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The action request.
- Returns:
- A JSON object containing the result of the action, the content of which is specified by the action.
- Throws:
- ResourceException- If the action could not be performed.
 
 - 
actionAsyncpublic Promise<ActionResponse,ResourceException> actionAsync(Context context, ActionRequest request) Asynchronously performs an action against a specific resource, or set of resources. Bulk updates are an example of an action request.The default implementation is to delegate. - Specified by:
- actionAsyncin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The action request.
- Returns:
- A future representing the result of the request.
 
 - 
closepublic void close() Releases any resources associated with this connection. For physical connections to a server this will mean that the underlying socket is closed.Other connection implementations may behave differently. For example, a pooled connection will be released and returned to its connection pool. Calling closeon a connection that is already closed has no effect.The default implementation is to delegate. - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- Connection
 
 - 
createpublic ResourceResponse create(Context context, CreateRequest request) throws ResourceException Adds a new JSON resource.The default implementation is to delegate. - Specified by:
- createin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The create request.
- Returns:
- The newly created JSON resource.
- Throws:
- ResourceException- If the JSON resource could not be created.
 
 - 
createAsyncpublic Promise<ResourceResponse,ResourceException> createAsync(Context context, CreateRequest request) Asynchronously adds a new JSON resource.The default implementation is to delegate. - Specified by:
- createAsyncin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The create request.
- Returns:
- A future representing the result of the request.
 
 - 
deletepublic ResourceResponse delete(Context context, DeleteRequest request) throws ResourceException Deletes a JSON resource.The default implementation is to delegate. - Specified by:
- deletein interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The delete request.
- Returns:
- The deleted JSON resource.
- Throws:
- ResourceException- If the JSON resource could not be deleted.
 
 - 
deleteAsyncpublic Promise<ResourceResponse,ResourceException> deleteAsync(Context context, DeleteRequest request) Asynchronously deletes a JSON resource.The default implementation is to delegate. - Specified by:
- deleteAsyncin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The delete request.
- Returns:
- A future representing the result of the request.
 
 - 
isClosedpublic boolean isClosed() Indicates whether or not this connection has been explicitly closed by callingclose. This method will not returntrueif a fatal error has occurred on the connection unlessclosehas been called.The default implementation is to delegate. - Specified by:
- isClosedin interface- Connection
- Returns:
- trueif this connection has been explicitly closed by calling- close, or- falseotherwise.
 
 - 
isValidpublic boolean isValid() Returnstrueif this connection has not been closed and no fatal errors have been detected. This method is guaranteed to returnfalseonly when it is called after the methodclosehas been called.The default implementation is to delegate. - Specified by:
- isValidin interface- Connection
- Returns:
- trueif this connection is valid,- falseotherwise.
 
 - 
patchpublic ResourceResponse patch(Context context, PatchRequest request) throws ResourceException Updates a JSON resource by applying a set of changes to its existing content.The default implementation is to delegate. - Specified by:
- patchin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The update request.
- Returns:
- The updated JSON resource.
- Throws:
- ResourceException- If the JSON resource could not be updated.
 
 - 
patchAsyncpublic Promise<ResourceResponse,ResourceException> patchAsync(Context context, PatchRequest request) Asynchronously updates a JSON resource by applying a set of changes to its existing content.The default implementation is to delegate. - Specified by:
- patchAsyncin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The patch request.
- Returns:
- A future representing the result of the request.
 
 - 
querypublic QueryResponse query(Context context, QueryRequest request, QueryResourceHandler handler) throws ResourceException Searches for all JSON resources matching a user specified set of criteria, and returns aPromisethat 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. - Specified by:
- queryin interface- Connection
- Parameters:
- 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.
- Returns:
- The query result.
- Throws:
- ResourceException- If the query could not be performed.
 
 - 
querypublic QueryResponse query(Context context, QueryRequest request, Collection<? super ResourceResponse> results) throws ResourceException Searches for all JSON resources matching a user specified set of criteria, and places the results in the provided collection.The default implementation is to delegate. - Specified by:
- queryin interface- Connection
- Parameters:
- 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.
- Returns:
- The query result.
- Throws:
- ResourceException- If the query could not be performed.
 
 - 
queryAsyncpublic 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 aPromisethat will be completed with the results of the search.Result processing happens-before the returned future completes. The default implementation is to delegate. - Specified by:
- queryAsyncin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The create request.
- handler- A non-- nullquery resource handler which should be used to process matching resources as they are received.
- Returns:
- A future representing the result of the request.
 
 - 
readpublic ResourceResponse read(Context context, ReadRequest request) throws ResourceException Reads a JSON resource.The default implementation is to delegate. - Specified by:
- readin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The read request.
- Returns:
- The JSON resource.
- Throws:
- ResourceException- If the JSON resource could not be read.
 
 - 
readAsyncpublic Promise<ResourceResponse,ResourceException> readAsync(Context context, ReadRequest request) Asynchronously reads a JSON resource.The default implementation is to delegate. - Specified by:
- readAsyncin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The read request.
- Returns:
- A future representing the result of the request.
 
 - 
updatepublic ResourceResponse update(Context context, UpdateRequest request) throws ResourceException Updates a JSON resource by replacing its existing content with new content.The default implementation is to delegate. - Specified by:
- updatein interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The update request.
- Returns:
- The updated JSON resource.
- Throws:
- ResourceException- If the JSON resource could not be updated.
 
 - 
updateAsyncpublic Promise<ResourceResponse,ResourceException> updateAsync(Context context, UpdateRequest request) Asynchronously updates a JSON resource by replacing its existing content with new content.The default implementation is to delegate. - Specified by:
- updateAsyncin interface- Connection
- Parameters:
- context- The request context, such as associated principal.
- request- The update request.
- Returns:
- A future representing the result of the request.
 
 - 
apipublic org.forgerock.api.models.ApiDescription api(ApiProducer<org.forgerock.api.models.ApiDescription> producer) Description copied from interface:DescribableProvide the API description for the component. This method should perform the heavy-lifting of computing the API descriptor, and should be expected to be called rarely. Upstream handlers should call this method in order to compose all of their downstream API Descriptors into a single descriptor.- Specified by:
- apiin interface- Describable<org.forgerock.api.models.ApiDescription,Request>
- Parameters:
- producer- The API producer that provides general information to be built into the descriptor.
- Returns:
- The description object.
 
 - 
handleApiRequestpublic org.forgerock.api.models.ApiDescription handleApiRequest(Context context, Request request) Description copied from interface:DescribableHandle a request for the API Descriptor. This method should not do any computation, but should return the already computed descriptor.- Specified by:
- handleApiRequestin interface- Describable<org.forgerock.api.models.ApiDescription,Request>
- Parameters:
- context- The request context.
- request- The request.
- Returns:
- The descriptor.
 
 - 
addDescriptorListenerpublic void addDescriptorListener(Describable.Listener listener) Description copied from interface:DescribableAdd a listener for API Descriptor changes. The described object should call all the listeners.- Specified by:
- addDescriptorListenerin interface- Describable<org.forgerock.api.models.ApiDescription,Request>
- Parameters:
- listener- The listener.
 
 - 
removeDescriptorListenerpublic void removeDescriptorListener(Describable.Listener listener) Description copied from interface:DescribableRemove a listener from API Descriptor changes.- Specified by:
- removeDescriptorListenerin interface- Describable<org.forgerock.api.models.ApiDescription,Request>
- Parameters:
- listener- The listener.
 
 
- 
 
-