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;
}
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;
}
Aggregations