Search in sources :

Example 6 with ConstrainedTo

use of jakarta.ws.rs.ConstrainedTo in project resteasy by resteasy.

the class ServerHelper method processProviderContracts.

protected void processProviderContracts(Class provider, Integer priorityOverride, boolean isBuiltin, Map<Class<?>, Integer> contracts, Map<Class<?>, Integer> newContracts) {
    ConstrainedTo constrainedTo = (ConstrainedTo) provider.getAnnotation(ConstrainedTo.class);
    if (constrainedTo != null && constrainedTo.value() != RuntimeType.SERVER)
        return;
    super.processProviderContracts(provider, priorityOverride, isBuiltin, contracts, newContracts);
    if (Utils.isA(provider, ContainerRequestFilter.class, contracts)) {
        int priority = Utils.getPriority(priorityOverride, contracts, ContainerRequestFilter.class, provider);
        addContainerRequestFilter(provider, priority);
        newContracts.put(ContainerRequestFilter.class, priority);
    }
    if (Utils.isA(provider, ContainerResponseFilter.class, contracts)) {
        int priority = Utils.getPriority(priorityOverride, contracts, ContainerResponseFilter.class, provider);
        addContainerResponseFilter(provider, priority);
        newContracts.put(ContainerResponseFilter.class, priority);
    }
    if (Utils.isA(provider, AsyncResponseProvider.class, contracts)) {
        try {
            addAsyncResponseProvider(provider);
            newContracts.put(AsyncResponseProvider.class, Utils.getPriority(priorityOverride, contracts, AsyncResponseProvider.class, provider));
        } catch (Exception e) {
            throw new RuntimeException(Messages.MESSAGES.unableToInstantiateAsyncResponseProvider(), e);
        }
    }
    if (Utils.isA(provider, AsyncStreamProvider.class, contracts)) {
        try {
            addAsyncStreamProvider(provider);
            newContracts.put(AsyncStreamProvider.class, Utils.getPriority(priorityOverride, contracts, AsyncStreamProvider.class, provider));
        } catch (Exception e) {
            throw new RuntimeException(Messages.MESSAGES.unableToInstantiateAsyncStreamProvider(), e);
        }
    }
    if (Utils.isA(provider, ExceptionMapper.class, contracts)) {
        try {
            addExceptionMapper(provider, isBuiltin);
            newContracts.put(ExceptionMapper.class, Utils.getPriority(priorityOverride, contracts, ExceptionMapper.class, provider));
        } catch (Exception e) {
            throw new RuntimeException(Messages.MESSAGES.unableToInstantiateExceptionMapper(), e);
        }
    }
}
Also used : ConstrainedTo(jakarta.ws.rs.ConstrainedTo) AsyncStreamProvider(org.jboss.resteasy.spi.AsyncStreamProvider) ExceptionMapper(jakarta.ws.rs.ext.ExceptionMapper) AsyncResponseProvider(org.jboss.resteasy.spi.AsyncResponseProvider)

Aggregations

ConstrainedTo (jakarta.ws.rs.ConstrainedTo)6 ThreadContexts (org.jboss.resteasy.spi.concurrent.ThreadContexts)2 RuntimeType (jakarta.ws.rs.RuntimeType)1 ClientRequestFilter (jakarta.ws.rs.client.ClientRequestFilter)1 ClientResponseFilter (jakarta.ws.rs.client.ClientResponseFilter)1 ContainerRequestFilter (jakarta.ws.rs.container.ContainerRequestFilter)1 ContainerResponseFilter (jakarta.ws.rs.container.ContainerResponseFilter)1 DynamicFeature (jakarta.ws.rs.container.DynamicFeature)1 Feature (jakarta.ws.rs.core.Feature)1 MediaType (jakarta.ws.rs.core.MediaType)1 ExceptionMapper (jakarta.ws.rs.ext.ExceptionMapper)1 ParamConverterProvider (jakarta.ws.rs.ext.ParamConverterProvider)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 AsyncClientResponseProvider (org.jboss.resteasy.spi.AsyncClientResponseProvider)1 AsyncResponseProvider (org.jboss.resteasy.spi.AsyncResponseProvider)1 AsyncStreamProvider (org.jboss.resteasy.spi.AsyncStreamProvider)1 ThreadContext (org.jboss.resteasy.spi.concurrent.ThreadContext)1 FeatureContextDelegate (org.jboss.resteasy.util.FeatureContextDelegate)1