public static FileDescriptorSource fromString(String name, String protoSource) { return new FileDescriptorSource().addProtoFile(name, protoSource); }
public FileDescriptorSource addProtoFiles(ClassLoader userClassLoader, String... classpathResources) throws IOException { for (String classpathResource : classpathResources) { if (classpathResource == null) { throw new IllegalArgumentException("classpathResource cannot be null"); } // enforce absolute resource path String absPath = classpathResource.startsWith("/") ? classpathResource : "/" + classpathResource; InputStream resourceAsStream = getResourceAsStream(userClassLoader, absPath); if (resourceAsStream == null) { throw new IOException("Resource not found in class path : " + classpathResource); } // discard the leading slash String path = classpathResource.startsWith("/") ? classpathResource.substring(1) : classpathResource; addProtoFile(path, resourceAsStream); } return this; }
public FileDescriptorSource asFileDescriptorSource() throws IOException { FileDescriptorSource source = new FileDescriptorSource(); StringReader stringReader = new StringReader( generateProtoschema() ); source.addProtoFile( "ogm-generated", stringReader ); return source; }
String file = schemas.getProperty(schema); try (FileInputStream in = new FileInputStream(file)) { ctx.registerProtoFiles(new FileDescriptorSource().addProtoFile(schema, in));
/** * Registers proto files and marshallers. * * @param ctx the serialization context * @throws org.infinispan.protostream.DescriptorParserException if a proto definition file fails to parse correctly * @throws IOException if proto file registration fails */ public static void registerMarshallers(SerializationContext ctx) throws IOException { FileDescriptorSource fileDescriptorSource = new FileDescriptorSource(); fileDescriptorSource.addProtoFile(QUERY_PROTO_RES, MarshallerRegistration.class.getResourceAsStream(QUERY_PROTO_RES)); fileDescriptorSource.addProtoFile(MESSAGE_PROTO_RES, MarshallerRegistration.class.getResourceAsStream(MESSAGE_PROTO_RES)); ctx.registerProtoFiles(fileDescriptorSource); ctx.registerMarshaller(new QueryRequest.NamedParameter.Marshaller()); ctx.registerMarshaller(new QueryRequest.Marshaller()); ctx.registerMarshaller(new QueryResponse.Marshaller()); ctx.registerMarshaller(new FilterResult.Marshaller()); ctx.registerMarshaller(new ContinuousQueryResult.ResultType.Marshaller()); ctx.registerMarshaller(new ContinuousQueryResult.Marshaller()); } }
fds.addProtoFile("sample_bank_account/bank.proto", bankSchemaFile); SerializationContext ctx = ProtoStreamMarshaller.getSerializationContext(manager); ctx.registerProtoFiles(fds);