1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.mina.codec.delimited;
21
22 import org.apache.mina.codec.delimited.ints.VarInt;
23 import org.apache.mina.codec.delimited.serialization.ProtobufMessageDecoder;
24
25 import com.google.protobuf.ExtensionRegistryLite;
26 import com.google.protobuf.GeneratedMessage;
27
28
29
30
31
32
33 public class ProtobufDecoder<OUTPUT extends GeneratedMessage> extends
34 SizePrefixedDecoder<OUTPUT> {
35 public static <L extends GeneratedMessage> ProtobufDecoder<L> newInstance(
36 Class<L> clazz, ExtensionRegistryLite registry)
37 throws NoSuchMethodException {
38 return new ProtobufDecoder<L>(clazz, registry);
39 }
40
41 public static <L extends GeneratedMessage> ProtobufDecoder<L> newInstance(
42 Class<L> clazz) throws NoSuchMethodException {
43 return newInstance(clazz, ExtensionRegistryLite.getEmptyRegistry());
44 }
45
46 public ProtobufDecoder(Class<OUTPUT> clazz, ExtensionRegistryLite registry)
47 throws NoSuchMethodException {
48 super(new VarInt().getDecoder(), ProtobufMessageDecoder.newInstance(
49 clazz, registry));
50 }
51 }