Removing java examples from grpc-common

pull/3109/head
nmittler 10 years ago
parent a25a42b4b7
commit 255b73b5b1
  1. 105
      java/pom.xml
  2. 10
      java/run_greeter_client.sh
  3. 9
      java/run_greeter_server.sh
  4. 55
      java/src/main/java/ex/grpc/GreeterClient.java
  5. 172
      java/src/main/java/ex/grpc/GreeterGrpc.java
  6. 16
      java/src/main/java/ex/grpc/GreeterImpl.java
  7. 51
      java/src/main/java/ex/grpc/GreeterServer.java
  8. 951
      java/src/main/java/ex/grpc/Helloworld.java

@ -1,105 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.google.net.stubby</groupId>
<artifactId>stubby-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>grpc-hello-world</artifactId>
<packaging>jar</packaging>
<name>Hello gRPC World</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>stubby-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>stubby-netty</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>stubby-okhttp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>stubby-stub</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>stubby-testing</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>com.internetitem</groupId>
<artifactId>write-properties-file-maven-plugin</artifactId>
<executions>
<execution>
<id>bootclasspath</id>
<phase>prepare-package</phase>
<goals>
<goal>write-properties-file</goal>
</goals>
<configuration>
<filename>bootclasspath.properties</filename>
<outputDirectory>${project.build.directory}</outputDirectory>
<properties>
<property>
<name>bootclasspath</name>
<value>${argLine.bootcp}</value>
</property>
<property>
<name>jar</name>
<value>${project.build.directory}/${project.artifactId}-${project.version}-jar-with-dependencies.jar</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -1,10 +0,0 @@
#!/bin/bash -e
TARGET='Greeter Client'
TARGET_CLASS='ex.grpc.GreeterClient'
TARGET_ARGS="$@"
cd "$(dirname "$0")"
mvn -q -nsu -am package -Dcheckstyle.skip=true -DskipTests
. target/bootclasspath.properties
echo "[INFO] Running: $TARGET ($TARGET_CLASS $TARGET_ARGS)"
exec java "$bootclasspath" -cp "$jar" "$TARGET_CLASS" $TARGET_ARGS

@ -1,9 +0,0 @@
#!/bin/bash -e
TARGET='Greeter Server'
TARGET_CLASS='ex.grpc.GreeterServer'
cd "$(dirname "$0")"
mvn -q -nsu -am package -Dcheckstyle.skip=true -DskipTests
. target/bootclasspath.properties
echo "[INFO] Running: $TARGET ($TARGET_CLASS)"
exec java "$bootclasspath" -cp "$jar" "$TARGET_CLASS"

@ -1,55 +0,0 @@
package ex.grpc;
import com.google.net.stubby.ChannelImpl;
import com.google.net.stubby.stub.StreamObserver;
import com.google.net.stubby.transport.netty.NegotiationType;
import com.google.net.stubby.transport.netty.NettyChannelBuilder;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.concurrent.TimeUnit;
public class GreeterClient {
private final Logger logger = Logger.getLogger(
GreeterClient.class.getName());
private final ChannelImpl channel;
private final GreeterGrpc.GreeterBlockingStub blockingStub;
public GreeterClient(String host, int port) {
channel = NettyChannelBuilder.forAddress(host, port)
.negotiationType(NegotiationType.PLAINTEXT)
.build();
blockingStub = GreeterGrpc.newBlockingStub(channel);
}
public void shutdown() throws InterruptedException {
channel.shutdown().awaitTerminated(5, TimeUnit.SECONDS);
}
public void greet(String name) {
try {
logger.fine("Will try to greet " + name + " ...");
Helloworld.HelloRequest req =
Helloworld.HelloRequest.newBuilder().setName(name).build();
Helloworld.HelloReply reply = blockingStub.sayHello(req);
logger.info("Greeting: " + reply.getMessage());
} catch (RuntimeException e) {
logger.log(Level.WARNING, "RPC failed", e);
return;
}
}
public static void main(String[] args) throws Exception {
GreeterClient client = new GreeterClient("localhost", 50051);
try {
/* Access a service running on the local machine on port 50051 */
String user = "world";
if (args.length > 0) {
user = args[0]; /* Use the arg as the name to greet if provided */
}
client.greet(user);
} finally {
client.shutdown();
}
}
}

@ -1,172 +0,0 @@
package ex.grpc;
import static com.google.net.stubby.stub.Calls.createMethodDescriptor;
import static com.google.net.stubby.stub.Calls.asyncUnaryCall;
import static com.google.net.stubby.stub.Calls.asyncServerStreamingCall;
import static com.google.net.stubby.stub.Calls.asyncClientStreamingCall;
import static com.google.net.stubby.stub.Calls.duplexStreamingCall;
import static com.google.net.stubby.stub.Calls.blockingUnaryCall;
import static com.google.net.stubby.stub.Calls.blockingServerStreamingCall;
import static com.google.net.stubby.stub.Calls.unaryFutureCall;
import static com.google.net.stubby.stub.ServerCalls.createMethodDefinition;
import static com.google.net.stubby.stub.ServerCalls.asyncUnaryRequestCall;
import static com.google.net.stubby.stub.ServerCalls.asyncStreamingRequestCall;
@javax.annotation.Generated("by gRPC proto compiler")
public class GreeterGrpc {
private static final com.google.net.stubby.stub.Method<ex.grpc.Helloworld.HelloRequest,
ex.grpc.Helloworld.HelloReply> METHOD_SAY_HELLO =
com.google.net.stubby.stub.Method.create(
com.google.net.stubby.MethodType.UNARY, "sayHello",
com.google.net.stubby.proto.ProtoUtils.marshaller(ex.grpc.Helloworld.HelloRequest.PARSER),
com.google.net.stubby.proto.ProtoUtils.marshaller(ex.grpc.Helloworld.HelloReply.PARSER));
public static GreeterStub newStub(com.google.net.stubby.Channel channel) {
return new GreeterStub(channel, CONFIG);
}
public static GreeterBlockingStub newBlockingStub(
com.google.net.stubby.Channel channel) {
return new GreeterBlockingStub(channel, CONFIG);
}
public static GreeterFutureStub newFutureStub(
com.google.net.stubby.Channel channel) {
return new GreeterFutureStub(channel, CONFIG);
}
public static final GreeterServiceDescriptor CONFIG =
new GreeterServiceDescriptor();
@javax.annotation.concurrent.Immutable
public static class GreeterServiceDescriptor extends
com.google.net.stubby.stub.AbstractServiceDescriptor<GreeterServiceDescriptor> {
public final com.google.net.stubby.MethodDescriptor<ex.grpc.Helloworld.HelloRequest,
ex.grpc.Helloworld.HelloReply> sayHello;
private GreeterServiceDescriptor() {
sayHello = createMethodDescriptor(
"helloworld.Greeter", METHOD_SAY_HELLO);
}
private GreeterServiceDescriptor(
java.util.Map<java.lang.String, com.google.net.stubby.MethodDescriptor<?, ?>> methodMap) {
sayHello = (com.google.net.stubby.MethodDescriptor<ex.grpc.Helloworld.HelloRequest,
ex.grpc.Helloworld.HelloReply>) methodMap.get(
CONFIG.sayHello.getName());
}
@java.lang.Override
protected GreeterServiceDescriptor build(
java.util.Map<java.lang.String, com.google.net.stubby.MethodDescriptor<?, ?>> methodMap) {
return new GreeterServiceDescriptor(methodMap);
}
@java.lang.Override
public com.google.common.collect.ImmutableList<com.google.net.stubby.MethodDescriptor<?, ?>> methods() {
return com.google.common.collect.ImmutableList.<com.google.net.stubby.MethodDescriptor<?, ?>>of(
sayHello);
}
}
public static interface Greeter {
public void sayHello(ex.grpc.Helloworld.HelloRequest request,
com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply> responseObserver);
}
public static interface GreeterBlockingClient {
public ex.grpc.Helloworld.HelloReply sayHello(ex.grpc.Helloworld.HelloRequest request);
}
public static interface GreeterFutureClient {
public com.google.common.util.concurrent.ListenableFuture<ex.grpc.Helloworld.HelloReply> sayHello(
ex.grpc.Helloworld.HelloRequest request);
}
public static class GreeterStub extends
com.google.net.stubby.stub.AbstractStub<GreeterStub, GreeterServiceDescriptor>
implements Greeter {
private GreeterStub(com.google.net.stubby.Channel channel,
GreeterServiceDescriptor config) {
super(channel, config);
}
@java.lang.Override
protected GreeterStub build(com.google.net.stubby.Channel channel,
GreeterServiceDescriptor config) {
return new GreeterStub(channel, config);
}
@java.lang.Override
public void sayHello(ex.grpc.Helloworld.HelloRequest request,
com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply> responseObserver) {
asyncUnaryCall(
channel.newCall(config.sayHello), request, responseObserver);
}
}
public static class GreeterBlockingStub extends
com.google.net.stubby.stub.AbstractStub<GreeterBlockingStub, GreeterServiceDescriptor>
implements GreeterBlockingClient {
private GreeterBlockingStub(com.google.net.stubby.Channel channel,
GreeterServiceDescriptor config) {
super(channel, config);
}
@java.lang.Override
protected GreeterBlockingStub build(com.google.net.stubby.Channel channel,
GreeterServiceDescriptor config) {
return new GreeterBlockingStub(channel, config);
}
@java.lang.Override
public ex.grpc.Helloworld.HelloReply sayHello(ex.grpc.Helloworld.HelloRequest request) {
return blockingUnaryCall(
channel.newCall(config.sayHello), request);
}
}
public static class GreeterFutureStub extends
com.google.net.stubby.stub.AbstractStub<GreeterFutureStub, GreeterServiceDescriptor>
implements GreeterFutureClient {
private GreeterFutureStub(com.google.net.stubby.Channel channel,
GreeterServiceDescriptor config) {
super(channel, config);
}
@java.lang.Override
protected GreeterFutureStub build(com.google.net.stubby.Channel channel,
GreeterServiceDescriptor config) {
return new GreeterFutureStub(channel, config);
}
@java.lang.Override
public com.google.common.util.concurrent.ListenableFuture<ex.grpc.Helloworld.HelloReply> sayHello(
ex.grpc.Helloworld.HelloRequest request) {
return unaryFutureCall(
channel.newCall(config.sayHello), request);
}
}
public static com.google.net.stubby.ServerServiceDefinition bindService(
final Greeter serviceImpl) {
return com.google.net.stubby.ServerServiceDefinition.builder("helloworld.Greeter")
.addMethod(createMethodDefinition(
METHOD_SAY_HELLO,
asyncUnaryRequestCall(
new com.google.net.stubby.stub.ServerCalls.UnaryRequestMethod<
ex.grpc.Helloworld.HelloRequest,
ex.grpc.Helloworld.HelloReply>() {
@java.lang.Override
public void invoke(
ex.grpc.Helloworld.HelloRequest request,
com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply> responseObserver) {
serviceImpl.sayHello(request, responseObserver);
}
}))).build();
}
}

