Package org.apache.http.conn.scheme

Examples of org.apache.http.conn.scheme.SchemeSocketFactory


        Args.notNull(params, "HTTP parameters");
        Asserts.check(!conn.isOpen(), "Connection must not be open");

        final SchemeRegistry registry = getSchemeRegistry(context);
        final Scheme schm = registry.getScheme(target.getSchemeName());
        final SchemeSocketFactory sf = schm.getSchemeSocketFactory();

        final InetAddress[] addresses = resolveHostname(target.getHostName());
        final int port = schm.resolvePort(target.getPort());
        for (int i = 0; i < addresses.length; i++) {
            final InetAddress address = addresses[i];
            final boolean last = i == addresses.length - 1;

            Socket sock = sf.createSocket(params);
            conn.opening(sock, target);

            final InetSocketAddress remoteAddress = new HttpInetSocketAddress(target, address, port);
            InetSocketAddress localAddress = null;
            if (local != null) {
                localAddress = new InetSocketAddress(local, 0);
            }
            if (this.log.isDebugEnabled()) {
                this.log.debug("Connecting to " + remoteAddress);
            }
            try {
                final Socket connsock = sf.connectSocket(sock, remoteAddress, localAddress, params);
                if (sock != connsock) {
                    sock = connsock;
                    conn.opening(sock, target);
                }
                prepareSocket(sock, context, params);
                conn.openCompleted(sf.isSecure(sock), params);
                return;
            } catch (final ConnectException ex) {
                if (last) {
                    throw ex;
                }
View Full Code Here


        HttpHost target = new HttpHost("www.apache.org", 80, "http");

        // Register the "http" protocol scheme, it is required
        // by the default operator to look up socket factories.
        SchemeRegistry supportedSchemes = new SchemeRegistry();
        SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
        supportedSchemes.register(new Scheme("http", 80, sf));

        // Prepare parameters.
        // Since this example doesn't use the full core framework,
        // only few parameters are actually required.
View Full Code Here

            HttpProtocolParams.setUseExpectContinue(defaultParams, false);
        }

        if (supportedSchemes == null) {
            supportedSchemes = new SchemeRegistry();
            SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
            supportedSchemes.register(new Scheme("http", 80, sf));
        }

        if (httpProcessor == null) {
            httpProcessor = new BasicHttpProcessor();
View Full Code Here

            if (conn.isOpen()) {
                throw new IllegalStateException("Connection must not be open");
            }

            Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
            SchemeSocketFactory sf = schm.getSchemeSocketFactory();

            //long start = System.nanoTime();
            long start = System.currentTimeMillis();
            InetAddress[] addresses = resolveHostname(target.getHostName());
            // long dnsEnd = System.nanoTime();
            long dnsEnd = System.currentTimeMillis();

            int port = schm.resolvePort(target.getPort());
            for (int i = 0; i < addresses.length; i++) {
                InetAddress address = addresses[i];
                boolean last = i == addresses.length - 1;

                Socket sock = sf.createSocket(params);
                conn.opening(sock, target);

                InetSocketAddress remoteAddress = new InetSocketAddress(address, port);
                InetSocketAddress localAddress = null;
                if (local != null) {
                    localAddress = new InetSocketAddress(local, 0);
                }
                if (log.isDebugEnabled()) {
                    log.debug("Connecting to " + remoteAddress);
                }
                try {
                    Socket connsock = sf.connectSocket(sock, remoteAddress, localAddress, params);
                    if (sock != connsock) {
                        sock = connsock;
                        conn.opening(sock, target);
                    }
                    prepareSocket(sock, context, params);
                    conn.openCompleted(sf.isSecure(sock), params);

                    SoapUIMetrics metrics = (SoapUIMetrics) conn.getMetrics();

                    if (metrics != null) {
                        metrics.getDNSTimer().set(start, dnsEnd);
View Full Code Here

    @Override
    protected boolean initiateClient()
    {
        try
        {
            SchemeSocketFactory ssf = null;
            ssf = PlainSocketFactory.getSocketFactory();
            SchemeRegistry schemeRegistry = new SchemeRegistry();
            schemeRegistry.register(new Scheme("http", Integer.parseInt(port), ssf));
            PoolingClientConnectionManager ccm = new PoolingClientConnectionManager(schemeRegistry);
            httpClient = new DefaultHttpClient(ccm);
View Full Code Here

    public static HttpClient initiateHttpClient(final KunderaMetadata kunderaMetadata, String persistenceUnit)
    {
        PersistenceUnitMetadata pumMetadata = KunderaMetadataManager.getPersistenceUnitMetadata(kunderaMetadata,
                persistenceUnit);

        SchemeSocketFactory ssf = null;
        ssf = PlainSocketFactory.getSocketFactory();
        SchemeRegistry schemeRegistry = new SchemeRegistry();
        int port = Integer.parseInt(pumMetadata.getProperty(PersistenceProperties.KUNDERA_PORT));
        String host = pumMetadata.getProperty(PersistenceProperties.KUNDERA_NODES);
        String userName = pumMetadata.getProperty(PersistenceProperties.KUNDERA_USERNAME);
View Full Code Here

        }

        onValidation(contactNode, defaultPort);
        try
        {
            SchemeSocketFactory ssf = null;
            ssf = PlainSocketFactory.getSocketFactory();
            SchemeRegistry schemeRegistry = new SchemeRegistry();
            schemeRegistry.register(new Scheme(CouchDBConstants.PROTOCOL, Integer.parseInt(defaultPort), ssf));
            PoolingClientConnectionManager ccm = new PoolingClientConnectionManager(schemeRegistry);
            httpClient = new DefaultHttpClient(ccm);
View Full Code Here

    public HttpClient initiateClient(String host, int port)
    {
        if (httpClient == null || httpHost == null)
        {
            SchemeSocketFactory ssf = null;
            ssf = PlainSocketFactory.getSocketFactory();
            SchemeRegistry schemeRegistry = new SchemeRegistry();

            schemeRegistry.register(new Scheme("http", port, ssf));
            PoolingClientConnectionManager ccm = new PoolingClientConnectionManager(schemeRegistry);
View Full Code Here

    if (paramHttpParams == null)
      throw new IllegalArgumentException("Parameters may not be null");
    if (paramOperatedClientConnection.isOpen())
      throw new IllegalStateException("Connection must not be open");
    Scheme localScheme = this.schemeRegistry.getScheme(paramHttpHost.getSchemeName());
    SchemeSocketFactory localSchemeSocketFactory = localScheme.getSchemeSocketFactory();
    InetAddress[] arrayOfInetAddress = resolveHostname(paramHttpHost.getHostName());
    int i = localScheme.resolvePort(paramHttpHost.getPort());
    for (int j = 0; j < arrayOfInetAddress.length; j++)
    {
      InetAddress localInetAddress = arrayOfInetAddress[j];
      int k = j == arrayOfInetAddress.length - 1 ? 1 : 0;
      Object localObject = localSchemeSocketFactory.createSocket(paramHttpParams);
      paramOperatedClientConnection.opening((Socket)localObject, paramHttpHost);
      HttpInetSocketAddress localHttpInetSocketAddress = new HttpInetSocketAddress(paramHttpHost, localInetAddress, i);
      InetSocketAddress localInetSocketAddress = null;
      if (paramInetAddress != null)
        localInetSocketAddress = new InetSocketAddress(paramInetAddress, 0);
      if (this.log.isDebugEnabled())
        this.log.debug("Connecting to " + localHttpInetSocketAddress);
      try
      {
        Socket localSocket = localSchemeSocketFactory.connectSocket((Socket)localObject, localHttpInetSocketAddress, localInetSocketAddress, paramHttpParams);
        if (localObject != localSocket)
        {
          localObject = localSocket;
          paramOperatedClientConnection.opening((Socket)localObject, paramHttpHost);
        }
        prepareSocket((Socket)localObject, paramHttpContext, paramHttpParams);
        paramOperatedClientConnection.openCompleted(localSchemeSocketFactory.isSecure((Socket)localObject), paramHttpParams);
        return;
      }
      catch (ConnectException localConnectException)
      {
        if (k != 0)
View Full Code Here

        Args.notNull(params, "HTTP parameters");
        Asserts.check(!conn.isOpen(), "Connection must not be open");

        final SchemeRegistry registry = getSchemeRegistry(context);
        final Scheme schm = registry.getScheme(target.getSchemeName());
        final SchemeSocketFactory sf = schm.getSchemeSocketFactory();

        final InetAddress[] addresses = resolveHostname(target.getHostName());
        final int port = schm.resolvePort(target.getPort());
        for (int i = 0; i < addresses.length; i++) {
            final InetAddress address = addresses[i];
            final boolean last = i == addresses.length - 1;

            Socket sock = sf.createSocket(params);
            conn.opening(sock, target);

            final InetSocketAddress remoteAddress = new HttpInetSocketAddress(target, address, port);
            InetSocketAddress localAddress = null;
            if (local != null) {
                localAddress = new InetSocketAddress(local, 0);
            }
            if (this.log.isDebugEnabled()) {
                this.log.debug("Connecting to " + remoteAddress);
            }
            try {
                final Socket connsock = sf.connectSocket(sock, remoteAddress, localAddress, params);
                if (sock != connsock) {
                    sock = connsock;
                    conn.opening(sock, target);
                }
                prepareSocket(sock, context, params);
                conn.openCompleted(sf.isSecure(sock), params);
                return;
            } catch (final ConnectException ex) {
                if (last) {
                    throw ex;
                }
View Full Code Here

TOP

Related Classes of org.apache.http.conn.scheme.SchemeSocketFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.