File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 6
6
import java .io .Reader ;
7
7
import java .net .URL ;
8
8
9
+ import com .fasterxml .jackson .databind .ObjectMapper ;
9
10
import com .fasterxml .jackson .databind .ObjectReader ;
10
11
import com .fasterxml .jackson .dataformat .protobuf .ProtobufMapper ;
11
12
@@ -24,15 +25,30 @@ public class DescriptorLoader
24
25
*/
25
26
protected final ObjectReader _reader ;
26
27
28
+ /**
29
+ * @param reader {@link ObjectReader} that is able to read protobuf input
30
+ * (that is, must have been created from {@link ProtobufMapper}, or regular
31
+ * mapper with {@link com.fasterxml.jackson.dataformat.protobuf.ProtobufFactory}),
32
+ * and has been configured with `protoc` definition of `descriptor.proro`
33
+ */
27
34
public DescriptorLoader (ObjectReader reader ) {
28
35
_reader = reader ;
29
36
}
30
37
31
38
public static DescriptorLoader construct (ProtobufMapper mapper ) throws IOException
39
+ {
40
+ return construct (mapper , mapper .schemaLoader ());
41
+ }
42
+
43
+ /**
44
+ * @param mapper {@link ObjectMapper} that can reader protoc content.
45
+ */
46
+ public static DescriptorLoader construct (ObjectMapper mapper ,
47
+ ProtobufSchemaLoader schemaLoader ) throws IOException
32
48
{
33
49
ProtobufSchema schema ;
34
50
try (InputStream in = DescriptorLoader .class .getResourceAsStream (DESCRIPTOR_PROTO )) {
35
- schema = mapper . schemaLoader () .load (in , "FileDescriptorSet" );
51
+ schema = schemaLoader .load (in , "FileDescriptorSet" );
36
52
}
37
53
return new DescriptorLoader (mapper .readerFor (FileDescriptorSet .class )
38
54
.with (schema ));
You can’t perform that action at this time.
0 commit comments