From 255b73b5b198f593b14d878842dd2a0bfec87fe9 Mon Sep 17 00:00:00 2001 From: nmittler Date: Wed, 25 Feb 2015 11:02:03 -0800 Subject: [PATCH] Removing java examples from grpc-common --- java/pom.xml | 105 -- java/run_greeter_client.sh | 10 - java/run_greeter_server.sh | 9 - java/src/main/java/ex/grpc/GreeterClient.java | 55 - java/src/main/java/ex/grpc/GreeterGrpc.java | 172 ---- java/src/main/java/ex/grpc/GreeterImpl.java | 16 - java/src/main/java/ex/grpc/GreeterServer.java | 51 - java/src/main/java/ex/grpc/Helloworld.java | 951 ------------------ 8 files changed, 1369 deletions(-) delete mode 100644 java/pom.xml delete mode 100755 java/run_greeter_client.sh delete mode 100755 java/run_greeter_server.sh delete mode 100644 java/src/main/java/ex/grpc/GreeterClient.java delete mode 100644 java/src/main/java/ex/grpc/GreeterGrpc.java delete mode 100644 java/src/main/java/ex/grpc/GreeterImpl.java delete mode 100644 java/src/main/java/ex/grpc/GreeterServer.java delete mode 100644 java/src/main/java/ex/grpc/Helloworld.java diff --git a/java/pom.xml b/java/pom.xml deleted file mode 100644 index da0ee205f77..00000000000 --- a/java/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - 4.0.0 - - - com.google.net.stubby - stubby-parent - 0.1.0-SNAPSHOT - - - grpc-hello-world - jar - - Hello gRPC World - - - - ${project.groupId} - stubby-core - ${project.version} - - - ${project.groupId} - stubby-netty - ${project.version} - - - ${project.groupId} - stubby-okhttp - ${project.version} - - - ${project.groupId} - stubby-stub - ${project.version} - - - ${project.groupId} - stubby-testing - ${project.version} - - - junit - junit - compile - - - org.mockito - mockito-core - compile - - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - assemble-all - package - - single - - - - - - jar-with-dependencies - - - - - - com.internetitem - write-properties-file-maven-plugin - - - bootclasspath - prepare-package - - write-properties-file - - - bootclasspath.properties - ${project.build.directory} - - - bootclasspath - ${argLine.bootcp} - - - jar - ${project.build.directory}/${project.artifactId}-${project.version}-jar-with-dependencies.jar - - - - - - - - - diff --git a/java/run_greeter_client.sh b/java/run_greeter_client.sh deleted file mode 100755 index e86ab4ae891..00000000000 --- a/java/run_greeter_client.sh +++ /dev/null @@ -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 diff --git a/java/run_greeter_server.sh b/java/run_greeter_server.sh deleted file mode 100755 index 836abc7f48a..00000000000 --- a/java/run_greeter_server.sh +++ /dev/null @@ -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" diff --git a/java/src/main/java/ex/grpc/GreeterClient.java b/java/src/main/java/ex/grpc/GreeterClient.java deleted file mode 100644 index 9a4615132d6..00000000000 --- a/java/src/main/java/ex/grpc/GreeterClient.java +++ /dev/null @@ -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(); - } - } -} diff --git a/java/src/main/java/ex/grpc/GreeterGrpc.java b/java/src/main/java/ex/grpc/GreeterGrpc.java deleted file mode 100644 index 080c3dfc434..00000000000 --- a/java/src/main/java/ex/grpc/GreeterGrpc.java +++ /dev/null @@ -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 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 { - public final com.google.net.stubby.MethodDescriptor sayHello; - - private GreeterServiceDescriptor() { - sayHello = createMethodDescriptor( - "helloworld.Greeter", METHOD_SAY_HELLO); - } - - private GreeterServiceDescriptor( - java.util.Map> methodMap) { - sayHello = (com.google.net.stubby.MethodDescriptor) methodMap.get( - CONFIG.sayHello.getName()); - } - - @java.lang.Override - protected GreeterServiceDescriptor build( - java.util.Map> methodMap) { - return new GreeterServiceDescriptor(methodMap); - } - - @java.lang.Override - public com.google.common.collect.ImmutableList> methods() { - return com.google.common.collect.ImmutableList.>of( - sayHello); - } - } - - public static interface Greeter { - - public void sayHello(ex.grpc.Helloworld.HelloRequest request, - com.google.net.stubby.stub.StreamObserver 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 sayHello( - ex.grpc.Helloworld.HelloRequest request); - } - - public static class GreeterStub extends - com.google.net.stubby.stub.AbstractStub - 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 responseObserver) { - asyncUnaryCall( - channel.newCall(config.sayHello), request, responseObserver); - } - } - - public static class GreeterBlockingStub extends - com.google.net.stubby.stub.AbstractStub - 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 - 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 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 responseObserver) { - serviceImpl.sayHello(request, responseObserver); - } - }))).build(); - } -} diff --git a/java/src/main/java/ex/grpc/GreeterImpl.java b/java/src/main/java/ex/grpc/GreeterImpl.java deleted file mode 100644 index 825ba8631ec..00000000000 --- a/java/src/main/java/ex/grpc/GreeterImpl.java +++ /dev/null @@ -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 responseObserver) { - Helloworld.HelloReply reply = Helloworld.HelloReply.newBuilder().setMessage( - "Hello " + req.getName()).build(); - responseObserver.onValue(reply); - responseObserver.onCompleted(); - } - -} diff --git a/java/src/main/java/ex/grpc/GreeterServer.java b/java/src/main/java/ex/grpc/GreeterServer.java deleted file mode 100644 index bb05680b0a6..00000000000 --- a/java/src/main/java/ex/grpc/GreeterServer.java +++ /dev/null @@ -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(); - } -} diff --git a/java/src/main/java/ex/grpc/Helloworld.java b/java/src/main/java/ex/grpc/Helloworld.java deleted file mode 100644 index b25a63fca32..00000000000 --- a/java/src/main/java/ex/grpc/Helloworld.java +++ /dev/null @@ -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 { - - /** - * optional string name = 1; - */ - java.lang.String getName(); - /** - * optional string name = 1; - */ - com.google.protobuf.ByteString - getNameBytes(); - } - /** - * Protobuf type {@code helloworld.HelloRequest} - * - *
-   * The request message containing the user's name.
-   * 
- */ - 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 PARSER = - new com.google.protobuf.AbstractParser() { - 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 getParserForType() { - return PARSER; - } - - public static final int NAME_FIELD_NUMBER = 1; - private java.lang.Object name_; - /** - * optional string name = 1; - */ - 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; - } - } - /** - * optional string name = 1; - */ - 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} - * - *
-     * The request message containing the user's name.
-     * 
- */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.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_ = ""; - /** - * optional string name = 1; - */ - 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; - } - } - /** - * optional string name = 1; - */ - 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; - } - } - /** - * optional string name = 1; - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * optional string name = 1; - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * optional string name = 1; - */ - 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 { - - /** - * optional string message = 1; - */ - java.lang.String getMessage(); - /** - * optional string message = 1; - */ - com.google.protobuf.ByteString - getMessageBytes(); - } - /** - * Protobuf type {@code helloworld.HelloReply} - * - *
-   * The response message containing the greetings
-   * 
- */ - 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 PARSER = - new com.google.protobuf.AbstractParser() { - 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 getParserForType() { - return PARSER; - } - - public static final int MESSAGE_FIELD_NUMBER = 1; - private java.lang.Object message_; - /** - * optional string message = 1; - */ - 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; - } - } - /** - * optional string message = 1; - */ - 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} - * - *
-     * The response message containing the greetings
-     * 
- */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.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_ = ""; - /** - * optional string message = 1; - */ - 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; - } - } - /** - * optional string message = 1; - */ - 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; - } - } - /** - * optional string message = 1; - */ - public Builder setMessage( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - message_ = value; - onChanged(); - return this; - } - /** - * optional string message = 1; - */ - public Builder clearMessage() { - - message_ = getDefaultInstance().getMessage(); - onChanged(); - return this; - } - /** - * optional string message = 1; - */ - 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) -}