Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.github.rmannibucau.featuredmock.http;
 
public class FeaturedHttpServerBuilder {
    private String host = "localhost";
    private int port = 8080;
    private int threads = 8;
    private boolean ssl = false;
    private String protocol = "TLS";
    private SecureRandom secureRandom;
    private TrustManager[] trustManagers;
    private KeyManager[] keyManagers;
    public FeaturedHttpServerBuilder host(final String host) {
        this. = host;
        return this;
    }
    public FeaturedHttpServerBuilder port(final int port) {
        this. = port;
        return this;
    }
    public FeaturedHttpServerBuilder threads(final int threads) {
        this. = threads;
        return this;
    }
    public FeaturedHttpServerBuilder ssl() {
        this. = true;
        return this;
    }
    public FeaturedHttpServerBuilder secureRandom(final SecureRandom secureRandom) {
        this. = secureRandom;
        return this;
    }
    public FeaturedHttpServerBuilder trustManagers(final TrustManager[] trustManagers) {
        this. = trustManagers;
        return this;
    }
    public FeaturedHttpServerBuilder keyManagers(final KeyManager[] keyManagers) {
        this. = keyManagers;
        return this;
    }
    public FeaturedHttpServerBuilder protocol(final String protocol) {
        this. = protocol;
        return this;
    }
    public FeaturedHttpServerBuilder mapper(final ContentTypeMapper mapper) {
        .add(mapper);
        return this;
    }
    public FeaturedHttpServer build() {
        final SSLEngine engine;
        if () {
            SSLContext clientContext;
            try {
                clientContext = SSLContext.getInstance();
                clientContext.init();
            } catch (final Exception e) {
                throw new Error(
                    "Failed to initialize the client-side SSLContext"e);
            }
            engine = clientContext.createSSLEngine();
            engine.setUseClientMode(true);
        } else {
            engine = null;
        }
        return new DefaultFeaturedHttpServer(.toArray(new ContentTypeMapper[.size()]), engine);
    }
New to GrepCode? Check out our FAQ X