Search in sources :

Example 1 with FIStaxInInterceptor

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());
}
Also used : JAXBElementProvider(org.apache.cxf.jaxrs.provider.JAXBElementProvider) JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) FIStaxInInterceptor(org.apache.cxf.interceptor.FIStaxInInterceptor) HashMap(java.util.HashMap) FIStaxOutInterceptor(org.apache.cxf.interceptor.FIStaxOutInterceptor) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 2 with FIStaxInInterceptor

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());
}
Also used : JAXBElementProvider(org.apache.cxf.jaxrs.provider.JAXBElementProvider) JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) FIStaxInInterceptor(org.apache.cxf.interceptor.FIStaxInInterceptor) HashMap(java.util.HashMap) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 3 with FIStaxInInterceptor

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);
}
Also used : FIStaxInInterceptor(org.apache.cxf.interceptor.FIStaxInInterceptor) FIStaxOutInterceptor(org.apache.cxf.interceptor.FIStaxOutInterceptor)

Example 4 with FIStaxInInterceptor

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);
    }
}
Also used : FIStaxInInterceptor(org.apache.cxf.interceptor.FIStaxInInterceptor) FIStaxOutInterceptor(org.apache.cxf.interceptor.FIStaxOutInterceptor)

Aggregations

FIStaxInInterceptor (org.apache.cxf.interceptor.FIStaxInInterceptor)4 FIStaxOutInterceptor (org.apache.cxf.interceptor.FIStaxOutInterceptor)3 HashMap (java.util.HashMap)2 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)2 WebClient (org.apache.cxf.jaxrs.client.WebClient)2 JAXBElementProvider (org.apache.cxf.jaxrs.provider.JAXBElementProvider)2 Test (org.junit.Test)2