Package org.forgerock.json.resource
Class Resources
- java.lang.Object
- 
- org.forgerock.json.resource.Resources
 
- 
 public final class Resources extends Object This class contains methods for creating and manipulating connection factories and connections.
- 
- 
Field SummaryFields Modifier and Type Field Description static JsonPointerFIELD_VALUE_ALL_PTRJsonPointer used in fields to denote "all fields", i.e., no filtering.
 - 
Method SummaryAll Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static RequestHandlerasRequestHandler(SynchronousRequestHandler syncHandler)Adapts the providedSynchronousRequestHandleras aRequestHandler.static JsonValuefilterResource(JsonValue resource, Collection<JsonPointer> fields)Returns a JSON object containing only the specified fields from the provided JSON value.static ResourceResponsefilterResource(ResourceResponse resource, Collection<JsonPointer> fields)Returns a JSON object containing only the specified fields from the provided resource.static RequestHandlernewAnnotatedRequestHandler(Object provider)Deprecated.UsenewHandler(Object)instead.static RequestHandlernewCollection(Object provider)Deprecated.UsenewHandler(Object)instead.static RequestHandlernewHandler(Object provider)Creates a newRequestHandlerbacked by the supplied provider.static ConnectionnewInternalConnection(RequestHandler handler)Creates a new connection to aRequestHandler.static ConnectionFactorynewInternalConnectionFactory(RequestHandler handler)Creates a new connection factory which binds internal client connections toRequestHandlers.static RequestHandlernewSingleton(Object provider)Deprecated.UsenewHandler(Object)instead.static Connectionuncloseable(Connection connection)Returns an uncloseable view of the provided connection.static ConnectionFactoryuncloseable(ConnectionFactory factory)Returns an uncloseable view of the provided connection factory.
 
- 
- 
- 
Field Detail- 
FIELD_VALUE_ALL_PTRpublic static final JsonPointer FIELD_VALUE_ALL_PTR JsonPointer used in fields to denote "all fields", i.e., no filtering.
 
- 
 - 
Method Detail- 
asRequestHandlerpublic static RequestHandler asRequestHandler(SynchronousRequestHandler syncHandler) Adapts the providedSynchronousRequestHandleras aRequestHandler.- Parameters:
- syncHandler- The synchronous request handler to be adapted.
- Returns:
- The adapted synchronous request handler.
 
 - 
filterResourcepublic static JsonValue filterResource(JsonValue resource, Collection<JsonPointer> fields) Returns a JSON object containing only the specified fields from the provided JSON value. If the list of fields is empty then the value is returned unchanged.NOTE: this method only performs a shallow copy of extracted fields, so changes to the filtered JSON value may impact the original JSON value, and vice-versa. - Parameters:
- resource- The JSON value whose fields are to be filtered.
- fields- The list of fields to be extracted.
- Returns:
- The filtered JSON value.
 
 - 
filterResourcepublic static ResourceResponse filterResource(ResourceResponse resource, Collection<JsonPointer> fields) Returns a JSON object containing only the specified fields from the provided resource. If the list of fields is empty then the resource is returned unchanged.NOTE: this method only performs a shallow copy of extracted fields, so changes to the filtered resource may impact the original resource, and vice-versa. - Parameters:
- resource- The resource whose fields are to be filtered.
- fields- The list of fields to be extracted.
- Returns:
- The filtered resource.
 
 - 
newInternalConnectionpublic static Connection newInternalConnection(RequestHandler handler) Creates a new connection to aRequestHandler.- Parameters:
- handler- The request handler to which client requests should be forwarded.
- Returns:
- The new internal connection.
- Throws:
- NullPointerException- If- handlerwas- null.
 
 - 
newInternalConnectionFactorypublic static ConnectionFactory newInternalConnectionFactory(RequestHandler handler) Creates a new connection factory which binds internal client connections toRequestHandlers.- Parameters:
- handler- The request handler to which client requests should be forwarded.
- Returns:
- The new internal connection factory.
- Throws:
- NullPointerException- If- handlerwas- null.
 
 - 
newHandlerpublic static RequestHandler newHandler(Object provider) Creates a newRequestHandlerbacked by the supplied provider. The provider can be an instance of an interface resource handler, and annotated resource handler or an annotated request handler. The type of the provider will be determined from theorg.forgerock.api.annotations.RequestHandler#variantannotation property, or from the type of interface implemented.Sub-paths that are declared using the org.forgerock.api.annotations.Pathannotation will also be routed through the returned handler.This method uses the same logic as newCollection(Object),newSingleton(Object)andnewAnnotatedRequestHandler(Object)to create the underlyingRequestHandlers.- Parameters:
- provider- The provider instance.
- Returns:
- The constructed handler.
 
 - 
newCollection@Deprecated public static RequestHandler newCollection(Object provider) Deprecated.UsenewHandler(Object)instead.Returns a new request handler which will forward requests on to the provided collection resource provider. Incoming requests which are not appropriate for a resource collection or resource instance will result in a bad request error being returned to the client.- Parameters:
- provider- The collection resource provider. Either an implementation of- CollectionResourceProvideror a POJO annotated with annotations from- org.forgerock.api.annotations.
- Returns:
- A new request handler which will forward requests on to the provided collection resource provider.
 
 - 
newSingleton@Deprecated public static RequestHandler newSingleton(Object provider) Deprecated.UsenewHandler(Object)instead.Returns a new request handler which will forward requests on to the provided singleton resource provider. Incoming requests which are not appropriate for a singleton resource (e.g. query) will result in a bad request error being returned to the client.- Parameters:
- provider- The singleton resource provider. Either an implementation of- SingletonResourceProvideror a POJO annotated with annotations from- org.forgerock.api.annotations.
- Returns:
- A new request handler which will forward requests on to the provided singleton resource provider.
 
 - 
newAnnotatedRequestHandler@Deprecated public static RequestHandler newAnnotatedRequestHandler(Object provider) Deprecated.UsenewHandler(Object)instead.Returns a new request handler which will forward requests on to the provided annotated request handler.- Parameters:
- provider- The POJO annotated with annotations from- org.forgerock.api.annotations.
- Returns:
- A new request handler which will forward requests on to the provided annotated POJO.
 
 - 
uncloseablepublic static Connection uncloseable(Connection connection) Returns an uncloseable view of the provided connection. Attempts to callConnection.close()will be ignored.- Parameters:
- connection- The connection whose- closemethod is to be disabled.
- Returns:
- An uncloseable view of the provided connection.
 
 - 
uncloseablepublic static ConnectionFactory uncloseable(ConnectionFactory factory) Returns an uncloseable view of the provided connection factory. Attempts to callConnectionFactory.close()will be ignored.- Parameters:
- factory- The connection factory whose- closemethod is to be disabled.
- Returns:
- An uncloseable view of the provided connection factory.
 
 
- 
 
-