Example usage for java.net Socket setSocketImplFactory

List of usage examples for java.net Socket setSocketImplFactory

Introduction

In this page you can find the example usage for java.net Socket setSocketImplFactory.

Prototype

public static synchronized void setSocketImplFactory(SocketImplFactory fac) throws IOException 

Source Link

Document

Sets the client socket implementation factory for the application.

Usage

From source file:com.github.caldav4j.support.HttpClientTestUtils.java

private static void setSocketImplFactory(SocketImplFactory factory) throws IOException {
    if (delegatingSocketImplFactory == null) {
        delegatingSocketImplFactory = new DelegatingSocketImplFactory(factory);

        // this can only be called once per JVM instance
        Socket.setSocketImplFactory(delegatingSocketImplFactory);
    } else {//from   w w w.j av  a  2  s.com
        delegatingSocketImplFactory.setDelegate(factory);
    }
}

From source file:com.twitter.pig.backend.hadoop.executionengine.tez.TezExecutionEngine.java

@SuppressWarnings({ "unchecked", "rawtypes" })
private void setSSHFactory() {
    Properties properties = this.pigContext.getProperties();
    String g = properties.getProperty("ssh.gateway");
    if (g == null || g.length() == 0)
        return;/*from w w  w. j  av  a 2 s . c  o  m*/
    try {
        Class clazz = Class.forName("org.apache.pig.shock.SSHSocketImplFactory");
        SocketImplFactory f = (SocketImplFactory) clazz.getMethod("getFactory", new Class[0]).invoke(0,
                new Object[0]);
        Socket.setSocketImplFactory(f);
    } catch (SocketException e) {
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.jboss.as.capedwarf.extension.CapedwarfSubsystemAdd.java

protected static void registerSocketFactory() throws OperationFailedException {
    try {/*w w  w. j a v a  2s.com*/
        Socket.setSocketImplFactory(CapedwarfSocketFactory.INSTANCE);
        DatagramSocket.setDatagramSocketImplFactory(CapedwarfSocketFactory.INSTANCE);
    } catch (IOException e) {
        throw new OperationFailedException(e.getMessage(), e);
    }
}

From source file:org.apache.pig.backend.hadoop.executionengine.MRExecutionEngine.java

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void setSSHFactory() {
    Properties properties = this.pigContext.getProperties();
    String g = properties.getProperty("ssh.gateway");
    if (g == null || g.length() == 0)
        return;/*  ww  w  . java 2s.  c om*/
    try {
        Class clazz = Class.forName("org.apache.pig.shock.SSHSocketImplFactory");
        SocketImplFactory f = (SocketImplFactory) clazz.getMethod("getFactory", new Class[0]).invoke(0,
                new Object[0]);
        Socket.setSocketImplFactory(f);
    } catch (SocketException e) {
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.apache.pig.shock.SSHSocketImplFactory.java

static public void main(String args[]) {
    try {/*from w  ww .java 2s. c  om*/
        System.setProperty("ssh.gateway", "ucdev2");
        final SSHSocketImplFactory fac = SSHSocketImplFactory.getFactory();
        Socket.setSocketImplFactory(fac);
        for (int i = 0; i < 10; i++) {
            new Thread() {
                @Override
                public void run() {
                    try {
                        log.error("Starting " + this);
                        connectTest("www.yahoo.com");
                        log.error("Finished " + this);
                    } catch (Exception e) {
                        log.error(e);
                    }
                }
            }.start();
        }
        Thread.sleep(1000000);
        connectTest("www.news.com");
        log.info("******** Starting PART II");
        for (int i = 0; i < 10; i++) {
            new Thread() {
                @Override
                public void run() {
                    try {
                        log.error("Starting " + this);
                        connectTest("www.flickr.com");
                        log.error("Finished " + this);
                    } catch (Exception e) {
                        log.error(e);
                    }
                }
            }.start();
        }
    } catch (Exception e) {
        log.error(e);
    }
}