@ -1,16 +0,0 @@
package ex.grpc;
import com.google.net.stubby.stub.StreamObserver;
public class GreeterImpl implements GreeterGrpc.Greeter {
@Override
public void sayHello(Helloworld.HelloRequest req,
StreamObserver<Helloworld.HelloReply> responseObserver) {
Helloworld.HelloReply reply = Helloworld.HelloReply.newBuilder().setMessage(
"Hello " + req.getName()).build();
responseObserver.onValue(reply);
responseObserver.onCompleted();
}
}

@ -1,51 +0,0 @@
package ex.grpc;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.net.stubby.ServerImpl;
import com.google.net.stubby.transport.netty.NettyServerBuilder;
import java.util.concurrent.TimeUnit;
/**
* Server that manages startup/shutdown of a {@code Greeter} server.
*/
public class GreeterServer {
/* The port on which the server should run */
private int port = 50051;
private ServerImpl server;
private void start() throws Exception {
server = NettyServerBuilder.forPort(port)
.addService(GreeterGrpc.bindService(new GreeterImpl()))
.build();
server.startAsync();
server.awaitRunning(5, TimeUnit.SECONDS);
System.out.println("Server started on port:" + port);
}
private void stop() throws Exception {
server.stopAsync();
server.awaitTerminated();
System.out.println("Server shutting down ...");
}
/**
* Main launches the server from the command line.
*/
public static void main(String[] args) throws Exception {
final GreeterServer server = new GreeterServer();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
System.out.println("Shutting down");
server.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
});
server.start();
}
}

@ -1,951 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: helloworld.proto
package ex.grpc;
public final class Helloworld {
private Helloworld() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
}
public interface HelloRequestOrBuilder extends
// @@protoc_insertion_point(interface_extends:helloworld.HelloRequest)
com.google.protobuf.MessageOrBuilder {
/**
* <code>optional string name = 1;</code>
*/
java.lang.String getName();
/**
* <code>optional string name = 1;</code>
*/
com.google.protobuf.ByteString
getNameBytes();
}
/**
* Protobuf type {@code helloworld.HelloRequest}
*
* <pre>
* The request message containing the user's name.
* </pre>
*/
public static final class HelloRequest extends
com.google.protobuf.GeneratedMessage implements
// @@protoc_insertion_point(message_implements:helloworld.HelloRequest)
HelloRequestOrBuilder {
// Use HelloRequest.newBuilder() to construct.
private HelloRequest(com.google.protobuf.GeneratedMessage.Builder builder) {
super(builder);
}
private HelloRequest() {
name_ = "";
}
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
}
private HelloRequest(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
int mutable_bitField0_ = 0;
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!input.skipField(tag)) {
done = true;
}
break;
}
case 10: {
com.google.protobuf.ByteString bs = input.readBytes();
name_ = bs;
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this);
} finally {
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return ex.grpc.Helloworld.internal_static_helloworld_HelloRequest_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return ex.grpc.Helloworld.internal_static_helloworld_HelloRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
ex.grpc.Helloworld.HelloRequest.class, ex.grpc.Helloworld.HelloRequest.Builder.class);
}
public static final com.google.protobuf.Parser<HelloRequest> PARSER =
new com.google.protobuf.AbstractParser<HelloRequest>() {
public HelloRequest parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new HelloRequest(input, extensionRegistry);
}
};
@java.lang.Override
public com.google.protobuf.Parser<HelloRequest> getParserForType() {
return PARSER;
}
public static final int NAME_FIELD_NUMBER = 1;
private java.lang.Object name_;
/**
* <code>optional string name = 1;</code>
*/
public java.lang.String getName() {
java.lang.Object ref = name_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
name_ = s;
}
return s;
}
}
/**
* <code>optional string name = 1;</code>
*/
public com.google.protobuf.ByteString
getNameBytes() {
java.lang.Object ref = name_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
name_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
getSerializedSize();
if (!getNameBytes().isEmpty()) {
output.writeBytes(1, getNameBytes());
}
}
private int memoizedSerializedSize = -1;
public int getSerializedSize() {
int size = memoizedSerializedSize;
if (size != -1) return size;
size = 0;
if (!getNameBytes().isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(1, getNameBytes());
}
memoizedSerializedSize = size;
return size;
}
private static final long serialVersionUID = 0L;
public static ex.grpc.Helloworld.HelloRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static ex.grpc.Helloworld.HelloRequest parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static ex.grpc.Helloworld.HelloRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static ex.grpc.Helloworld.HelloRequest parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static ex.grpc.Helloworld.HelloRequest parseFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
public static ex.grpc.Helloworld.HelloRequest parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
public static ex.grpc.Helloworld.HelloRequest parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
public static ex.grpc.Helloworld.HelloRequest parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
public static ex.grpc.Helloworld.HelloRequest parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
public static ex.grpc.Helloworld.HelloRequest parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
public static Builder newBuilder() { return new Builder(); }
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder(ex.grpc.Helloworld.HelloRequest prototype) {
return newBuilder().mergeFrom(prototype);
}
public Builder toBuilder() { return newBuilder(this); }
@java.lang.Override
protected Builder newBuilderForType(
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code helloworld.HelloRequest}
*
* <pre>
* The request message containing the user's name.
* </pre>
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessage.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:helloworld.HelloRequest)
ex.grpc.Helloworld.HelloRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return ex.grpc.Helloworld.internal_static_helloworld_HelloRequest_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return ex.grpc.Helloworld.internal_static_helloworld_HelloRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
ex.grpc.Helloworld.HelloRequest.class, ex.grpc.Helloworld.HelloRequest.Builder.class);
}
// Construct using ex.grpc.Helloworld.HelloRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
}
}
public Builder clear() {
super.clear();
name_ = "";
return this;
}
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return ex.grpc.Helloworld.internal_static_helloworld_HelloRequest_descriptor;
}
public ex.grpc.Helloworld.HelloRequest getDefaultInstanceForType() {
return ex.grpc.Helloworld.HelloRequest.getDefaultInstance();
}
public ex.grpc.Helloworld.HelloRequest build() {
ex.grpc.Helloworld.HelloRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
public ex.grpc.Helloworld.HelloRequest buildPartial() {
ex.grpc.Helloworld.HelloRequest result = new ex.grpc.Helloworld.HelloRequest(this);
result.name_ = name_;
onBuilt();
return result;
}
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof ex.grpc.Helloworld.HelloRequest) {
return mergeFrom((ex.grpc.Helloworld.HelloRequest)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(ex.grpc.Helloworld.HelloRequest other) {
if (other == ex.grpc.Helloworld.HelloRequest.getDefaultInstance()) return this;
if (!other.getName().isEmpty()) {
name_ = other.name_;
onChanged();
}
onChanged();
return this;
}
public final boolean isInitialized() {
return true;
}
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
ex.grpc.Helloworld.HelloRequest parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (ex.grpc.Helloworld.HelloRequest) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private java.lang.Object name_ = "";
/**
* <code>optional string name = 1;</code>
*/
public java.lang.String getName() {
java.lang.Object ref = name_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
name_ = s;
}
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <code>optional string name = 1;</code>
*/
public com.google.protobuf.ByteString
getNameBytes() {
java.lang.Object ref = name_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
name_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>optional string name = 1;</code>
*/
public Builder setName(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
name_ = value;
onChanged();
return this;
}
/**
* <code>optional string name = 1;</code>
*/
public Builder clearName() {
name_ = getDefaultInstance().getName();
onChanged();
return this;
}
/**
* <code>optional string name = 1;</code>
*/
public Builder setNameBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
name_ = value;
onChanged();
return this;
}
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
}
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
}
// @@protoc_insertion_point(builder_scope:helloworld.HelloRequest)
}
// @@protoc_insertion_point(class_scope:helloworld.HelloRequest)
private static final ex.grpc.Helloworld.HelloRequest defaultInstance;static {
defaultInstance = new ex.grpc.Helloworld.HelloRequest();
}
public static ex.grpc.Helloworld.HelloRequest getDefaultInstance() {
return defaultInstance;
}
public ex.grpc.Helloworld.HelloRequest getDefaultInstanceForType() {
return defaultInstance;
}
}
public interface HelloReplyOrBuilder extends
// @@protoc_insertion_point(interface_extends:helloworld.HelloReply)
com.google.protobuf.MessageOrBuilder {
/**
* <code>optional string message = 1;</code>
*/
java.lang.String getMessage();
/**
* <code>optional string message = 1;</code>
*/
com.google.protobuf.ByteString
getMessageBytes();
}
/**
* Protobuf type {@code helloworld.HelloReply}
*
* <pre>
* The response message containing the greetings
* </pre>
*/
public static final class HelloReply extends
com.google.protobuf.GeneratedMessage implements
// @@protoc_insertion_point(message_implements:helloworld.HelloReply)
HelloReplyOrBuilder {
// Use HelloReply.newBuilder() to construct.
private HelloReply(com.google.protobuf.GeneratedMessage.Builder builder) {
super(builder);
}
private HelloReply() {
message_ = "";
}
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
}
private HelloReply(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
int mutable_bitField0_ = 0;
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!input.skipField(tag)) {
done = true;
}
break;
}
case 10: {
com.google.protobuf.ByteString bs = input.readBytes();
message_ = bs;
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this);
} finally {
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return ex.grpc.Helloworld.internal_static_helloworld_HelloReply_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return ex.grpc.Helloworld.internal_static_helloworld_HelloReply_fieldAccessorTable
.ensureFieldAccessorsInitialized(
ex.grpc.Helloworld.HelloReply.class, ex.grpc.Helloworld.HelloReply.Builder.class);
}
public static final com.google.protobuf.Parser<HelloReply> PARSER =
new com.google.protobuf.AbstractParser<HelloReply>() {
public HelloReply parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new HelloReply(input, extensionRegistry);
}
};
@java.lang.Override
public com.google.protobuf.Parser<HelloReply> getParserForType() {
return PARSER;
}
public static final int MESSAGE_FIELD_NUMBER = 1;
private java.lang.Object message_;
/**
* <code>optional string message = 1;</code>
*/
public java.lang.String getMessage() {
java.lang.Object ref = message_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
message_ = s;
}
return s;
}
}
/**
* <code>optional string message = 1;</code>
*/
public com.google.protobuf.ByteString
getMessageBytes() {
java.lang.Object ref = message_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
message_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
getSerializedSize();
if (!getMessageBytes().isEmpty()) {
output.writeBytes(1, getMessageBytes());
}
}
private int memoizedSerializedSize = -1;
public int getSerializedSize() {
int size = memoizedSerializedSize;
if (size != -1) return size;
size = 0;
if (!getMessageBytes().isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(1, getMessageBytes());
}
memoizedSerializedSize = size;
return size;
}
private static final long serialVersionUID = 0L;
public static ex.grpc.Helloworld.HelloReply parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static ex.grpc.Helloworld.HelloReply parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static ex.grpc.Helloworld.HelloReply parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static ex.grpc.Helloworld.HelloReply parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static ex.grpc.Helloworld.HelloReply parseFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
public static ex.grpc.Helloworld.HelloReply parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
public static ex.grpc.Helloworld.HelloReply parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
public static ex.grpc.Helloworld.HelloReply parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
public static ex.grpc.Helloworld.HelloReply parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
public static ex.grpc.Helloworld.HelloReply parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
public static Builder newBuilder() { return new Builder(); }
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder(ex.grpc.Helloworld.HelloReply prototype) {
return newBuilder().mergeFrom(prototype);
}
public Builder toBuilder() { return newBuilder(this); }
@java.lang.Override
protected Builder newBuilderForType(
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code helloworld.HelloReply}
*
* <pre>
* The response message containing the greetings
* </pre>
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessage.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:helloworld.HelloReply)
ex.grpc.Helloworld.HelloReplyOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return ex.grpc.Helloworld.internal_static_helloworld_HelloReply_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return ex.grpc.Helloworld.internal_static_helloworld_HelloReply_fieldAccessorTable
.ensureFieldAccessorsInitialized(
ex.grpc.Helloworld.HelloReply.class, ex.grpc.Helloworld.HelloReply.Builder.class);
}
// Construct using ex.grpc.Helloworld.HelloReply.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
}
}
public Builder clear() {
super.clear();
message_ = "";
return this;
}
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return ex.grpc.Helloworld.internal_static_helloworld_HelloReply_descriptor;
}
public ex.grpc.Helloworld.HelloReply getDefaultInstanceForType() {
return ex.grpc.Helloworld.HelloReply.getDefaultInstance();
}
public ex.grpc.Helloworld.HelloReply build() {
ex.grpc.Helloworld.HelloReply result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
public ex.grpc.Helloworld.HelloReply buildPartial() {
ex.grpc.Helloworld.HelloReply result = new ex.grpc.Helloworld.HelloReply(this);
result.message_ = message_;
onBuilt();
return result;
}
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof ex.grpc.Helloworld.HelloReply) {
return mergeFrom((ex.grpc.Helloworld.HelloReply)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(ex.grpc.Helloworld.HelloReply other) {
if (other == ex.grpc.Helloworld.HelloReply.getDefaultInstance()) return this;
if (!other.getMessage().isEmpty()) {
message_ = other.message_;
onChanged();
}
onChanged();
return this;
}
public final boolean isInitialized() {
return true;
}
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
ex.grpc.Helloworld.HelloReply parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (ex.grpc.Helloworld.HelloReply) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private java.lang.Object message_ = "";
/**
* <code>optional string message = 1;</code>
*/
public java.lang.String getMessage() {
java.lang.Object ref = message_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
message_ = s;
}
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <code>optional string message = 1;</code>
*/
public com.google.protobuf.ByteString
getMessageBytes() {
java.lang.Object ref = message_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
message_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>optional string message = 1;</code>
*/
public Builder setMessage(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
message_ = value;
onChanged();
return this;
}
/**
* <code>optional string message = 1;</code>
*/
public Builder clearMessage() {
message_ = getDefaultInstance().getMessage();
onChanged();
return this;
}
/**
* <code>optional string message = 1;</code>
*/
public Builder setMessageBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
message_ = value;
onChanged();
return this;
}
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
}
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
}
// @@protoc_insertion_point(builder_scope:helloworld.HelloReply)
}
// @@protoc_insertion_point(class_scope:helloworld.HelloReply)
private static final ex.grpc.Helloworld.HelloReply defaultInstance;static {
defaultInstance = new ex.grpc.Helloworld.HelloReply();
}
public static ex.grpc.Helloworld.HelloReply getDefaultInstance() {
return defaultInstance;
}
public ex.grpc.Helloworld.HelloReply getDefaultInstanceForType() {
return defaultInstance;
}
}
private static final com.google.protobuf.Descriptors.Descriptor
internal_static_helloworld_HelloRequest_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_helloworld_HelloRequest_fieldAccessorTable;
private static final com.google.protobuf.Descriptors.Descriptor
internal_static_helloworld_HelloReply_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_helloworld_HelloReply_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\020helloworld.proto\022\nhelloworld\"\034\n\014HelloR" +
"equest\022\014\n\004name\030\001 \001(\t\"\035\n\nHelloReply\022\017\n\007me" +
"ssage\030\001 \001(\t2I\n\007Greeter\022>\n\010sayHello\022\030.hel" +
"loworld.HelloRequest\032\026.helloworld.HelloR" +
"eply\"\000B\t\n\007ex.grpcb\006proto3"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
public com.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.Descriptors.FileDescriptor root) {
descriptor = root;
return null;
}
};
com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
}, assigner);
internal_static_helloworld_HelloRequest_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_helloworld_HelloRequest_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_helloworld_HelloRequest_descriptor,
new java.lang.String[] { "Name", });
internal_static_helloworld_HelloReply_descriptor =
getDescriptor().getMessageTypes().get(1);
internal_static_helloworld_HelloReply_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_helloworld_HelloReply_descriptor,
new java.lang.String[] { "Message", });
}
// @@protoc_insertion_point(outer_class_scope)
}
Loading…
Cancel
Save