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

de.ruedigermoeller.fastcast.remoting.FCSendContext Maven / Gradle / Ivy

There is a newer version: 3.10
Show newest version
package de.ruedigermoeller.fastcast.remoting;

import de.ruedigermoeller.heapoff.bytez.Bytez;
import de.ruedigermoeller.heapoff.bytez.onheap.HeapBytez;

/**
 * Created with IntelliJ IDEA.
 * User: moelrue
 * Date: 8/8/13
 * Time: 11:47 AM
 * To change this template use File | Settings | File Templates.
 */
public class FCSendContext {

    private long longFlowHeader;

    public static FCSendContext get() {
        return context.get();
    }

    static ThreadLocal context = new ThreadLocal() {
        @Override
        protected FCSendContext initialValue() {
            return new FCSendContext();
        }
    };

    String receiver;
    byte flowHeader[];

    public byte[] getFlowHeader() {
        return flowHeader;
    }

    /**
     * set a tag which can be used by the FSTTopicService.readAndFilter method for fast filtering
     * @param flowHeader
     */
    public void setFlowHeader(byte[] flowHeader) {
        this.flowHeader = flowHeader;
    }

    Bytez intTmp = new HeapBytez(new byte[4]); // cache
    Bytez longTmp = new HeapBytez(new byte[8]); // cache

    public void setIntFlowHeader(int flowHeader) {
        intTmp.putInt(0, flowHeader);
        this.flowHeader = intTmp.asByteArray();
    }

    public void setLongFlowHeader(long longFlowHeader) {
        longTmp.putLong(0, longFlowHeader);
        this.flowHeader = longTmp.asByteArray();
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public void reset() {
        receiver = null;
        flowHeader = null;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy