Search in sources :

Example 71 with DataStructure

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

the class NetworkBridgeFilterMarshaller method tightMarshal1.

/**
 * Write the booleans that this object uses to a BooleanStream
 */
public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
    NetworkBridgeFilter info = (NetworkBridgeFilter) o;
    int rc = super.tightMarshal1(wireFormat, o, bs);
    rc += tightMarshalCachedObject1(wireFormat, (DataStructure) info.getNetworkBrokerId(), bs);
    return rc + 4;
}
Also used : DataStructure(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.DataStructure) NetworkBridgeFilter(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.NetworkBridgeFilter)

Example 72 with DataStructure

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

the class NetworkBridgeFilterMarshaller method tightMarshal2.

/**
 * Write a object instance to data output stream
 *
 * @param o the instance to be marshaled
 * @param dataOut the output stream
 * @throws IOException thrown if an error occurs
 */
public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataByteArrayOutputStream dataOut, BooleanStream bs) throws IOException {
    super.tightMarshal2(wireFormat, o, dataOut, bs);
    NetworkBridgeFilter info = (NetworkBridgeFilter) o;
    dataOut.writeInt(info.getNetworkTTL());
    tightMarshalCachedObject2(wireFormat, (DataStructure) info.getNetworkBrokerId(), dataOut, bs);
}
Also used : NetworkBridgeFilter(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.NetworkBridgeFilter)

Example 73 with DataStructure

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

the class BaseDataStreamMarshaller method looseUnmarsalCachedObject.

protected DataStructure looseUnmarsalCachedObject(OpenWireFormat wireFormat, DataByteArrayInputStream dataIn) throws IOException {
    if (wireFormat.isCacheEnabled()) {
        if (dataIn.readBoolean()) {
            short index = dataIn.readShort();
            DataStructure object = wireFormat.looseUnmarshalNestedObject(dataIn);
            wireFormat.setInUnmarshallCache(index, object);
            return object;
        } else {
            short index = dataIn.readShort();
            return wireFormat.getFromUnmarshallCache(index);
        }
    } else {
        return wireFormat.looseUnmarshalNestedObject(dataIn);
    }
}
Also used : DataStructure(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.DataStructure)

Example 74 with DataStructure

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

the class BaseDataStreamMarshaller method tightUnmarsalCachedObject.

protected DataStructure tightUnmarsalCachedObject(OpenWireFormat wireFormat, DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException {
    if (wireFormat.isCacheEnabled()) {
        if (bs.readBoolean()) {
            short index = dataIn.readShort();
            DataStructure object = wireFormat.tightUnmarshalNestedObject(dataIn, bs);
            wireFormat.setInUnmarshallCache(index, object);
            return object;
        } else {
            short index = dataIn.readShort();
            return wireFormat.getFromUnmarshallCache(index);
        }
    } else {
        return wireFormat.tightUnmarshalNestedObject(dataIn, bs);
    }
}
Also used : DataStructure(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.DataStructure)

Example 75 with DataStructure

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.DataStructure 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

DataStructure (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.DataStructure)30 IOException (java.io.IOException)7 Message (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Message)6 DataResponse (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.DataResponse)5 RemoveInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.RemoveInfo)5 BrokerInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerInfo)3 ConnectionError (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.ConnectionError)3 ConnectionInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.ConnectionInfo)3 ConsumerControl (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.ConsumerControl)3 ConsumerInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.ConsumerInfo)3 DestinationInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.DestinationInfo)3 LocalTransactionId (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.LocalTransactionId)3 MessageAck (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.MessageAck)3 MessageDispatch (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.MessageDispatch)3 MessageDispatchNotification (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.MessageDispatchNotification)3 MessageId (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.MessageId)3 NetworkBridgeFilter (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.NetworkBridgeFilter)3 ProducerInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.ProducerInfo)3 RemoveSubscriptionInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.RemoveSubscriptionInfo)3 SessionInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.SessionInfo)3