Search in sources :

Example 6 with ByteArrayOutputStream

use of org.fusesource.hawtbuf.ByteArrayOutputStream in project fabric8 by jboss-fuse.

the class WireFormatInfo method beforeMarshall.

public void beforeMarshall(OpenWireFormat wireFormat) throws IOException {
    // Need to marshal the properties.
    if (marshalledProperties == null && properties != null) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream os = new DataOutputStream(baos);
        MarshallingSupport.marshalPrimitiveMap(properties, os);
        os.close();
        marshalledProperties = baos.toBuffer();
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(org.fusesource.hawtbuf.ByteArrayOutputStream)

Example 7 with ByteArrayOutputStream

use of org.fusesource.hawtbuf.ByteArrayOutputStream in project fabric8 by jboss-fuse.

the class ActiveMQObjectMessage method storeContent.

public void storeContent() {
    Buffer bodyAsBytes = getContent();
    if (bodyAsBytes == null && object != null) {
        try {
            ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            OutputStream os = bytesOut;
            if (Settings.enable_compression()) {
                compressed = true;
                os = new DeflaterOutputStream(os);
            }
            DataOutputStream dataOut = new DataOutputStream(os);
            ObjectOutputStream objOut = new ObjectOutputStream(dataOut);
            objOut.writeObject(object);
            objOut.flush();
            objOut.reset();
            objOut.close();
            setContent(bytesOut.toBuffer());
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage(), ioe);
        }
    }
}
Also used : Buffer(org.fusesource.hawtbuf.Buffer) DataOutputStream(java.io.DataOutputStream) OutputStream(java.io.OutputStream) ByteArrayOutputStream(org.fusesource.hawtbuf.ByteArrayOutputStream) DeflaterOutputStream(java.util.zip.DeflaterOutputStream) DataOutputStream(java.io.DataOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) DeflaterOutputStream(java.util.zip.DeflaterOutputStream) ByteArrayOutputStream(org.fusesource.hawtbuf.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Aggregations

ByteArrayOutputStream (org.fusesource.hawtbuf.ByteArrayOutputStream)7 DeflaterOutputStream (java.util.zip.DeflaterOutputStream)5 DataOutputStream (java.io.DataOutputStream)3 Buffer (org.fusesource.hawtbuf.Buffer)2 OpenwireException (io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException)1 IOException (java.io.IOException)1 ObjectOutputStream (java.io.ObjectOutputStream)1 OutputStream (java.io.OutputStream)1 Deflater (java.util.zip.Deflater)1