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

com.jn.agileway.codec.serialization.kryo.customizer.CGLibProxyKryoCustomizer Maven / Gradle / Ivy

Go to download

Provide an unified codec API for hession, kryo, protostuff, fst, fes, xson, cbor, jackson, json, etc....

There is a newer version: 3.1.12
Show newest version
package com.jn.agileway.codec.serialization.kryo.customizer;

import com.esotericsoftware.kryo.Kryo;
import com.jn.agileway.codec.serialization.kryo.KryoCustomizer;
import com.jn.langx.util.ClassLoaders;
import de.javakaffee.kryoserializers.cglib.CGLibProxySerializer;

public class CGLibProxyKryoCustomizer implements KryoCustomizer {
    @Override
    public String getName() {
        return "cglib_proxy";
    }

    @Override
    public void customize(Kryo kryo) {
        if (isCglibFound()) {
            kryo.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer());
        }
    }

    private boolean isCglibFound() {
        try {
            Class c = ClassLoaders.loadClass("net.sf.cglib.proxy.Enhancer");
            return c != null;
        } catch (ClassNotFoundException ex) {
            return false;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy