final class MethodSelectingRouter extends java.lang.Object implements Router
Modifier and Type | Class and Description |
---|---|
private static class |
MethodSelectingRouter.ConsumesProducesAcceptor
Represents a 1-1-1 relation between input and output media type and an methodAcceptorPair.
|
private static class |
MethodSelectingRouter.MethodSelector
Helper class to select matching resource method to be invoked.
|
private static class |
MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor
The same as above ConsumesProducesAcceptor,
only concrete request content-type and accept header info is included in addition.
|
Router.Continuation
Modifier and Type | Field and Description |
---|---|
private static java.util.Comparator<MethodSelectingRouter.ConsumesProducesAcceptor> |
CONSUMES_PRODUCES_ACCEPTOR_COMPARATOR |
private java.util.Map<java.lang.String,java.util.List<MethodSelectingRouter.ConsumesProducesAcceptor>> |
consumesProducesAcceptors |
private static java.util.logging.Logger |
LOGGER |
private Router |
router |
private MessageBodyWorkers |
workers |
Constructor and Description |
---|
MethodSelectingRouter(MessageBodyWorkers workers,
java.util.List<MethodRouting> methodRoutings)
Create a new
MethodSelectingRouter for all the methods on the same path. |
Modifier and Type | Method and Description |
---|---|
private void |
addAllConsumesProducesCombinations(java.util.List<MethodSelectingRouter.ConsumesProducesAcceptor> acceptors,
MethodRouting methodRouting) |
Router.Continuation |
apply(RequestProcessingContext requestContext)
Performs a request routing task and returns the routed request together with
a
routing continuation . |
private Router |
createHeadEnrichedRouter() |
private Router |
createInternalRouter() |
private javax.ws.rs.core.MediaType |
determineResponseMediaType(java.lang.Class<?> entityClass,
java.lang.reflect.Type entityType,
MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor selectedMethod,
java.util.List<AcceptableMediaType> acceptableMediaTypes)
Determine the
MediaType of the Response based on writers suitable for the given entity class,
pre-selected method and acceptable media types. |
private void |
fillInputTypesFromWorkers(java.util.Set<javax.ws.rs.core.MediaType> effectiveInputTypes,
Invocable invocableMethod) |
private boolean |
fillMediaTypes(java.util.Set<javax.ws.rs.core.MediaType> effectiveTypes,
ResourceMethod resourceMethod,
java.util.List<javax.ws.rs.core.MediaType> methodTypes,
boolean inputTypes) |
private void |
fillOutputTypesFromWorkers(java.util.Set<javax.ws.rs.core.MediaType> effectiveOutputTypes,
java.lang.Class<?> returnEntityType) |
private Parameter |
getEntityParam(Invocable invocable) |
private java.util.List<Router> |
getMethodRouter(RequestProcessingContext context) |
private boolean |
isReadable(MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor candidate) |
private boolean |
isWriteable(MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor candidate) |
private void |
reportMethodSelectionAmbiguity(java.util.List<AcceptableMediaType> acceptableTypes,
MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor selected,
java.util.List<MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor> sameFitnessAcceptors) |
private MethodSelectingRouter.MethodSelector |
selectMethod(java.util.List<AcceptableMediaType> acceptableMediaTypes,
java.util.List<MethodSelectingRouter.ConsumesProducesAcceptor> satisfyingAcceptors,
javax.ws.rs.core.MediaType effectiveContentType,
boolean singleInvokableMethod)
Select method to be invoked.
|
private static boolean |
usePreSelectedMediaType(MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor selectedMethod,
java.util.List<AcceptableMediaType> acceptableMediaTypes) |
private static final java.util.logging.Logger LOGGER
private static final java.util.Comparator<MethodSelectingRouter.ConsumesProducesAcceptor> CONSUMES_PRODUCES_ACCEPTOR_COMPARATOR
private final MessageBodyWorkers workers
private final java.util.Map<java.lang.String,java.util.List<MethodSelectingRouter.ConsumesProducesAcceptor>> consumesProducesAcceptors
private final Router router
MethodSelectingRouter(MessageBodyWorkers workers, java.util.List<MethodRouting> methodRoutings)
MethodSelectingRouter
for all the methods on the same path.
The router selects the method that best matches the request based on
produce/consume information from the resource method models.workers
- message body workers.methodRoutings
- [method model, method methodAcceptorPair] pairs.private Router createInternalRouter()
public Router.Continuation apply(RequestProcessingContext requestContext)
Router
routing continuation
.private void addAllConsumesProducesCombinations(java.util.List<MethodSelectingRouter.ConsumesProducesAcceptor> acceptors, MethodRouting methodRouting)
private boolean fillMediaTypes(java.util.Set<javax.ws.rs.core.MediaType> effectiveTypes, ResourceMethod resourceMethod, java.util.List<javax.ws.rs.core.MediaType> methodTypes, boolean inputTypes)
private void fillOutputTypesFromWorkers(java.util.Set<javax.ws.rs.core.MediaType> effectiveOutputTypes, java.lang.Class<?> returnEntityType)
private void fillInputTypesFromWorkers(java.util.Set<javax.ws.rs.core.MediaType> effectiveInputTypes, Invocable invocableMethod)
private java.util.List<Router> getMethodRouter(RequestProcessingContext context)
private javax.ws.rs.core.MediaType determineResponseMediaType(java.lang.Class<?> entityClass, java.lang.reflect.Type entityType, MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor selectedMethod, java.util.List<AcceptableMediaType> acceptableMediaTypes)
MediaType
of the Response
based on writers suitable for the given entity class,
pre-selected method and acceptable media types.entityClass
- entity class to determine the media type for.entityType
- entity type for writers.selectedMethod
- pre-selected (invoked) method.acceptableMediaTypes
- acceptable media types from request.private static boolean usePreSelectedMediaType(MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor selectedMethod, java.util.List<AcceptableMediaType> acceptableMediaTypes)
private boolean isWriteable(MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor candidate)
private boolean isReadable(MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor candidate)
private MethodSelectingRouter.MethodSelector selectMethod(java.util.List<AcceptableMediaType> acceptableMediaTypes, java.util.List<MethodSelectingRouter.ConsumesProducesAcceptor> satisfyingAcceptors, javax.ws.rs.core.MediaType effectiveContentType, boolean singleInvokableMethod)
acceptableMediaTypes
- media types acceptable by the client.satisfyingAcceptors
- pre-computed acceptors.effectiveContentType
- media type of incoming entity.singleInvokableMethod
- flag determining whether only one method to be invoked has been found among satisfying
acceptors.private void reportMethodSelectionAmbiguity(java.util.List<AcceptableMediaType> acceptableTypes, MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor selected, java.util.List<MethodSelectingRouter.RequestSpecificConsumesProducesAcceptor> sameFitnessAcceptors)
private Router createHeadEnrichedRouter()