I have a method that registers classes for serialization. I want to call this from a control class, something like:
public static void main(String[] args) {
Registrar.RegisterClass(Control.SomeRequest);
Registrar.RegisterClass(Control.SomeResponse);
Sender testServer = new Sender();
Receiver testClient = new Receiver();
testServer.StartServer();
testClient.StartClient();
}
public static class SomeRequest {
public String text;
}
public static class SomeResponse {
public String text;
}
---------------------------------------------
public class Registrar {
static Kryo kryo = client.getKryo();
public static void RegisterClass(??? cls){
kryo.register(cls.class);
}
}
Alternatively, I could pass in Control.SomeRequest.class
just as easy, though I'm not sure how to achieve either of these.
The class name of "classes" is Class
public static void RegisterClass(Class cls){
kryo.register(cls);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.