Package org.apache.cxf.jaxrs.impl

Examples of org.apache.cxf.jaxrs.impl.ProvidersImpl


    private org.dom4j.Document readXML() throws Exception {
        return readXML(MediaType.APPLICATION_XML_TYPE, "<a/>");
    }
    private org.dom4j.Document readXML(MediaType ct, final String xml) throws Exception {
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessage()));
        org.dom4j.Document dom = p.readFrom(org.dom4j.Document.class, org.dom4j.Document.class,
            new Annotation[] {}, ct, new MetadataMap<String, String>(),
            new ByteArrayInputStream(xml.getBytes("UTF-8")));
        return dom;
    }
View Full Code Here


   
    @Test
    public void testReadJSONConvertToXML() throws Exception {
        final String xml = "{\"a\":{\"b\":2}}";
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessage()));
        org.dom4j.Document dom = p.readFrom(org.dom4j.Document.class, org.dom4j.Document.class,
                   new Annotation[]{}, MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, String>(),
                   new ByteArrayInputStream(xml.getBytes("UTF-8")));
        String str = dom.asXML();
        // starts with the xml PI
View Full Code Here

    }
   
    private void doTestWriteXML(MediaType ct) throws Exception {
        org.dom4j.Document dom = readXML(ct, "<a/>");
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessage()));
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(dom, org.dom4j.Document.class, org.dom4j.Document.class,
            new Annotation[]{}, ct, new MetadataMap<String, Object>(), bos);
        String str = bos.toString();
View Full Code Here

   
    @Test
    public void testWriteJSON() throws Exception {
        org.dom4j.Document dom = readXML();
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessage()));
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(dom, org.dom4j.Document.class, org.dom4j.Document.class,
                   new Annotation[]{}, MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
                   bos);
View Full Code Here

   
    @Test
    public void testWriteJSONDropRoot() throws Exception {
        org.dom4j.Document dom = readXML(MediaType.APPLICATION_XML_TYPE, "<root><a/></root>");
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessageWithJSONProvider()));
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(dom, org.dom4j.Document.class, org.dom4j.Document.class,
                   new Annotation[]{}, MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
                   bos);
View Full Code Here

        List<Attachment> newAttachments = new LinkedList<Attachment>();
        try {
            Attachment first = new Attachment(AttachmentUtil.createAttachment(
                                     inMessage.getContent(InputStream.class),
                                     (InternetHeaders)inMessage.get(InternetHeaders.class.getName())),
                                     new ProvidersImpl(inMessage));
            newAttachments.add(first);
        } catch (IOException ex) {
            throw new WebApplicationException(500);
        }
       
   
        Collection<org.apache.cxf.message.Attachment> childAttachments = inMessage.getAttachments();
        if (childAttachments == null) {
            childAttachments = Collections.emptyList();
        }
        childAttachments.size();
        for (org.apache.cxf.message.Attachment a : childAttachments) {
            newAttachments.add(new Attachment(a, new ProvidersImpl(inMessage)));
        }
        MediaType mt = embeddedAttachment
            ? (MediaType)inMessage.get("org.apache.cxf.multipart.embedded.ctype")
            : getHttpHeaders().getMediaType();
        MultipartBody body = new MultipartBody(newAttachments, mt, false);
View Full Code Here

            o = new RequestImpl(contextMessage);
        } else if (SecurityContext.class.isAssignableFrom(clazz)) {
            SecurityContext customContext = contextMessage.get(SecurityContext.class);
            o = customContext == null ? new SecurityContextImpl(contextMessage) : customContext;
        } else if (Providers.class.isAssignableFrom(clazz)) {
            o = new ProvidersImpl(contextMessage);
        } else if (ContextResolver.class.isAssignableFrom(clazz)) {
            o = createContextResolver(genericType, contextMessage);
        } else if (MessageContext.class.isAssignableFrom(clazz)) {
            o = new MessageContextImpl(m);
        } else if (Application.class.isAssignableFrom(clazz)) {
View Full Code Here

        List<Attachment> newAttachments = new LinkedList<Attachment>();
        try {
            Attachment first = new Attachment(AttachmentUtil.createAttachment(
                                     inMessage.getContent(InputStream.class),
                                     (InternetHeaders)inMessage.get(InternetHeaders.class.getName())),
                                     new ProvidersImpl(inMessage));
            newAttachments.add(first);
        } catch (IOException ex) {
            throw new WebApplicationException(500);
        }
       
   
        Collection<org.apache.cxf.message.Attachment> childAttachments = inMessage.getAttachments();
        if (childAttachments == null) {
            childAttachments = Collections.emptyList();
        }
        childAttachments.size();
        for (org.apache.cxf.message.Attachment a : childAttachments) {
            newAttachments.add(new Attachment(a, new ProvidersImpl(inMessage)));
        }
        MediaType mt = embeddedAttachment
            ? (MediaType)inMessage.get("org.apache.cxf.multipart.embedded.ctype")
            : getHttpHeaders().getMediaType();
        MultipartBody body = new MultipartBody(newAttachments, mt, false);
View Full Code Here

        } else if (ResourceContext.class.isAssignableFrom(clazz)) {
            o = new ResourceContextImpl(contextMessage.getExchange().get(OperationResourceInfo.class));
        } else if (Request.class.isAssignableFrom(clazz)) {
            o = new RequestImpl(contextMessage);
        } else if (Providers.class.isAssignableFrom(clazz)) {
            o = new ProvidersImpl(contextMessage);
        } else if (ContextResolver.class.isAssignableFrom(clazz)) {
            o = createContextResolver(genericType, contextMessage);
        } else if (Application.class.isAssignableFrom(clazz)) {
            ProviderInfo<?> providerInfo =
                (ProviderInfo<?>)contextMessage.getExchange().getEndpoint().get(Application.class.getName());
View Full Code Here

    private org.dom4j.Document readXML() throws Exception {
        return readXML(MediaType.APPLICATION_XML_TYPE, "<a/>");
    }
    private org.dom4j.Document readXML(MediaType ct, final String xml) throws Exception {
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessage()));
        org.dom4j.Document dom = p.readFrom(org.dom4j.Document.class, org.dom4j.Document.class,
            new Annotation[] {}, ct, new MetadataMap<String, String>(),
            new ByteArrayInputStream(xml.getBytes("UTF-8")));
        return dom;
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.impl.ProvidersImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.