Make all transport factories package-private in favor of channel builders.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79367593
This commit is contained in:
zhangkun 2014-11-06 14:05:17 -08:00 committed by Eric Anderson
parent 776ff86687
commit a71d887661
8 changed files with 30 additions and 44 deletions

View File

@ -3,8 +3,8 @@ package com.google.net.stubby.examples;
import com.google.common.util.concurrent.SettableFuture;
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 com.google.net.stubby.transport.netty.NettyClientTransportFactory.NegotiationType;
import com.google.protos.net.stubby.examples.CalcGrpc;
import com.google.protos.net.stubby.examples.CalcGrpc.CalcBlockingStub;
import com.google.protos.net.stubby.examples.CalcGrpc.CalcStub;

View File

@ -2,8 +2,8 @@ package com.google.net.stubby.examples;
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 com.google.net.stubby.transport.netty.NettyClientTransportFactory.NegotiationType;
import com.google.protos.net.stubby.examples.StockGrpc;
import com.google.protos.net.stubby.examples.StockGrpc.StockBlockingStub;
import com.google.protos.net.stubby.examples.StockGrpc.StockStub;

View File

@ -1,26 +1,13 @@
package com.google.net.stubby.testing.integration;
import static com.google.net.stubby.testing.integration.Messages.PayloadType.COMPRESSABLE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.net.stubby.ChannelImpl;
import com.google.net.stubby.stub.StreamRecorder;
import com.google.net.stubby.testing.integration.Messages.SimpleRequest;
import com.google.net.stubby.testing.integration.Messages.SimpleResponse;
import com.google.net.stubby.testing.integration.Messages.StreamingOutputCallRequest;
import com.google.net.stubby.testing.integration.Messages.StreamingOutputCallResponse;
import com.google.net.stubby.testing.integration.TestServiceGrpc.TestService;
import com.google.net.stubby.transport.okhttp.OkHttpChannelBuilder;
import com.google.net.stubby.transport.netty.NegotiationType;
import com.google.net.stubby.transport.netty.NettyChannelBuilder;
import com.google.net.stubby.transport.netty.NettyClientTransportFactory;
import com.google.net.stubby.transport.okhttp.OkHttpChannelBuilder;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* Application that starts a client for the {@link TestServiceGrpc.TestService} and runs through a
@ -38,14 +25,14 @@ public class TestServiceClient {
@Override
public ChannelImpl createChannel(String serverHost, int serverPort) {
return NettyChannelBuilder.forAddress(serverHost, serverPort)
.negotiationType(NettyClientTransportFactory.NegotiationType.PLAINTEXT).build();
.negotiationType(NegotiationType.PLAINTEXT).build();
}
},
NETTY_TLS {
@Override
public ChannelImpl createChannel(String serverHost, int serverPort) {
return NettyChannelBuilder.forAddress(serverHost, serverPort)
.negotiationType(NettyClientTransportFactory.NegotiationType.TLS).build();
.negotiationType(NegotiationType.TLS).build();
}
},
OKHTTP {

View File

@ -0,0 +1,22 @@
package com.google.net.stubby.transport.netty;
/**
* Identifies the negotiation used for starting up HTTP/2.
*/
public enum NegotiationType {
/**
* Uses TLS ALPN/NPN negotiation, assumes an SSL connection.
*/
TLS,
/**
* Use the HTTP UPGRADE protocol for a plaintext (non-SSL) upgrade from HTTP/1.1 to HTTP/2.
*/
PLAINTEXT_UPGRADE,
/**
* Just assume the connection is plaintext (non-SSL) and the remote endpoint supports HTTP/2
* directly without an upgrade.
*/
PLAINTEXT
}

View File

@ -4,7 +4,6 @@ import com.google.common.util.concurrent.Service;
import com.google.net.stubby.AbstractChannelBuilder;
import com.google.net.stubby.SharedResourceHolder;
import com.google.net.stubby.transport.ClientTransportFactory;
import com.google.net.stubby.transport.netty.NettyClientTransportFactory.NegotiationType;
import io.netty.channel.EventLoopGroup;

View File

@ -12,7 +12,6 @@ import com.google.net.stubby.transport.AbstractClientTransport;
import com.google.net.stubby.transport.ClientStream;
import com.google.net.stubby.transport.ClientStreamListener;
import com.google.net.stubby.transport.ClientTransport;
import com.google.net.stubby.transport.netty.NettyClientTransportFactory.NegotiationType;
import com.google.net.stubby.util.ssl.SslContextFactory;
import io.netty.bootstrap.Bootstrap;

View File

@ -10,28 +10,7 @@ import java.net.InetSocketAddress;
/**
* Factory that manufactures instances of {@link NettyClientTransport}.
*/
public class NettyClientTransportFactory implements ClientTransportFactory {
/**
* Identifies the negotiation used for starting up HTTP/2.
*/
public enum NegotiationType {
/**
* Uses TLS ALPN/NPN negotiation, assumes an SSL connection.
*/
TLS,
/**
* Use the HTTP UPGRADE protocol for a plaintext (non-SSL) upgrade from HTTP/1.1 to HTTP/2.
*/
PLAINTEXT_UPGRADE,
/**
* Just assume the connection is plaintext (non-SSL) and the remote endpoint supports HTTP/2
* directly without an upgrade.
*/
PLAINTEXT
}
class NettyClientTransportFactory implements ClientTransportFactory {
private final InetSocketAddress address;
private final NegotiationType negotiationType;

View File

@ -10,7 +10,7 @@ import java.util.concurrent.ExecutorService;
/**
* Factory that manufactures instances of {@link OkHttpClientTransport}.
*/
public class OkHttpClientTransportFactory implements ClientTransportFactory {
class OkHttpClientTransportFactory implements ClientTransportFactory {
private final InetSocketAddress address;
private final ExecutorService executor;