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

colesico.framework.rpc.rpcgear.kryo.KryoClient Maven / Gradle / Ivy

The newest version!
package colesico.framework.rpc.rpcgear.kryo;

import colesico.framework.ioc.production.Polysupplier;
import colesico.framework.rpc.clientapi.RpcEndpointsPrototype;
import colesico.framework.rpc.clientapi.RpcErrorHandlerFactory;
import colesico.framework.rpc.clientapi.RpcRequestHandler;
import colesico.framework.rpc.clientapi.RpcResponseHandler;
import colesico.framework.rpc.rpcgear.httpbase.HttpRpcClient;
import colesico.framework.rpc.rpcgear.httpbase.HttpRpcClientOptionsPrototype;

import javax.inject.Inject;
import javax.inject.Singleton;
import java.io.InputStream;
import java.io.OutputStream;

@Singleton
public class KryoClient extends HttpRpcClient {

    private final KryoSerializer serializer;

    @Inject
    public KryoClient(Polysupplier endpointsConf,
                      Polysupplier options,
                      Polysupplier requestHnd,
                      Polysupplier responseHnd,
                      RpcErrorHandlerFactory errorHndFac,
                      KryoSerializer serializer) {
        super(endpointsConf, options, requestHnd, responseHnd, errorHndFac);
        this.serializer = serializer;
    }

    @Override
    protected  void serialize(T obj, OutputStream os) {
        serializer.serialize(obj, os);
    }

    @Override
    protected  T deserialize(InputStream is, Class type) {
        return serializer.deserialize(is, type);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy