diff --git a/core/src/main/java/io/grpc/HandlerRegistry.java b/core/src/main/java/io/grpc/HandlerRegistry.java index 19c429f6d1..7aad4f65a7 100644 --- a/core/src/main/java/io/grpc/HandlerRegistry.java +++ b/core/src/main/java/io/grpc/HandlerRegistry.java @@ -31,8 +31,6 @@ package io.grpc; -import io.grpc.ServerServiceDefinition.ServerMethodDefinition; - import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; diff --git a/core/src/main/java/io/grpc/ServerInterceptors.java b/core/src/main/java/io/grpc/ServerInterceptors.java index 2b5e01f889..231b5baea1 100644 --- a/core/src/main/java/io/grpc/ServerInterceptors.java +++ b/core/src/main/java/io/grpc/ServerInterceptors.java @@ -33,8 +33,6 @@ package io.grpc; import com.google.common.base.Preconditions; -import io.grpc.ServerServiceDefinition.ServerMethodDefinition; - import java.io.BufferedInputStream; import java.io.InputStream; import java.util.ArrayList; diff --git a/core/src/main/java/io/grpc/ServerMethodDefinition.java b/core/src/main/java/io/grpc/ServerMethodDefinition.java new file mode 100644 index 0000000000..e1ccfc6eda --- /dev/null +++ b/core/src/main/java/io/grpc/ServerMethodDefinition.java @@ -0,0 +1,82 @@ +/* + * Copyright 2014, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.grpc; + +/** + * Definition of a method exposed by a {@link Server}. + * + * @see ServerServiceDefinition + */ +public final class ServerMethodDefinition { + private final MethodDescriptor method; + private final ServerCallHandler handler; + + private ServerMethodDefinition(MethodDescriptor method, + ServerCallHandler handler) { + this.method = method; + this.handler = handler; + } + + /** + * Create a new instance. + * + * @param method the {@link MethodDescriptor} for this method. + * @param handler to dispatch calls to. + * @return a new instance. + */ + public static ServerMethodDefinition create( + MethodDescriptor method, + ServerCallHandler handler) { + return new ServerMethodDefinition(method, handler); + } + + /** The {@code MethodDescriptor} for this method. */ + public MethodDescriptor getMethodDescriptor() { + return method; + } + + /** Handler for incoming calls. */ + public ServerCallHandler getServerCallHandler() { + return handler; + } + + /** + * Create a new method definition with a different call handler. + * + * @param handler to bind to a cloned instance of this. + * @return a cloned instance of this with the new handler bound. + */ + public ServerMethodDefinition withServerCallHandler( + ServerCallHandler handler) { + return new ServerMethodDefinition(method, handler); + } +} diff --git a/core/src/main/java/io/grpc/ServerServiceDefinition.java b/core/src/main/java/io/grpc/ServerServiceDefinition.java index 19ed9458e9..6c41c5bc8e 100644 --- a/core/src/main/java/io/grpc/ServerServiceDefinition.java +++ b/core/src/main/java/io/grpc/ServerServiceDefinition.java @@ -165,57 +165,4 @@ public final class ServerServiceDefinition { return new ServerServiceDefinition(serviceDescriptor, methods); } } - - /** - * Definition of a method exposed by a {@link Server}. - */ - public static final class ServerMethodDefinition { - - private final MethodDescriptor method; - private final ServerCallHandler handler; - - private ServerMethodDefinition(MethodDescriptor method, - ServerCallHandler handler) { - this.method = method; - this.handler = handler; - } - - /** - * Create a new instance. - * - * @param method the {@link MethodDescriptor} for this method. - * @param handler to dispatch calls to. - * @return a new instance. - */ - public static ServerMethodDefinition create( - MethodDescriptor method, - ServerCallHandler handler) { - return new ServerMethodDefinition(method, handler); - } - - /** - * The {@code MethodDescriptor} for this method. - */ - public MethodDescriptor getMethodDescriptor() { - return method; - } - - /** - * Handler for incoming calls. - */ - public ServerCallHandler getServerCallHandler() { - return handler; - } - - /** - * Create a new method definition with a different call handler. - * - * @param handler to bind to a cloned instance of this. - * @return a cloned instance of this with the new handler bound. - */ - public ServerMethodDefinition withServerCallHandler( - ServerCallHandler handler) { - return new ServerMethodDefinition(method, handler); - } - } } diff --git a/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java b/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java index 6a7a8ad0ed..a6713f386b 100644 --- a/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java +++ b/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java @@ -42,8 +42,8 @@ import io.grpc.DecompressorRegistry; import io.grpc.HandlerRegistry; import io.grpc.Internal; import io.grpc.ServerBuilder; +import io.grpc.ServerMethodDefinition; import io.grpc.ServerServiceDefinition; -import io.grpc.ServerServiceDefinition.ServerMethodDefinition; import java.util.concurrent.Executor; diff --git a/core/src/main/java/io/grpc/internal/InternalHandlerRegistry.java b/core/src/main/java/io/grpc/internal/InternalHandlerRegistry.java index 24c755da12..72ea6b12b4 100644 --- a/core/src/main/java/io/grpc/internal/InternalHandlerRegistry.java +++ b/core/src/main/java/io/grpc/internal/InternalHandlerRegistry.java @@ -33,8 +33,8 @@ package io.grpc.internal; import com.google.common.collect.ImmutableMap; +import io.grpc.ServerMethodDefinition; import io.grpc.ServerServiceDefinition; -import io.grpc.ServerServiceDefinition.ServerMethodDefinition; import java.util.HashMap; import javax.annotation.Nullable; diff --git a/core/src/main/java/io/grpc/internal/ServerImpl.java b/core/src/main/java/io/grpc/internal/ServerImpl.java index 9d0422d516..e133c17724 100644 --- a/core/src/main/java/io/grpc/internal/ServerImpl.java +++ b/core/src/main/java/io/grpc/internal/ServerImpl.java @@ -47,7 +47,7 @@ import io.grpc.DecompressorRegistry; import io.grpc.HandlerRegistry; import io.grpc.Metadata; import io.grpc.ServerCall; -import io.grpc.ServerServiceDefinition.ServerMethodDefinition; +import io.grpc.ServerMethodDefinition; import io.grpc.Status; import java.io.IOException; diff --git a/core/src/main/java/io/grpc/util/MutableHandlerRegistry.java b/core/src/main/java/io/grpc/util/MutableHandlerRegistry.java index 5d3f52eebb..28b823ddac 100644 --- a/core/src/main/java/io/grpc/util/MutableHandlerRegistry.java +++ b/core/src/main/java/io/grpc/util/MutableHandlerRegistry.java @@ -34,8 +34,8 @@ package io.grpc.util; import io.grpc.ExperimentalApi; import io.grpc.HandlerRegistry; import io.grpc.MethodDescriptor; +import io.grpc.ServerMethodDefinition; import io.grpc.ServerServiceDefinition; -import io.grpc.ServerServiceDefinition.ServerMethodDefinition; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; diff --git a/core/src/test/java/io/grpc/ServerInterceptorsTest.java b/core/src/test/java/io/grpc/ServerInterceptorsTest.java index b3e8fa5188..954178e507 100644 --- a/core/src/test/java/io/grpc/ServerInterceptorsTest.java +++ b/core/src/test/java/io/grpc/ServerInterceptorsTest.java @@ -45,7 +45,7 @@ import static org.mockito.Mockito.verifyZeroInteractions; import io.grpc.MethodDescriptor.Marshaller; import io.grpc.MethodDescriptor.MethodType; import io.grpc.ServerCall.Listener; -import io.grpc.ServerServiceDefinition.ServerMethodDefinition; +import io.grpc.ServerMethodDefinition; import org.junit.After; import org.junit.Before; diff --git a/core/src/test/java/io/grpc/ServerServiceDefinitionTest.java b/core/src/test/java/io/grpc/ServerServiceDefinitionTest.java index cfc5eec5f7..dbc7c365c0 100644 --- a/core/src/test/java/io/grpc/ServerServiceDefinitionTest.java +++ b/core/src/test/java/io/grpc/ServerServiceDefinitionTest.java @@ -35,8 +35,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; -import io.grpc.ServerServiceDefinition.ServerMethodDefinition; - import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; diff --git a/core/src/test/java/io/grpc/util/MutableHandlerRegistryTest.java b/core/src/test/java/io/grpc/util/MutableHandlerRegistryTest.java index 4ae126e3fa..42ead8488b 100644 --- a/core/src/test/java/io/grpc/util/MutableHandlerRegistryTest.java +++ b/core/src/test/java/io/grpc/util/MutableHandlerRegistryTest.java @@ -42,8 +42,8 @@ import io.grpc.MethodDescriptor.Marshaller; import io.grpc.MethodDescriptor.MethodType; import io.grpc.MethodDescriptor; import io.grpc.ServerCallHandler; +import io.grpc.ServerMethodDefinition; import io.grpc.ServerServiceDefinition; -import io.grpc.ServerServiceDefinition.ServerMethodDefinition; import io.grpc.ServiceDescriptor; import org.junit.After;