Search in sources :

Example 1 with ContainerRequestContextImpl

use of org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl in project tomee by apache.

the class JAXRSUtils method runContainerResponseFilters.

public static void runContainerResponseFilters(ServerProviderFactory pf, ResponseImpl r, Message m, OperationResourceInfo ori, Method invoked) throws IOException, Throwable {
    List<ProviderInfo<ContainerResponseFilter>> containerFilters = pf.getContainerResponseFilters(ori == null ? null : ori.getNameBindings());
    if (!containerFilters.isEmpty()) {
        ContainerRequestContext requestContext = new ContainerRequestContextImpl(m.getExchange().getInMessage(), false, true);
        ContainerResponseContext responseContext = new ContainerResponseContextImpl(r, m, ori == null ? null : ori.getClassResourceInfo().getServiceClass(), invoked);
        for (ProviderInfo<ContainerResponseFilter> filter : containerFilters) {
            InjectionUtils.injectContexts(filter.getProvider(), filter, m);
            filter.getProvider().filter(requestContext, responseContext);
        }
    }
}
Also used : ContainerResponseFilter(javax.ws.rs.container.ContainerResponseFilter) ProviderInfo(org.apache.cxf.jaxrs.model.ProviderInfo) ContainerRequestContext(javax.ws.rs.container.ContainerRequestContext) ContainerRequestContextImpl(org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl) ContainerResponseContext(javax.ws.rs.container.ContainerResponseContext) ContainerResponseContextImpl(org.apache.cxf.jaxrs.impl.ContainerResponseContextImpl)

Example 2 with ContainerRequestContextImpl

use of org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl in project tomee by apache.

the class JAXRSUtils method runContainerRequestFilters.

public static boolean runContainerRequestFilters(ServerProviderFactory pf, Message m, boolean preMatch, Set<String> names) throws IOException {
    List<ProviderInfo<ContainerRequestFilter>> containerFilters = preMatch ? pf.getPreMatchContainerRequestFilters() : pf.getPostMatchContainerRequestFilters(names);
    if (!containerFilters.isEmpty()) {
        ContainerRequestContext context = new ContainerRequestContextImpl(m, preMatch, false);
        for (ProviderInfo<ContainerRequestFilter> filter : containerFilters) {
            InjectionUtils.injectContexts(filter.getProvider(), filter, m);
            filter.getProvider().filter(context);
            Response response = m.getExchange().get(Response.class);
            if (response != null) {
                setMessageContentType(m, response);
                return true;
            }
        }
    }
    return false;
}
Also used : AsyncResponse(javax.ws.rs.container.AsyncResponse) Response(javax.ws.rs.core.Response) ProviderInfo(org.apache.cxf.jaxrs.model.ProviderInfo) ContainerRequestContext(javax.ws.rs.container.ContainerRequestContext) ContainerRequestContextImpl(org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl) ContainerRequestFilter(javax.ws.rs.container.ContainerRequestFilter)

Example 3 with ContainerRequestContextImpl

use of org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl in project cxf by apache.

the class JAXRSUtils method runContainerRequestFilters.

public static boolean runContainerRequestFilters(ServerProviderFactory pf, Message m, boolean preMatch, Set<String> names) throws IOException {
    List<ProviderInfo<ContainerRequestFilter>> containerFilters = preMatch ? pf.getPreMatchContainerRequestFilters() : pf.getPostMatchContainerRequestFilters(names);
    if (!containerFilters.isEmpty()) {
        ContainerRequestContext context = new ContainerRequestContextImpl(m, preMatch, false);
        for (ProviderInfo<ContainerRequestFilter> filter : containerFilters) {
            InjectionUtils.injectContexts(filter.getProvider(), filter, m);
            filter.getProvider().filter(context);
            Response response = m.getExchange().get(Response.class);
            if (response != null) {
                setMessageContentType(m, response);
                return true;
            }
        }
    }
    return false;
}
Also used : AsyncResponse(javax.ws.rs.container.AsyncResponse) Response(javax.ws.rs.core.Response) ProviderInfo(org.apache.cxf.jaxrs.model.ProviderInfo) ContainerRequestContext(javax.ws.rs.container.ContainerRequestContext) ContainerRequestContextImpl(org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl) ContainerRequestFilter(javax.ws.rs.container.ContainerRequestFilter)

Example 4 with ContainerRequestContextImpl

use of org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl in project cxf by apache.

the class JAXRSUtils method runContainerResponseFilters.

public static void runContainerResponseFilters(ServerProviderFactory pf, ResponseImpl r, Message m, OperationResourceInfo ori, Method invoked) throws IOException, Throwable {
    List<ProviderInfo<ContainerResponseFilter>> containerFilters = pf.getContainerResponseFilters(ori == null ? null : ori.getNameBindings());
    if (!containerFilters.isEmpty()) {
        ContainerRequestContext requestContext = new ContainerRequestContextImpl(m.getExchange().getInMessage(), false, true);
        ContainerResponseContext responseContext = new ContainerResponseContextImpl(r, m, ori == null ? null : ori.getClassResourceInfo().getServiceClass(), invoked);
        for (ProviderInfo<ContainerResponseFilter> filter : containerFilters) {
            InjectionUtils.injectContexts(filter.getProvider(), filter, m);
            filter.getProvider().filter(requestContext, responseContext);
        }
    }
}
Also used : ContainerResponseFilter(javax.ws.rs.container.ContainerResponseFilter) ProviderInfo(org.apache.cxf.jaxrs.model.ProviderInfo) ContainerRequestContext(javax.ws.rs.container.ContainerRequestContext) ContainerRequestContextImpl(org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl) ContainerResponseContext(javax.ws.rs.container.ContainerResponseContext) ContainerResponseContextImpl(org.apache.cxf.jaxrs.impl.ContainerResponseContextImpl)

Aggregations

ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)4 ContainerRequestContextImpl (org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl)4 ProviderInfo (org.apache.cxf.jaxrs.model.ProviderInfo)4 AsyncResponse (javax.ws.rs.container.AsyncResponse)2 ContainerRequestFilter (javax.ws.rs.container.ContainerRequestFilter)2 ContainerResponseContext (javax.ws.rs.container.ContainerResponseContext)2 ContainerResponseFilter (javax.ws.rs.container.ContainerResponseFilter)2 Response (javax.ws.rs.core.Response)2 ContainerResponseContextImpl (org.apache.cxf.jaxrs.impl.ContainerResponseContextImpl)2