Java Code Examples for org.infinispan.protostream.SerializationContext#registerProtoFiles()
The following examples show how to use
org.infinispan.protostream.SerializationContext#registerProtoFiles() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HotRodSearchClient.java From apicurio-registry with Apache License 2.0 | 6 votes |
private void registerProto(boolean reset, String... protoKeys) { RemoteCache<Object, Object> cache = manager.getCache(PROTO_CACHE); if (cache == null) { throw new IllegalStateException(String.format("Missing %s cache!", PROTO_CACHE)); } SerializationContext ctx = MarshallerUtil.getSerializationContext(manager); FileDescriptorSource fds = new FileDescriptorSource(); for (String protoKey : protoKeys) { if (reset || !cache.containsKey(protoKey)) { String protoContent = IoUtil.toString(getClass().getResourceAsStream("/" + protoKey)); log.info(String.format("Using proto schema: %s%n%s", protoKey, protoContent)); fds.addProtoFile(protoKey, protoContent); cache.put(protoKey, protoContent); } } ctx.registerProtoFiles(fds); ctx.registerMarshaller(new ArtifactTypeMarshaller()); ctx.registerMarshaller(new ArtifactMarshaller()); }
Example 2
Source File: Bucket4jProtobufContextInitializer.java From bucket4j with Apache License 2.0 | 5 votes |
@Override public void registerSchema(SerializationContext serCtx) { StringBuilder protoBuilder = new StringBuilder(FOOTER); for (SerializationHandle<?> serializationHandle : Bucket4j.getSerializationHandles()) { String typeName = "Bucket4jType_" + serializationHandle.getTypeId(); String typeDefinition = TYPE_TEMPLATE.replace("[type_name]", typeName); protoBuilder.append(typeDefinition); } String generatedProtoFile = protoBuilder.toString(); FileDescriptorSource protoSource = FileDescriptorSource.fromString(getProtoFileName(), generatedProtoFile); serCtx.registerProtoFiles(protoSource); }