Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package io.undertow.client;
  
  import org.xnio.IoFuture;
  import org.xnio.OptionMap;
  import org.xnio.Pool;
  
 import java.net.URI;
 import java.util.Map;
Undertow client class. This class loads ClientProvider implementations, and uses them to create connections to a target.

Author(s):
Stuart Douglas
 
 public final class UndertowClient {
 
     private final Map<StringClientProviderclientProviders;
 
     private static final UndertowClient INSTANCE = new UndertowClient();
 
     private UndertowClient() {
         this(UndertowClient.class.getClassLoader());
     }
 
     private UndertowClient(final ClassLoader classLoader) {
         ServiceLoader<ClientProviderproviders = ServiceLoader.load(ClientProvider.classclassLoader);
         final Map<StringClientProvidermap = new HashMap<StringClientProvider>();
         for (ClientProvider provider : providers) {
             for (String scheme : provider.handlesSchemes()) {
                 map.put(schemeprovider);
             }
         }
         this. = Collections.unmodifiableMap(map);
     }
 
     public IoFuture<ClientConnectionconnect(final URI urifinal XnioWorker workerPool<ByteBufferbufferPoolOptionMap options) {
         ClientProvider provider = getClientProvider(uri);
         final FutureResult<ClientConnectionresult = new FutureResult<ClientConnection>();
         provider.connect(new ClientCallback<ClientConnection>() {
             @Override
             public void completed(ClientConnection r) {
                 result.setResult(r);
             }
 
             @Override
             public void failed(IOException e) {
                 result.setException(e);
             }
         }, uriworkernullbufferPooloptions
         );
         return result.getIoFuture();
     }
 
     public IoFuture<ClientConnectionconnect(final URI urifinal XnioIoThread ioThreadPool<ByteBufferbufferPoolOptionMap options) {
         ClientProvider provider = getClientProvider(uri);
         final FutureResult<ClientConnectionresult = new FutureResult<ClientConnection>();
         provider.connect(new ClientCallback<ClientConnection>() {
             @Override
             public void completed(ClientConnection r) {
                 result.setResult(r);
             }
 
             @Override
             public void failed(IOException e) {
                 result.setException(e);
             }
         }, uriioThreadnullbufferPooloptions
         );
         return result.getIoFuture();
     }
 
 
     public void connect(final ClientCallback<ClientConnectionlistenerfinal URI urifinal XnioWorker workerPool<ByteBufferbufferPoolOptionMap options) {
         ClientProvider provider = getClientProvider(uri);
         provider.connect(listeneruriworkernullbufferPooloptions);
     }
 
     public void connect(final ClientCallback<ClientConnectionlistenerfinal URI urifinal XnioIoThread ioThreadPool<ByteBufferbufferPoolOptionMap options) {
         ClientProvider provider = getClientProvider(uri);
         provider.connect(listeneruriioThreadnullbufferPooloptions);
     }
 
     private ClientProvider getClientProvider(URI uri) {
         ClientProvider provider = .get(uri.getScheme());
         if (provider == null) {
             throw ..unknownScheme(uri);
         }
         return provider;
     }
 
    public static UndertowClient getInstance() {
        return ;
    }
    public static UndertowClient getInstance(final ClassLoader classLoader) {
        return new UndertowClient(classLoader);
    }
New to GrepCode? Check out our FAQ X