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

com.hibegin.http.server.handler.RequestEventStorable Maven / Gradle / Ivy

Go to download

Simple, flexible, less dependent, more extended. Less memory footprint, can quickly build Web project. Can quickly run embedded, Android devices

There is a newer version: 0.3.162
Show newest version
package com.hibegin.http.server.handler;

import com.hibegin.common.AbstractStorable;
import com.hibegin.common.util.IOUtil;

import java.io.File;
import java.nio.channels.SelectionKey;

class RequestEventStorable extends AbstractStorable {

    private final SelectionKey selectionKey;

    public RequestEventStorable(SelectionKey key, byte[] requestBytes, String fileName) {
        super(new RequestEvent(key, requestBytes), fileName);
        this.selectionKey = key;
    }

    @Override
    protected long getDataSize(RequestEvent data) {
        return data.getRequestBody().length;
    }

    @Override
    protected File serializeToFile(RequestEvent data, String filePath) {
        File file = new File(filePath + "/" + tempFileName);
        IOUtil.writeBytesToFile(data.getRequestBody(), file);
        return file;
    }

    @Override
    protected RequestEvent deserialize(byte[] bytes) {
        return new RequestEvent(selectionKey, bytes);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy