當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。