1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.kryo;
15
16 import ch.qos.logback.classic.spi.LoggerContextVO;
17 import com.esotericsoftware.kryo.kryo5.Kryo;
18 import com.esotericsoftware.kryo.kryo5.Serializer;
19 import com.esotericsoftware.kryo.kryo5.io.Input;
20 import com.esotericsoftware.kryo.kryo5.io.Output;
21
22 import java.util.Map;
23
24
25
26
27
28
29
30
31 public class VanillaLoggerContextVOSerializer extends Serializer<LoggerContextVO> {
32
33 @Override
34 public void write(Kryo kryo, Output output, LoggerContextVO loggerContextVO) {
35 output.writeString(loggerContextVO.getName());
36 output.writeVarLong(loggerContextVO.getBirthTime(), false);
37 kryo.writeClassAndObject(output, loggerContextVO.getPropertyMap());
38 }
39
40 @Override
41 @SuppressWarnings("unchecked")
42 public LoggerContextVO read(Kryo kryo, Input input, Class<? extends LoggerContextVO> type) {
43 String name = input.readString();
44 long birthTime = input.readVarLong(false);
45 Map<String, String> propertyMap = (Map<String, String>) kryo.readClassAndObject(input);
46 return new LoggerContextVO(name, propertyMap, birthTime);
47 }
48 }