com.fasterxml.clustermate.service.http.StreamingEntityImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clustermate-service Show documentation
Show all versions of clustermate-service Show documentation
Building blocks for ClusterMate-based services and servers.
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);
}
}