public final class Resources extends Object
Modifier and Type | Field and Description |
---|---|
static JsonPointer |
FIELD_VALUE_ALL_PTR
JsonPointer used in fields to denote "all fields", i.e., no filtering.
|
Modifier and Type | Method and Description |
---|---|
static RequestHandler |
asRequestHandler(SynchronousRequestHandler syncHandler)
Adapts the provided
SynchronousRequestHandler as a
RequestHandler . |
static JsonValue |
filterResource(JsonValue resource,
Collection<JsonPointer> fields)
Returns a JSON object containing only the specified fields from the
provided JSON value.
|
static ResourceResponse |
filterResource(ResourceResponse resource,
Collection<JsonPointer> fields)
Returns a JSON object containing only the specified fields from the
provided resource.
|
static RequestHandler |
newAnnotatedRequestHandler(Object provider)
Deprecated.
Use
Resources.newHandler(Object) instead. |
static RequestHandler |
newCollection(Object provider)
Deprecated.
Use
Resources.newHandler(Object) instead. |
static RequestHandler |
newHandler(Object provider)
Creates a new
RequestHandler backed by the supplied provider. |
static Connection |
newInternalConnection(RequestHandler handler)
Creates a new connection to a
RequestHandler . |
static ConnectionFactory |
newInternalConnectionFactory(RequestHandler handler)
Creates a new connection factory which binds internal client connections
to
RequestHandler s. |
static RequestHandler |
newSingleton(Object provider)
Deprecated.
Use
Resources.newHandler(Object) instead. |
static Connection |
uncloseable(Connection connection)
Returns an uncloseable view of the provided connection.
|
static ConnectionFactory |
uncloseable(ConnectionFactory factory)
Returns an uncloseable view of the provided connection factory.
|
public static final JsonPointer FIELD_VALUE_ALL_PTR
public static RequestHandler asRequestHandler(SynchronousRequestHandler syncHandler)
SynchronousRequestHandler
as a
RequestHandler
.syncHandler
- The synchronous request handler to be adapted.public static JsonValue filterResource(JsonValue resource, Collection<JsonPointer> fields)
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.
resource
- The JSON value whose fields are to be filtered.fields
- The list of fields to be extracted.public static ResourceResponse filterResource(ResourceResponse resource, Collection<JsonPointer> fields)
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.
resource
- The resource whose fields are to be filtered.fields
- The list of fields to be extracted.public static Connection newInternalConnection(RequestHandler handler)
RequestHandler
.handler
- The request handler to which client requests should be
forwarded.NullPointerException
- If handler
was null
.public static ConnectionFactory newInternalConnectionFactory(RequestHandler handler)
RequestHandler
s.handler
- The request handler to which client requests should be
forwarded.NullPointerException
- If handler
was null
.public static RequestHandler newHandler(Object provider)
RequestHandler
backed 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 the org.forgerock.api.annotations.RequestHandler#variant
annotation property, or from the type of interface implemented.
Sub-paths that are declared using the org.forgerock.api.annotations.Path
annotation will also be routed
through the returned handler.
This method uses the same logic as Resources.newCollection(Object)
, Resources.newSingleton(Object)
and
Resources.newAnnotatedRequestHandler(Object)
to create the underlying RequestHandler
s.
provider
- The provider instance.@Deprecated public static RequestHandler newCollection(Object provider)
Resources.newHandler(Object)
instead.provider
- The collection resource provider. Either an implementation of CollectionResourceProvider
or
a POJO annotated with annotations from org.forgerock.api.annotations
.@Deprecated public static RequestHandler newSingleton(Object provider)
Resources.newHandler(Object)
instead.provider
- The singleton resource provider. Either an implementation of SingletonResourceProvider
or
a POJO annotated with annotations from org.forgerock.api.annotations
.@Deprecated public static RequestHandler newAnnotatedRequestHandler(Object provider)
Resources.newHandler(Object)
instead.provider
- The POJO annotated with annotations from org.forgerock.api.annotations
.public static Connection uncloseable(Connection connection)
Connection.close()
will be ignored.connection
- The connection whose close
method is to be disabled.public static ConnectionFactory uncloseable(ConnectionFactory factory)
ConnectionFactory.close()
will be ignored.factory
- The connection factory whose close
method is to be
disabled.Copyright © 2010-2018, ForgeRock All Rights Reserved.