Search in sources :

Example 1 with CachedEncodingTrait

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.CachedEncodingTrait in project fabric8 by jboss-fuse.

the class OpenWireFormat method looseMarshalNestedObject.

public void looseMarshalNestedObject(DataStructure o, DataByteArrayOutputStream dataOut) throws IOException {
    dataOut.writeBoolean(o != null);
    if (o != null) {
        if (o instanceof Message) {
            if (!isTightEncodingEnabled() && !isCacheEnabled()) {
                CachedEncodingTrait encoding = ((Message) o).getCachedEncoding();
                if (encoding != null && !encoding.tight() && encoding.version() == getVersion()) {
                    Buffer buffer = encoding.buffer();
                    dataOut.write(buffer.data, buffer.offset + 4, buffer.length() - 4);
                    return;
                }
            }
        }
        byte type = o.getDataStructureType();
        dataOut.writeByte(type);
        DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[type & 0xFF];
        if (dsm == null) {
            throw new IOException("Unknown data type: " + type);
        }
        dsm.looseMarshal(this, o, dataOut);
    }
}
Also used : Buffer(org.fusesource.hawtbuf.Buffer) Message(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Message) CachedEncodingTrait(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.CachedEncodingTrait) IOException(java.io.IOException)

Aggregations

CachedEncodingTrait (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.CachedEncodingTrait)1 Message (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Message)1 IOException (java.io.IOException)1 Buffer (org.fusesource.hawtbuf.Buffer)1