Class JerseyResource
- java.lang.Object
-
- org.apache.solr.api.JerseyResource
-
- Direct Known Subclasses:
AdminAPIBase,CoreAdminAPIBase,GetPublicKey,GetSchema,GetSchemaFieldAPI,ListConfigSets,NodeLoggingAPI,ReplicationAPIBase,SnapshotBackupAPI
public class JerseyResource extends Object
A marker parent type for all Jersey "resource" classes."Resources" in Jersey are classes that define one or more API endpoints. As such they're analogous to the v1
SolrRequestHandleror the v2Api.
-
-
Field Summary
Fields Modifier and Type Field Description jakarta.ws.rs.container.ContainerRequestContextcontainerRequestContext
-
Constructor Summary
Constructors Constructor Description JerseyResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidensureRequiredParameterProvided(String parameterName, Object parameterValue)protected voidensureRequiredRequestBodyProvided(Object requestBody)protected <T extends SolrJerseyResponse>
TinstantiateJerseyResponse(Class<T> clazz)Create an instance of theSolrJerseyResponsesubclass; registering it with the Jersey request-context upon creation.protected <T extends SolrJerseyResponse>
TinstantiateJerseyResponse(Supplier<T> instantiator)Create an instance of theSolrJerseyResponsesubclass; registering it with the Jersey request-context upon creation.
-
-
-
Method Detail
-
instantiateJerseyResponse
protected <T extends SolrJerseyResponse> T instantiateJerseyResponse(Class<T> clazz)
Create an instance of theSolrJerseyResponsesubclass; registering it with the Jersey request-context upon creation.This utility method primarily exists to allow Jersey resources to return error responses that match those returned by Solr's v1 APIs.
When a severe-enough exception halts a v1 request, Solr generates a summary of the error and attaches it to the
SolrQueryResponsegiven to the request handler. This SolrQueryResponse may already hold some portion of the normal "success" response for that API.The JAX-RS framework isn't well suited to mimicking responses of this sort, as the "response" from a Jersey resource is its return value (instead of a mutable method parameter that gets modified). This utility works around this limitation by attaching the eventual return value of a JerseyResource to the context associated with the Jersey request, as soon as its created. This allows partially-constructed responses to be accessed later in the case of an exception.
In order to instantiate arbitrary SolrJerseyResponse subclasses, this utility uses reflection to find and invoke the first (no-arg) constructor for the specified type. SolrJerseyResponse subclasses without a no-arg constructor can be instantiated and registered using
instantiateJerseyResponse(Supplier)- Parameters:
clazz- the SolrJerseyResponse class to instantiate and register- See Also:
CatchAllExceptionMapper,HttpSolrCall.call()
-
instantiateJerseyResponse
protected <T extends SolrJerseyResponse> T instantiateJerseyResponse(Supplier<T> instantiator)
Create an instance of theSolrJerseyResponsesubclass; registering it with the Jersey request-context upon creation.This utility method primarily exists to allow Jersey resources to return responses, especially error responses, that match some of the particulars of Solr's traditional/v1 APIs. See the companion method
instantiateJerseyResponse(Class)for more details.- Parameters:
instantiator- a lambda to create the desired SolrJerseyResponse- See Also:
CatchAllExceptionMapper,HttpSolrCall.call()
-
ensureRequiredParameterProvided
protected void ensureRequiredParameterProvided(String parameterName, Object parameterValue)
-
ensureRequiredRequestBodyProvided
protected void ensureRequiredRequestBodyProvided(Object requestBody)
-
-