Search in sources :

Example 1 with AbstractConfigurableProvider

use of org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider in project cxf by apache.

the class JAXRSOutInterceptor method checkBufferingMode.

private boolean checkBufferingMode(Message m, List<WriterInterceptor> writers, boolean firstTry) {
    if (!firstTry) {
        return false;
    }
    WriterInterceptor last = writers.get(writers.size() - 1);
    MessageBodyWriter<Object> w = ((WriterInterceptorMBW) last).getMBW();
    Object outBuf = m.getContextualProperty(OUT_BUFFERING);
    boolean enabled = PropertyUtils.isTrue(outBuf);
    boolean configurableProvider = w instanceof AbstractConfigurableProvider;
    if (!enabled && outBuf == null && configurableProvider) {
        enabled = ((AbstractConfigurableProvider) w).getEnableBuffering();
    }
    if (enabled) {
        boolean streamingOn = configurableProvider && ((AbstractConfigurableProvider) w).getEnableStreaming();
        if (streamingOn) {
            m.setContent(XMLStreamWriter.class, new CachingXmlEventWriter());
        } else {
            m.setContent(OutputStream.class, new CachedOutputStream());
        }
    }
    return enabled;
}
Also used : WriterInterceptor(javax.ws.rs.ext.WriterInterceptor) WriterInterceptorMBW(org.apache.cxf.jaxrs.impl.WriterInterceptorMBW) AbstractConfigurableProvider(org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider) CachingXmlEventWriter(org.apache.cxf.staxutils.CachingXmlEventWriter) CachedOutputStream(org.apache.cxf.io.CachedOutputStream)

Example 2 with AbstractConfigurableProvider

use of org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider in project tomee by apache.

the class JAXRSOutInterceptor method checkBufferingMode.

private boolean checkBufferingMode(Message m, List<WriterInterceptor> writers, boolean firstTry) {
    if (!firstTry) {
        return false;
    }
    WriterInterceptor last = writers.get(writers.size() - 1);
    MessageBodyWriter<Object> w = ((WriterInterceptorMBW) last).getMBW();
    Object outBuf = m.getContextualProperty(OUT_BUFFERING);
    boolean enabled = PropertyUtils.isTrue(outBuf);
    boolean configurableProvider = w instanceof AbstractConfigurableProvider;
    if (!enabled && outBuf == null && configurableProvider) {
        enabled = ((AbstractConfigurableProvider) w).getEnableBuffering();
    }
    if (enabled) {
        boolean streamingOn = configurableProvider && ((AbstractConfigurableProvider) w).getEnableStreaming();
        if (streamingOn) {
            m.setContent(XMLStreamWriter.class, new CachingXmlEventWriter());
        } else {
            m.setContent(OutputStream.class, new CachedOutputStream());
        }
    }
    return enabled;
}
Also used : WriterInterceptor(javax.ws.rs.ext.WriterInterceptor) WriterInterceptorMBW(org.apache.cxf.jaxrs.impl.WriterInterceptorMBW) AbstractConfigurableProvider(org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider) CachingXmlEventWriter(org.apache.cxf.staxutils.CachingXmlEventWriter) CachedOutputStream(org.apache.cxf.io.CachedOutputStream)

Aggregations

WriterInterceptor (javax.ws.rs.ext.WriterInterceptor)2 CachedOutputStream (org.apache.cxf.io.CachedOutputStream)2 WriterInterceptorMBW (org.apache.cxf.jaxrs.impl.WriterInterceptorMBW)2 AbstractConfigurableProvider (org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider)2 CachingXmlEventWriter (org.apache.cxf.staxutils.CachingXmlEventWriter)2