use of org.apache.cxf.interceptor.FIStaxInInterceptor in project cxf by apache.
the class JAXRSSoapBookTest method testPostGetBookFastinfoset.
@Test
public void testPostGetBookFastinfoset() throws Exception {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress("http://localhost:" + PORT + "/test/services/rest3/bookstore/fastinfoset");
bean.getOutInterceptors().add(new FIStaxOutInterceptor());
bean.getInInterceptors().add(new FIStaxInInterceptor());
JAXBElementProvider<?> p = new JAXBElementProvider<>();
p.setConsumeMediaTypes(Collections.singletonList("application/fastinfoset"));
p.setProduceMediaTypes(Collections.singletonList("application/fastinfoset"));
bean.setProvider(p);
Map<String, Object> props = new HashMap<>();
props.put(FIStaxOutInterceptor.FI_ENABLED, Boolean.TRUE);
bean.setProperties(props);
WebClient client = bean.createWebClient();
Book b = new Book("CXF", 1L);
Book b2 = client.type("application/fastinfoset").accept("application/fastinfoset").post(b, Book.class);
assertEquals(b2.getName(), b.getName());
assertEquals(b2.getId(), b.getId());
}
use of org.apache.cxf.interceptor.FIStaxInInterceptor in project cxf by apache.
the class JAXRSSoapBookTest method testGetBookFastinfoset.
@Test
public void testGetBookFastinfoset() throws Exception {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress("http://localhost:" + PORT + "/test/services/rest3/bookstore/fastinfoset2");
bean.getInInterceptors().add(new FIStaxInInterceptor());
JAXBElementProvider<?> p = new JAXBElementProvider<>();
p.setConsumeMediaTypes(Collections.singletonList("application/fastinfoset"));
bean.setProvider(p);
Map<String, Object> props = new HashMap<>();
props.put(FIStaxInInterceptor.FI_GET_SUPPORTED, Boolean.TRUE);
bean.setProperties(props);
WebClient client = bean.createWebClient();
Book b = client.accept("application/fastinfoset").get(Book.class);
assertEquals("CXF2", b.getName());
assertEquals(2L, b.getId());
}
use of org.apache.cxf.interceptor.FIStaxInInterceptor in project cxf by apache.
the class FastInfosetFeature method initializeProvider.
@Override
protected void initializeProvider(InterceptorProvider provider, Bus bus) {
FIStaxInInterceptor in = new FIStaxInInterceptor();
FIStaxOutInterceptor out = new FIStaxOutInterceptor(force);
if (serializerAttributeValueMapMemoryLimit != null && serializerAttributeValueMapMemoryLimit.intValue() > 0) {
out.setSerializerAttributeValueMapMemoryLimit(serializerAttributeValueMapMemoryLimit);
}
if (serializerMinAttributeValueSize != null && serializerMinAttributeValueSize.intValue() > 0) {
out.setSerializerMinAttributeValueSize(serializerMinAttributeValueSize);
}
if (serializerMaxAttributeValueSize != null && serializerMaxAttributeValueSize.intValue() > 0) {
out.setSerializerMaxAttributeValueSize(serializerMaxAttributeValueSize);
}
if (serializerCharacterContentChunkMapMemoryLimit != null && serializerCharacterContentChunkMapMemoryLimit.intValue() > 0) {
out.setSerializerCharacterContentChunkMapMemoryLimit(serializerCharacterContentChunkMapMemoryLimit);
}
if (serializerMinCharacterContentChunkSize != null && serializerMinCharacterContentChunkSize.intValue() > 0) {
out.setSerializerMinCharacterContentChunkSize(serializerMinCharacterContentChunkSize);
}
if (serializerMaxCharacterContentChunkSize != null && serializerMaxCharacterContentChunkSize.intValue() > 0) {
out.setSerializerMaxCharacterContentChunkSize(serializerMaxCharacterContentChunkSize);
}
provider.getInInterceptors().add(in);
provider.getInFaultInterceptors().add(in);
provider.getOutInterceptors().add(out);
provider.getOutFaultInterceptors().add(out);
}
use of org.apache.cxf.interceptor.FIStaxInInterceptor in project cxf by apache.
the class AnnotationsFactoryBeanListener method addFastInfosetSupport.
private void addFastInfosetSupport(InterceptorProvider provider, FastInfoset annotation) {
if (annotation != null) {
FIStaxInInterceptor in = new FIStaxInInterceptor();
FIStaxOutInterceptor out = new FIStaxOutInterceptor(annotation.force());
out.setSerializerAttributeValueMapMemoryLimit(annotation.serializerAttributeValueMapMemoryLimit());
out.setSerializerMinAttributeValueSize(annotation.serializerMinAttributeValueSize());
out.setSerializerMaxAttributeValueSize(annotation.serializerMaxAttributeValueSize());
out.setSerializerCharacterContentChunkMapMemoryLimit(annotation.serializerCharacterContentChunkMapMemoryLimit());
out.setSerializerMinCharacterContentChunkSize(annotation.serializerMinCharacterContentChunkSize());
out.setSerializerMaxCharacterContentChunkSize(annotation.serializerMaxCharacterContentChunkSize());
provider.getInInterceptors().add(in);
provider.getInFaultInterceptors().add(in);
provider.getOutInterceptors().add(out);
provider.getOutFaultInterceptors().add(out);
}
}
Aggregations