public static FileDescriptorSource fromString(String name, String protoSource) { return new FileDescriptorSource().addProtoFile(name, protoSource); }
public static FileDescriptorSource fromResources(ClassLoader userClassLoader, String... classPathResources) throws IOException { return new FileDescriptorSource().addProtoFiles(userClassLoader, classPathResources); }
public static FileDescriptorSource fromResources(String... classPathResources) throws IOException { return new FileDescriptorSource().addProtoFiles(classPathResources); }
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));
public InfinispanSessionLegacyConverter (String cacheName) throws Exception { //legacy serialization _legacyManager = new RemoteCacheManager(); _legacyCache = _legacyManager.getCache(cacheName); //new protobuf based String host = System.getProperty("host", "127.0.0.1"); _verbose = Boolean.getBoolean("verbose"); Properties properties = new Properties(); ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); clientBuilder.withProperties(properties).addServer().host(host).marshaller(new ProtoStreamMarshaller()); _protoManager = new RemoteCacheManager(clientBuilder.build()); FileDescriptorSource fds = new FileDescriptorSource(); fds.addProtoFiles("/session.proto"); SerializationContext serCtx = ProtoStreamMarshaller.getSerializationContext(_protoManager); serCtx.registerProtoFiles(fds); serCtx.registerMarshaller(new SessionDataMarshaller()); _protoCache = _protoManager.getCache(cacheName); }
/** * 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()); } }
FileDescriptorSource fds = new FileDescriptorSource(); fds.addProtoFile("sample_bank_account/bank.proto", bankSchemaFile); SerializationContext ctx = ProtoStreamMarshaller.getSerializationContext(manager);