All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.clustermate.service.http.StreamingEntityImpl Maven / Gradle / Ivy

There is a newer version: 0.10.5
Show newest version
package com.fasterxml.clustermate.service.http;

import java.io.IOException;
import java.io.OutputStream;

import com.fasterxml.jackson.databind.ObjectWriter;

import com.fasterxml.clustermate.service.msg.StreamingResponseContent;

public class StreamingEntityImpl
    implements StreamingResponseContent
{
    protected final ObjectWriter _objectWriter;
    protected final Object _entity;

    public StreamingEntityImpl(ObjectWriter objectWriter, Object e)
    {
        _objectWriter = objectWriter;
        _entity = e;
    }

    /**
     * Generally we do not know it: could do buffering if we really
     * cared to check it for smallish responses.
     */
    @Override
    public long getLength() {
        return -1L;
    }

    @Override
    public void writeContent(OutputStream out) throws IOException
    {
        _objectWriter.writeValue(out, _entity);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy