diff --git a/grpc/flatbuffers-java-grpc/pom.xml b/grpc/flatbuffers-java-grpc/pom.xml
new file mode 100644
index 000000000..11aa0bd1b
--- /dev/null
+++ b/grpc/flatbuffers-java-grpc/pom.xml
@@ -0,0 +1,42 @@
+
+
+ 4.0.0
+
+ com.google.flatbuffers
+ flatbuffers-parent
+ 1.8.0
+
+ flatbuffers-java-grpc
+ ${project.artifactId}
+ bundle
+
+ Utilities supporting generated code for GRPC
+
+
+
+ Wouter van Oortmerssen
+
+
+ Yuri Finkelstein
+ https://github.com/yfinkelstein
+
+
+
+ 1.8.0
+
+
+
+ com.google.flatbuffers
+ flatbuffers-java
+ ${project.parent.version}
+
+
+ io.grpc
+ grpc-core
+ ${gRPC.version}
+
+
+
+
diff --git a/grpc/flatbuffers-java-grpc/src/main/java/com/google/flatbuffers/grpc/FlatbuffersUtils.java b/grpc/flatbuffers-java-grpc/src/main/java/com/google/flatbuffers/grpc/FlatbuffersUtils.java
new file mode 100644
index 000000000..768708b11
--- /dev/null
+++ b/grpc/flatbuffers-java-grpc/src/main/java/com/google/flatbuffers/grpc/FlatbuffersUtils.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2014 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.flatbuffers.grpc;
+
+import com.google.flatbuffers.Table;
+import io.grpc.Drainable;
+import io.grpc.KnownLength;
+import io.grpc.MethodDescriptor;
+
+import javax.annotation.Nullable;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+
+public class FlatbuffersUtils {
+ abstract public static class FBExtactor {
+ T extract (InputStream stream) throws IOException {
+ if (stream instanceof KnownLength) {
+ int size = stream.available();
+ ByteBuffer buffer = ByteBuffer.allocate(size);
+ stream.read(buffer.array());
+ return extract(buffer);
+ } else
+ throw new RuntimeException("The class " + stream.getClass().getCanonicalName() + " does not extend from KnownLength ");
+ }
+
+ public abstract T extract(ByteBuffer buffer);
+
+ }
+
+ static class FBInputStream extends InputStream implements Drainable, KnownLength {
+ private final ByteBuffer buffer;
+ private final int size;
+ @Nullable private ByteArrayInputStream inputStream;
+
+ FBInputStream(ByteBuffer buffer) {
+ this.buffer = buffer;
+ this.size = buffer.remaining();
+ }
+
+ private void makeStreamIfNotAlready() {
+ if (inputStream == null)
+ inputStream = new ByteArrayInputStream(buffer.array(), buffer.position(), size);
+ }
+
+ @Override
+ public int drainTo(OutputStream target) throws IOException {
+ target.write(buffer.array(), buffer.position(), size);
+ return size;
+ }
+
+ @Override
+ public int read() throws IOException {
+ makeStreamIfNotAlready();
+ return inputStream.read();
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ makeStreamIfNotAlready();
+ if (inputStream == null) {
+ if (len >= size) {
+ System.arraycopy(buffer.array(), buffer.position(), b, off, size);
+ return size;
+ } else {
+ makeStreamIfNotAlready();
+ return inputStream.read(b, off, len);
+ }
+ } else
+ return inputStream.read(b, off, len);
+ }
+
+ @Override
+ public int available() throws IOException {
+ return inputStream == null ? size : inputStream.available();
+ }
+
+ }
+
+ public static MethodDescriptor.Marshaller marshaller(final Class clazz, final FBExtactor extractor) {
+ return new MethodDescriptor.ReflectableMarshaller() {
+ @Override
+ public Class getMessageClass() {
+ return clazz;
+ }
+
+ @Override
+ public InputStream stream(T value) {
+ return new FBInputStream (value.getByteBuffer());
+ }
+
+ @Override
+ public T parse(InputStream stream) {
+ try {
+ return extractor.extract(stream);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ }
+}
diff --git a/grpc/pom.xml b/grpc/pom.xml
new file mode 100644
index 000000000..b43369e35
--- /dev/null
+++ b/grpc/pom.xml
@@ -0,0 +1,213 @@
+
+ 4.0.0
+ com.google.flatbuffers
+ flatbuffers-parent
+ pom
+ 1.8.0
+ flatbuffers-parent
+ parent pom for flatbuffers java artifacts
+
+ https://github.com/google/flatbuffers
+ scm:git:${scm.url}.git
+ UTF-8
+
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ GitHub
+ https://github.com/google/flatbuffers/issues
+
+
+
+
+ Wouter van Oortmerssen
+
+
+
+ ${scm.url}
+
+
+ ${scm.connection}
+ ${scm.connection}
+ ${scm.url}
+ HEAD
+
+
+
+
+ ossrh
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+
+
+ kr.motd.maven
+ os-maven-plugin
+ 1.5.0.Final
+
+
+
+
+
+ maven-compiler-plugin
+ 3.6.1
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ maven-source-plugin
+ 3.0.1
+
+
+ maven-surefire-plugin
+ 2.19.1
+
+
+ maven-javadoc-plugin
+ 2.10.4
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.12
+
+
+ maven-dependency-plugin
+ 2.8
+
+
+ maven-deploy-plugin
+ 2.7
+
+
+ maven-gpg-plugin
+ 1.5
+
+
+ maven-release-plugin
+ 2.5.3
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.5.0
+
+
+
+
+
+
+ maven-compiler-plugin
+
+ 1.6
+ 1.6
+
+
+
+ maven-surefire-plugin
+
+
+ **/*Test.java
+
+
+
+
+ maven-source-plugin
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+ maven-javadoc-plugin
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ 3.0.1
+ true
+
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.7
+ true
+
+ ossrh
+ https://oss.sonatype.org/
+ true
+
+
+
+ maven-gpg-plugin
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+
+
+ maven-release-plugin
+
+ true
+ false
+ release
+ deploy
+
+
+
+
+
+
+
+ flatbuffers-java-grpc
+
+
+
diff --git a/grpc/tests/JavaGrpcTest.java b/grpc/tests/JavaGrpcTest.java
new file mode 100644
index 000000000..6ae6995b4
--- /dev/null
+++ b/grpc/tests/JavaGrpcTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2014 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import MyGame.Example.Monster;
+import MyGame.Example.MonsterStorageGrpc;
+import MyGame.Example.Stat;
+import com.google.flatbuffers.FlatBufferBuilder;
+import io.grpc.ManagedChannel;
+import io.grpc.ManagedChannelBuilder;
+import io.grpc.Server;
+import io.grpc.ServerBuilder;
+import org.junit.Assert;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Iterator;
+
+
+/**
+ * Demonstrates basic client-server interaction using grpc-java over netty.
+ */
+public class JavaGrpcTest {
+ static final String BIG_MONSTER_NAME = "big-monster";
+ static final short nestedMonsterHp = 600;
+ static final short nestedMonsterMana = 1024;
+ static final int numStreamedMsgs = 10;
+
+ static class MyService extends MonsterStorageGrpc.MonsterStorageImplBase {
+ @Override
+ public void store(Monster request, io.grpc.stub.StreamObserver responseObserver) {
+ Assert.assertEquals(request.name(), BIG_MONSTER_NAME);
+ Assert.assertEquals(request.hp(), nestedMonsterHp);
+ Assert.assertEquals(request.mana(), nestedMonsterMana);
+ System.out.println("Received store request from " + request.name());
+ // Create a response from the incoming request name.
+ FlatBufferBuilder builder = new FlatBufferBuilder();
+ int statOffset = Stat.createStat(builder, builder.createString("Hello " + request.name()), 100, 10);
+ builder.finish(statOffset);
+ Stat stat = Stat.getRootAsStat(builder.dataBuffer());
+ responseObserver.onNext(stat);
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void retrieve(Stat request, io.grpc.stub.StreamObserver responseObserver) {
+ // Create 10 monsters for streaming response.
+ for (int i=0; i iterator = stub.retrieve(stat);
+ int counter = 0;
+ while(iterator.hasNext()) {
+ Monster m = iterator.next();
+ System.out.println("Received monster " + m.name());
+ counter ++;
+ }
+ Assert.assertEquals(counter, numStreamedMsgs);
+ System.out.println("FlatBuffers GRPC client/server test: completed successfully");
+ }
+}
diff --git a/grpc/tests/java-grpc-test.sh b/grpc/tests/java-grpc-test.sh
new file mode 100755
index 000000000..ec4296055
--- /dev/null
+++ b/grpc/tests/java-grpc-test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# NOTE: make sure `mvn install` in /gprc is executed before running this test
+mvn test
diff --git a/grpc/tests/pom.xml b/grpc/tests/pom.xml
new file mode 100644
index 000000000..cfd908b5f
--- /dev/null
+++ b/grpc/tests/pom.xml
@@ -0,0 +1,73 @@
+
+ 4.0.0
+
+ com.google.flatbuffers
+ flatbuffers-parent
+ 1.8.0
+
+ grpc-test
+ Example/Test project demonstrating usage of flatbuffers with GRPC-Java instead of protobufs
+
+
+ 1.8.0
+
+
+
+ com.google.flatbuffers
+ flatbuffers-java
+ ${project.parent.version}
+ test
+
+
+ com.google.flatbuffers
+ flatbuffers-java-grpc
+ ${project.parent.version}
+ test
+
+
+ io.grpc
+ grpc-stub
+ ${gRPC.version}
+ test
+
+
+ io.grpc
+ grpc-netty
+ ${gRPC.version}
+ test
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+ add-source
+ generate-sources
+
+ add-test-source
+
+
+
+ ${project.basedir}
+ ${project.basedir}/../../tests
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/MyGame/Example/MonsterStorageGrpc.java b/tests/MyGame/Example/MonsterStorageGrpc.java
new file mode 100644
index 000000000..2d203e632
--- /dev/null
+++ b/tests/MyGame/Example/MonsterStorageGrpc.java
@@ -0,0 +1,350 @@
+//Generated by flatc compiler (version 1.8.0) on Dec 28 2017 10:07:47
+//If you make any local changes, they will be lost
+//source: monster_test.fbs
+
+package MyGame.Example;
+
+import com.google.flatbuffers.grpc.FlatbuffersUtils;
+
+import java.nio.ByteBuffer;
+import static io.grpc.MethodDescriptor.generateFullMethodName;
+import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncUnaryCall;
+import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
+import static io.grpc.stub.ClientCalls.blockingUnaryCall;
+import static io.grpc.stub.ClientCalls.futureUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
+
+/**
+ */
+@javax.annotation.Generated(
+ value = "by gRPC proto compiler",
+ comments = "Source: monster_test.fbs")
+public final class MonsterStorageGrpc {
+
+ private MonsterStorageGrpc() {}
+
+ public static final String SERVICE_NAME = "MyGame.Example.MonsterStorage";
+
+ // Static method descriptors that strictly reflect the proto.
+ @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
+ @java.lang.Deprecated // Use {@link #getStoreMethod()} instead.
+ public static final io.grpc.MethodDescriptor METHOD_STORE = getStoreMethod();
+
+ private static volatile io.grpc.MethodDescriptor getStoreMethod;
+
+ private static volatile FlatbuffersUtils.FBExtactor extractorOfMonster;
+ private static FlatbuffersUtils.FBExtactor getExtractorOfMonster() {
+ if (extractorOfMonster != null) return extractorOfMonster;
+ synchronized (MonsterStorageGrpc.class) {
+ if (extractorOfMonster != null) return extractorOfMonster;
+ extractorOfMonster = new FlatbuffersUtils.FBExtactor() {
+ public MyGame.Example.Monster extract (ByteBuffer buffer) {
+ return MyGame.Example.Monster.getRootAsMonster(buffer);
+ }
+ };
+ return extractorOfMonster;
+ }
+ }
+
+ private static volatile FlatbuffersUtils.FBExtactor extractorOfStat;
+ private static FlatbuffersUtils.FBExtactor getExtractorOfStat() {
+ if (extractorOfStat != null) return extractorOfStat;
+ synchronized (MonsterStorageGrpc.class) {
+ if (extractorOfStat != null) return extractorOfStat;
+ extractorOfStat = new FlatbuffersUtils.FBExtactor() {
+ public MyGame.Example.Stat extract (ByteBuffer buffer) {
+ return MyGame.Example.Stat.getRootAsStat(buffer);
+ }
+ };
+ return extractorOfStat;
+ }
+ }
+
+ @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
+ public static io.grpc.MethodDescriptor getStoreMethod() {
+ io.grpc.MethodDescriptor getStoreMethod;
+ if ((getStoreMethod = MonsterStorageGrpc.getStoreMethod) == null) {
+ synchronized (MonsterStorageGrpc.class) {
+ if ((getStoreMethod = MonsterStorageGrpc.getStoreMethod) == null) {
+ MonsterStorageGrpc.getStoreMethod = getStoreMethod =
+ io.grpc.MethodDescriptor.newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(generateFullMethodName(
+ "MyGame.Example.MonsterStorage", "Store"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(FlatbuffersUtils.marshaller(
+ MyGame.Example.Monster.class, getExtractorOfMonster()))
+ .setResponseMarshaller(FlatbuffersUtils.marshaller(
+ MyGame.Example.Stat.class, getExtractorOfStat()))
+ .setSchemaDescriptor(null)
+ .build();
+ }
+ }
+ }
+ return getStoreMethod;
+ }
+
+ @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
+ @java.lang.Deprecated // Use {@link #getRetrieveMethod()} instead.
+ public static final io.grpc.MethodDescriptor METHOD_RETRIEVE = getRetrieveMethod();
+
+ private static volatile io.grpc.MethodDescriptor getRetrieveMethod;
+
+ @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
+ public static io.grpc.MethodDescriptor getRetrieveMethod() {
+ io.grpc.MethodDescriptor getRetrieveMethod;
+ if ((getRetrieveMethod = MonsterStorageGrpc.getRetrieveMethod) == null) {
+ synchronized (MonsterStorageGrpc.class) {
+ if ((getRetrieveMethod = MonsterStorageGrpc.getRetrieveMethod) == null) {
+ MonsterStorageGrpc.getRetrieveMethod = getRetrieveMethod =
+ io.grpc.MethodDescriptor.newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
+ .setFullMethodName(generateFullMethodName(
+ "MyGame.Example.MonsterStorage", "Retrieve"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(FlatbuffersUtils.marshaller(
+ MyGame.Example.Stat.class, getExtractorOfStat()))
+ .setResponseMarshaller(FlatbuffersUtils.marshaller(
+ MyGame.Example.Monster.class, getExtractorOfMonster()))
+ .setSchemaDescriptor(null)
+ .build();
+ }
+ }
+ }
+ return getRetrieveMethod;
+ }
+
+ /**
+ * Creates a new async stub that supports all call types for the service
+ */
+ public static MonsterStorageStub newStub(io.grpc.Channel channel) {
+ return new MonsterStorageStub(channel);
+ }
+
+ /**
+ * Creates a new blocking-style stub that supports unary and streaming output calls on the service
+ */
+ public static MonsterStorageBlockingStub newBlockingStub(
+ io.grpc.Channel channel) {
+ return new MonsterStorageBlockingStub(channel);
+ }
+
+ /**
+ * Creates a new ListenableFuture-style stub that supports unary calls on the service
+ */
+ public static MonsterStorageFutureStub newFutureStub(
+ io.grpc.Channel channel) {
+ return new MonsterStorageFutureStub(channel);
+ }
+
+ /**
+ */
+ public static abstract class MonsterStorageImplBase implements io.grpc.BindableService {
+
+ /**
+ */
+ public void store(MyGame.Example.Monster request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnimplementedUnaryCall(getStoreMethod(), responseObserver);
+ }
+
+ /**
+ */
+ public void retrieve(MyGame.Example.Stat request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnimplementedUnaryCall(getRetrieveMethod(), responseObserver);
+ }
+
+ @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
+ return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+ .addMethod(
+ getStoreMethod(),
+ asyncUnaryCall(
+ new MethodHandlers<
+ MyGame.Example.Monster,
+ MyGame.Example.Stat>(
+ this, METHODID_STORE)))
+ .addMethod(
+ getRetrieveMethod(),
+ asyncServerStreamingCall(
+ new MethodHandlers<
+ MyGame.Example.Stat,
+ MyGame.Example.Monster>(
+ this, METHODID_RETRIEVE)))
+ .build();
+ }
+ }
+
+ /**
+ */
+ public static final class MonsterStorageStub extends io.grpc.stub.AbstractStub {
+ private MonsterStorageStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private MonsterStorageStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @java.lang.Override
+ protected MonsterStorageStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new MonsterStorageStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public void store(MyGame.Example.Monster request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnaryCall(
+ getChannel().newCall(getStoreMethod(), getCallOptions()), request, responseObserver);
+ }
+
+ /**
+ */
+ public void retrieve(MyGame.Example.Stat request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncServerStreamingCall(
+ getChannel().newCall(getRetrieveMethod(), getCallOptions()), request, responseObserver);
+ }
+ }
+
+ /**
+ */
+ public static final class MonsterStorageBlockingStub extends io.grpc.stub.AbstractStub {
+ private MonsterStorageBlockingStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private MonsterStorageBlockingStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @java.lang.Override
+ protected MonsterStorageBlockingStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new MonsterStorageBlockingStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public MyGame.Example.Stat store(MyGame.Example.Monster request) {
+ return blockingUnaryCall(
+ getChannel(), getStoreMethod(), getCallOptions(), request);
+ }
+
+ /**
+ */
+ public java.util.Iterator retrieve(
+ MyGame.Example.Stat request) {
+ return blockingServerStreamingCall(
+ getChannel(), getRetrieveMethod(), getCallOptions(), request);
+ }
+ }
+
+ /**
+ */
+ public static final class MonsterStorageFutureStub extends io.grpc.stub.AbstractStub {
+ private MonsterStorageFutureStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private MonsterStorageFutureStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @java.lang.Override
+ protected MonsterStorageFutureStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new MonsterStorageFutureStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public com.google.common.util.concurrent.ListenableFuture store(
+ MyGame.Example.Monster request) {
+ return futureUnaryCall(
+ getChannel().newCall(getStoreMethod(), getCallOptions()), request);
+ }
+ }
+
+ private static final int METHODID_STORE = 0;
+ private static final int METHODID_RETRIEVE = 1;
+
+ private static final class MethodHandlers implements
+ io.grpc.stub.ServerCalls.UnaryMethod,
+ io.grpc.stub.ServerCalls.ServerStreamingMethod,
+ io.grpc.stub.ServerCalls.ClientStreamingMethod,
+ io.grpc.stub.ServerCalls.BidiStreamingMethod {
+ private final MonsterStorageImplBase serviceImpl;
+ private final int methodId;
+
+ MethodHandlers(MonsterStorageImplBase serviceImpl, int methodId) {
+ this.serviceImpl = serviceImpl;
+ this.methodId = methodId;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("unchecked")
+ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) {
+ switch (methodId) {
+ case METHODID_STORE:
+ serviceImpl.store((MyGame.Example.Monster) request,
+ (io.grpc.stub.StreamObserver) responseObserver);
+ break;
+ case METHODID_RETRIEVE:
+ serviceImpl.retrieve((MyGame.Example.Stat) request,
+ (io.grpc.stub.StreamObserver) responseObserver);
+ break;
+ default:
+ throw new AssertionError();
+ }
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("unchecked")
+ public io.grpc.stub.StreamObserver invoke(
+ io.grpc.stub.StreamObserver responseObserver) {
+ switch (methodId) {
+ default:
+ throw new AssertionError();
+ }
+ }
+ }
+
+ private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
+
+ public static io.grpc.ServiceDescriptor getServiceDescriptor() {
+ io.grpc.ServiceDescriptor result = serviceDescriptor;
+ if (result == null) {
+ synchronized (MonsterStorageGrpc.class) {
+ result = serviceDescriptor;
+ if (result == null) {
+ serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
+ .setSchemaDescriptor(null)
+ .addMethod(getStoreMethod())
+ .addMethod(getRetrieveMethod())
+ .build();
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/tests/namespace_test/NamespaceA/TableInC.java b/tests/namespace_test/NamespaceA/TableInC.java
deleted file mode 100644
index 38fb3ab30..000000000
--- a/tests/namespace_test/NamespaceA/TableInC.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package NamespaceA;
-
-import java.nio.*;
-import java.lang.*;
-import java.util.*;
-import com.google.flatbuffers.*;
-
-@SuppressWarnings("unused")
-public final class TableInC extends Table {
- public static TableInC getRootAsTableInC(ByteBuffer _bb) { return getRootAsTableInC(_bb, new TableInC()); }
- public static TableInC getRootAsTableInC(ByteBuffer _bb, TableInC obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public TableInC __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
-
- public NamespaceA.TableInFirstNS referToA1() { return referToA1(new NamespaceA.TableInFirstNS()); }
- public NamespaceA.TableInFirstNS referToA1(NamespaceA.TableInFirstNS obj) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
- public SecondTableInA referToA2() { return referToA2(new SecondTableInA()); }
- public SecondTableInA referToA2(SecondTableInA obj) { int o = __offset(6); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
-
- public static int createTableInC(FlatBufferBuilder builder,
- int refer_to_a1Offset,
- int refer_to_a2Offset) {
- builder.startObject(2);
- TableInC.addReferToA2(builder, refer_to_a2Offset);
- TableInC.addReferToA1(builder, refer_to_a1Offset);
- return TableInC.endTableInC(builder);
- }
-
- public static void startTableInC(FlatBufferBuilder builder) { builder.startObject(2); }
- public static void addReferToA1(FlatBufferBuilder builder, int referToA1Offset) { builder.addOffset(0, referToA1Offset, 0); }
- public static void addReferToA2(FlatBufferBuilder builder, int referToA2Offset) { builder.addOffset(1, referToA2Offset, 0); }
- public static int endTableInC(FlatBufferBuilder builder) {
- int o = builder.endObject();
- return o;
- }
-};
-