Package javax.ws.rs.ext

Examples of javax.ws.rs.ext.MessageBodyWriter.writeTo()


                        ReflectionHelper.objectToString(p)));
            }

            if (out == null)
                out = new CommittingOutputStream(size);
            p.writeTo(entity, entity.getClass(), entityType,
                    annotations, contentType, getHttpHeaders(),
                    out);
            if (!isCommitted) {
                isCommitted = true;
                responseWriter.writeStatusAndHeaders(-1, this);
View Full Code Here


            }
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("Response EntityProvider is: " + writer.getClass().getName());
            }
            try {
                writer.writeTo(entity, targetType, genericType,
                               annotations,
                               responseType,
                               responseHeaders,
                               message.getContent(OutputStream.class));
               
View Full Code Here

       
        MessageBodyWriter mbw = ProviderFactory.getInstance(outMessage).createMessageBodyWriter(
            cls, type, anns, contentType, outMessage);
        if (mbw != null) {
            try {
                mbw.writeTo(o, cls, type, anns, contentType, headers, os);
                if (os != null) {
                    os.flush();
                }
            } catch (Exception ex) {
                reportMessageHandlerProblem("MSG_WRITER_PROBLEM", cls, contentType, ex, null);
View Full Code Here

            if (writer == null) {
                throw new RuntimeException(String.format("No writer for type %s and media type %s",
                                                         String.valueOf(type),
                                                         contentType));
            }
            writer.writeTo(entity,
                           type,
                           genericType,
                           null,
                           contentMediaType,
                           request.getHeaders(),
View Full Code Here

            }
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("Response EntityProvider is: " + writer.getClass().getName());
            }
            try {
                writer.writeTo(entity, targetType, genericType,
                               annotations,
                               responseType,
                               responseHeaders,
                               message.getContent(OutputStream.class));
               
View Full Code Here

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @Test
    public void testWriteTo() throws Exception {
        MessageBodyWriter p = new BinaryDataProvider();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        p.writeTo(new byte[]{'h', 'i'}, null, null, null, null, null, os);
        assertTrue(Arrays.equals(new String("hi").getBytes(), os.toByteArray()));
        ByteArrayInputStream is = new ByteArrayInputStream("hi".getBytes());
        os = new ByteArrayOutputStream();
        p.writeTo(is, null, null, null, null, null, os);
        assertTrue(Arrays.equals(os.toByteArray(), new String("hi").getBytes()));
View Full Code Here

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        p.writeTo(new byte[]{'h', 'i'}, null, null, null, null, null, os);
        assertTrue(Arrays.equals(new String("hi").getBytes(), os.toByteArray()));
        ByteArrayInputStream is = new ByteArrayInputStream("hi".getBytes());
        os = new ByteArrayOutputStream();
        p.writeTo(is, null, null, null, null, null, os);
        assertTrue(Arrays.equals(os.toByteArray(), new String("hi").getBytes()));
       
        Reader r = new StringReader("hi");
        os = new ByteArrayOutputStream();
        p.writeTo(r, null, null, null, MediaType.valueOf("text/xml"), null, os);
View Full Code Here

        p.writeTo(is, null, null, null, null, null, os);
        assertTrue(Arrays.equals(os.toByteArray(), new String("hi").getBytes()));
       
        Reader r = new StringReader("hi");
        os = new ByteArrayOutputStream();
        p.writeTo(r, null, null, null, MediaType.valueOf("text/xml"), null, os);
        assertTrue(Arrays.equals(os.toByteArray(), new String("hi").getBytes()));
       
        os = new ByteArrayOutputStream();
        p.writeTo(new StreamingOutputImpl(), null, null, null,
                  MediaType.valueOf("text/xml"), null, os);
View Full Code Here

        os = new ByteArrayOutputStream();
        p.writeTo(r, null, null, null, MediaType.valueOf("text/xml"), null, os);
        assertTrue(Arrays.equals(os.toByteArray(), new String("hi").getBytes()));
       
        os = new ByteArrayOutputStream();
        p.writeTo(new StreamingOutputImpl(), null, null, null,
                  MediaType.valueOf("text/xml"), null, os);
        assertTrue(Arrays.equals(os.toByteArray(), new String("hi").getBytes()));
    }

   
View Full Code Here

            mbw = ProviderFactory.getInstance().createMessageBodyWriter(
                      cls, type, anns, contentType, m);
        }
        if (mbw != null) {
            try {
                mbw.writeTo(o, cls, type, anns, contentType, headers, os);
                os.flush();
            } catch (Exception ex) {
                throw new WebApplicationException();
            }
            
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.