当前位置: 首页>>代码示例>>Java>>正文


Java SocketFactory.getDefault方法代码示例

本文整理汇总了Java中javax.net.SocketFactory.getDefault方法的典型用法代码示例。如果您正苦于以下问题:Java SocketFactory.getDefault方法的具体用法?Java SocketFactory.getDefault怎么用?Java SocketFactory.getDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.net.SocketFactory的用法示例。


在下文中一共展示了SocketFactory.getDefault方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDefaultSocketFactory

import javax.net.SocketFactory; //导入方法依赖的package包/类
/**
 * Get the default socket factory as specified by the configuration
 * parameter <tt>hadoop.rpc.socket.factory.default</tt>
 * 
 * @param conf the configuration
 * @return the default socket factory as specified in the configuration or
 *         the JVM default socket factory if the configuration does not
 *         contain a default socket factory property.
 */
public static SocketFactory getDefaultSocketFactory(Configuration conf) {

  String propValue = conf.get(
      CommonConfigurationKeysPublic.HADOOP_RPC_SOCKET_FACTORY_CLASS_DEFAULT_KEY,
      CommonConfigurationKeysPublic.HADOOP_RPC_SOCKET_FACTORY_CLASS_DEFAULT_DEFAULT);
  if ((propValue == null) || (propValue.length() == 0))
    return SocketFactory.getDefault();

  return getSocketFactoryFromProperty(conf, propValue);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:NetUtils.java

示例2: copyWithDefaults

import javax.net.SocketFactory; //导入方法依赖的package包/类
OkHttpClient copyWithDefaults() {
    OkHttpClient result = new OkHttpClient(this);
    if (result.proxySelector == null) {
        result.proxySelector = ProxySelector.getDefault();
    }
    if (result.cookieHandler == null) {
        result.cookieHandler = CookieHandler.getDefault();
    }
    if (result.socketFactory == null) {
        result.socketFactory = SocketFactory.getDefault();
    }
    if (result.sslSocketFactory == null) {
        result.sslSocketFactory = getDefaultSSLSocketFactory();
    }
    if (result.hostnameVerifier == null) {
        result.hostnameVerifier = OkHostnameVerifier.INSTANCE;
    }
    if (result.certificatePinner == null) {
        result.certificatePinner = CertificatePinner.DEFAULT;
    }
    if (result.authenticator == null) {
        result.authenticator = AuthenticatorAdapter.INSTANCE;
    }
    if (result.connectionPool == null) {
        result.connectionPool = ConnectionPool.getDefault();
    }
    if (result.protocols == null) {
        result.protocols = DEFAULT_PROTOCOLS;
    }
    if (result.connectionSpecs == null) {
        result.connectionSpecs = DEFAULT_CONNECTION_SPECS;
    }
    if (result.dns == null) {
        result.dns = Dns.SYSTEM;
    }
    return result;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:38,代码来源:OkHttpClient.java

示例3: selectSocketFactory

import javax.net.SocketFactory; //导入方法依赖的package包/类
public SocketFactory selectSocketFactory(boolean secure)
{
    if (secure)
    {
        if (mSSLContext != null)
        {
            return mSSLContext.getSocketFactory();
        }

        if (mSSLSocketFactory != null)
        {
            return mSSLSocketFactory;
        }

        return SSLSocketFactory.getDefault();
    }

    if (mSocketFactory != null)
    {
        return mSocketFactory;
    }

    return SocketFactory.getDefault();
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:25,代码来源:SocketFactorySettings.java

示例4: setUp

import javax.net.SocketFactory; //导入方法依赖的package包/类
@Before public void setUp() throws Exception {
  socketFactory = SocketFactory.getDefault();
  hostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:RouteSelectorTest.java

示例5: PCloudAPIClient

import javax.net.SocketFactory; //导入方法依赖的package包/类
private PCloudAPIClient(Builder builder) {
    this.connectTimeoutMs = builder.connectTimeoutMs;
    this.writeTimeoutMs = builder.writeTimeoutMs;
    this.readTimeoutMs = builder.readTimeoutMs;

    this.socketFactory = builder.socketFactory != null ? builder.socketFactory : SocketFactory.getDefault();

    this.sslSocketFactory = builder.sslSocketFactory != null ?
                    builder.sslSocketFactory : (SSLSocketFactory) SSLSocketFactory.getDefault();

    this.hostnameVerifier = builder.hostnameVerifier != null ?
                    builder.hostnameVerifier : DefaultHostnameVerifier.INSTANCE;

    this.connectionPool = builder.connectionPool != null ? builder.connectionPool : new ConnectionPool();
    this.endpointProvider = builder.endpointProvider != null ? builder.endpointProvider : EndpointProvider.DEFAULT;

    ConnectionFactory connectionFactory = new ConnectionFactory(socketFactory, sslSocketFactory, hostnameVerifier);
    this.connectionProvider = new ConnectionProvider(connectionPool, endpointProvider, connectionFactory,
            connectTimeoutMs, readTimeoutMs, writeTimeoutMs, false);

    ThreadFactory threadFactory = new ThreadFactory() {
        @Override
        public Thread newThread(Runnable r) {
            return new Thread(r, "PCloud API Client");
        }
    };
    this.callExecutor = builder.callExecutor != null ?
            builder.callExecutor : new ThreadPoolExecutor(0,
            Integer.MAX_VALUE,
            DEFAULT_KEEP_ALIVE_TIME_MS,
            TimeUnit.SECONDS,
            new SynchronousQueue<Runnable>(),
            threadFactory);

    this.interceptors = Collections.unmodifiableList(new ArrayList<>(builder.interceptors));
}
 
开发者ID:pCloud,项目名称:pcloud-networking-java,代码行数:37,代码来源:PCloudAPIClient.java

示例6: connect

import javax.net.SocketFactory; //导入方法依赖的package包/类
public void connect()
{
	if(reconnect != null)
		reconnect.cancel(); // No race condition because it all runs on the main thread
	if(connection != null)
		connection.disconnect();

	SocketFactory factory;
	if(preferences.isSSL())
		try
		{
			SSLContext context = SSLContext.getInstance("SSL");
			context.init(null, trustAllCerts, new SecureRandom());
			factory = context.getSocketFactory();
		}
		catch(GeneralSecurityException e)
		{
			tab.putLine(new TextEvent(ERROR, e.toString()));
			Log.d("BananaPeel", "", e);
			return;
		}
	else
		factory = SocketFactory.getDefault();

	connection = new IRCConnection(this, factory);
	connection.connect(preferences.getHost(), preferences.getPort());
}
 
开发者ID:mniip,项目名称:bananapeel,代码行数:28,代码来源:IRCServer.java

示例7: openConnection

import javax.net.SocketFactory; //导入方法依赖的package包/类
private MessageWriteTarget openConnection(SocketAddress addr, ProtobufConnection<TwoWayChannelMessage> parser) throws Exception {
    if (clientType == 0 || clientType == 1) {
        channels.openConnection(addr, parser);
        if (parser.writeTarget.get() == null)
            Thread.sleep(100);
        return parser.writeTarget.get();
    } else if (clientType == 2)
        return new NioClient(addr, parser, 100);
    else if (clientType == 3)
        return new BlockingClient(addr, parser, 100, SocketFactory.getDefault(), null);
    else
        throw new RuntimeException();
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:14,代码来源:NetworkAbstractionTests.java

示例8: getDefaultSocketFactory

import javax.net.SocketFactory; //导入方法依赖的package包/类
public static SocketFactory getDefaultSocketFactory(Configuration conf) {
  return SocketFactory.getDefault();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:4,代码来源:NetUtils.java

示例9: newAddress

import javax.net.SocketFactory; //导入方法依赖的package包/类
private Address newAddress(String name) {
  return new Address(name, 1, Dns.SYSTEM, SocketFactory.getDefault(), null, null, null,
      new RecordingOkAuthenticator("password"), null, Collections.<Protocol>emptyList(),
      Collections.<ConnectionSpec>emptyList(),
      ProxySelector.getDefault());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:ConnectionPoolTest.java

示例10: provideSocketFactory

import javax.net.SocketFactory; //导入方法依赖的package包/类
@Provides
SocketFactory provideSocketFactory() {
	return SocketFactory.getDefault();
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:5,代码来源:TestSocksModule.java

示例11: BlockingClientManager

import javax.net.SocketFactory; //导入方法依赖的package包/类
public BlockingClientManager() {
    socketFactory = SocketFactory.getDefault();
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:4,代码来源:BlockingClientManager.java

示例12: connect

import javax.net.SocketFactory; //导入方法依赖的package包/类
protected InboundMessageQueuer connect(Peer peer, VersionMessage versionMessage) throws Exception {
    checkArgument(versionMessage.hasBlockChain());
    final AtomicBoolean doneConnecting = new AtomicBoolean(false);
    final Thread thisThread = Thread.currentThread();
    peer.addDisconnectedEventListener(new PeerDisconnectedEventListener() {
        @Override
        public void onPeerDisconnected(Peer p, int peerCount) {
            synchronized (doneConnecting) {
                if (!doneConnecting.get())
                    thisThread.interrupt();
            }
        }
    });
    if (clientType == ClientType.NIO_CLIENT_MANAGER || clientType == ClientType.BLOCKING_CLIENT_MANAGER)
        channels.openConnection(new InetSocketAddress("127.0.0.1", 2000), peer);
    else if (clientType == ClientType.NIO_CLIENT)
        new NioClient(new InetSocketAddress("127.0.0.1", 2000), peer, 100);
    else if (clientType == ClientType.BLOCKING_CLIENT)
        new BlockingClient(new InetSocketAddress("127.0.0.1", 2000), peer, 100, SocketFactory.getDefault(), null);
    else
        throw new RuntimeException();
    // Claim we are connected to a different IP that what we really are, so tx confidence broadcastBy sets work
    InboundMessageQueuer writeTarget = newPeerWriteTargetQueue.take();
    writeTarget.peer = peer;
    // Complete handshake with the peer - send/receive version(ack)s, receive bloom filter
    checkState(!peer.getVersionHandshakeFuture().isDone());
    writeTarget.sendMessage(versionMessage);
    writeTarget.sendMessage(new VersionAck());
    try {
        checkState(writeTarget.nextMessageBlocking() instanceof VersionMessage);
        checkState(writeTarget.nextMessageBlocking() instanceof VersionAck);
        peer.getVersionHandshakeFuture().get();
        synchronized (doneConnecting) {
            doneConnecting.set(true);
        }
        Thread.interrupted(); // Clear interrupted bit in case it was set before we got into the CS
    } catch (InterruptedException e) {
        // We were disconnected before we got back version/verack
    }
    return writeTarget;
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:42,代码来源:TestWithNetworkConnections.java

示例13: getDefaultSocketFactory

import javax.net.SocketFactory; //导入方法依赖的package包/类
/**
 * Get the default socket factory as specified by the configuration
 * parameter <tt>hadoop.rpc.socket.factory.default</tt>
 * 
 * @param conf the configuration
 * @return the default socket factory as specified in the configuration or
 *         the JVM default socket factory if the configuration does not
 *         contain a default socket factory property.
 */
public static SocketFactory getDefaultSocketFactory(Configuration conf) {

  String propValue = conf.get("hadoop.rpc.socket.factory.class.default");
  if ((propValue == null) || (propValue.length() == 0))
    return SocketFactory.getDefault();

  return getSocketFactoryFromProperty(conf, propValue);
}
 
开发者ID:spafka,项目名称:spark_deep,代码行数:18,代码来源:NetUtils.java


注:本文中的javax.net.SocketFactory.getDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。