org.apache.http.ExceptionLogger Java Examples

The following examples show how to use org.apache.http.ExceptionLogger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CliServer.java    From Repeat with Apache License 2.0 5 votes vote down vote up
@Override
protected void start() throws IOException {
	handlers = createHandlers();
	setMainBackEndHolder(backEndHolder);

	ServerBootstrap serverBootstrap = ServerBootstrap.bootstrap()
			.setLocalAddress(InetAddress.getByName("localhost"))
               .setListenerPort(port)
               .setServerInfo("RepeatCli")
			.setExceptionLogger(ExceptionLogger.STD_ERR)
			.registerHandler("/test", new UpAndRunningHandler());
	for (Entry<String, HttpHandlerWithBackend> entry : handlers.entrySet()) {
		serverBootstrap.registerHandler(entry.getKey(), entry.getValue());
	}
	server = serverBootstrap.create();

	mainThread = new Thread() {
       	@Override
       	public void run() {
       		try {
				server.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
			} catch (InterruptedException e) {
				getLogger().log(Level.SEVERE, "Interrupted when waiting for CLI server.", e);
			}
       		getLogger().info("Finished waiting for CLI server termination...");
       	}
       };
       server.start();
       mainThread.start();
       getLogger().info("CLI server up and running...");
}
 
Example #2
Source File: UIServer.java    From Repeat with Apache License 2.0 5 votes vote down vote up
@Override
protected void start() throws IOException {
	if (!portFree()) {
		getLogger().warning("Failed to initialize " + getName() + ". Port " + port + " is not free.");
		throw new IOException("Port " + port + " is not free.");
	}

	handlers = createHandlers();
	taskActivationConstructorManager.start();
	manuallyBuildActionConstructorManager.start();
	setMainBackEndHolder(backEndHolder);

	ServerBootstrap serverBootstrap = ServerBootstrap.bootstrap()
               .setLocalAddress(InetAddress.getByName("localhost"))
               .setIOReactorConfig(IOReactorConfig.custom().setSoReuseAddress(true).build())
               .setListenerPort(port)
               .setServerInfo("Repeat")
			.setExceptionLogger(ExceptionLogger.STD_ERR)
			.registerHandler("/test", new UpAndRunningHandler())
			.registerHandler("/static/*", new StaticFileServingHandler(BootStrapResources.getWebUIResource().getStaticDir().getAbsolutePath()));
	for (Entry<String, HttpHandlerWithBackend> entry : handlers.entrySet()) {
		serverBootstrap.registerHandler(entry.getKey(), entry.getValue());
	}
	server = serverBootstrap.create();

	mainThread = new Thread() {
       	@Override
       	public void run() {
       		try {
				server.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
			} catch (InterruptedException e) {
				getLogger().log(Level.SEVERE, "Interrupted when waiting for UI server.", e);
			}
       		getLogger().info("Finished waiting for UI server termination...");
       	}
       };
       server.start();
       mainThread.start();
       getLogger().info("UI server up and running...");
}
 
Example #3
Source File: SerialiseToHTTPTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void setupServer() throws MessagingException, IOException {
    mapper = new UriHttpRequestHandlerMapper();

    SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(50000).build();
    server = ServerBootstrap.bootstrap().setListenerPort(0).setSocketConfig(socketConfig)
            .setExceptionLogger(ExceptionLogger.NO_OP).setHandlerMapper(mapper).create();

    server.start();

}
 
Example #4
Source File: HeadersToHTTPTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void setupServer() throws Exception {
    mapper = new UriHttpRequestHandlerMapper();

    SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(50000).build();
    server = ServerBootstrap.bootstrap().setListenerPort(0).setSocketConfig(socketConfig)
            .setExceptionLogger(ExceptionLogger.NO_OP).setHandlerMapper(mapper).create();

    server.start();
}
 
Example #5
Source File: NHttpFileServer.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
private NHttpFileServer start() throws KeyManagementException, UnrecoverableKeyException, NoSuchAlgorithmException,
        KeyStoreException, CertificateException, IOException, InterruptedException {
    SSLContext sslContext = null;
    if (port == 8443) {
        // Initialize SSL context
        final URL url = NHttpFileServer.class.getResource("/test.keystore");
        if (url == null) {
            debug("Keystore not found");
            System.exit(1);
        }
        debug("Loading keystore " + url);
        sslContext = SSLContexts.custom()
                .loadKeyMaterial(url, "nopassword".toCharArray(), "nopassword".toCharArray()).build();
    }

    final IOReactorConfig config = IOReactorConfig.custom().setSoTimeout(15000).setTcpNoDelay(true).build();

    // @formatter:off
    server = ServerBootstrap.bootstrap()
            .setListenerPort(port)
            .setServerInfo("Test/1.1")
            .setIOReactorConfig(config)
            .setSslContext(sslContext)
            .setExceptionLogger(ExceptionLogger.STD_ERR)
            .registerHandler("*", new HttpFileHandler(docRoot)).create();
    // @formatter:on

    server.start();
    debug("Serving " + docRoot + " on " + server.getEndpoint().getAddress()
            + (sslContext == null ? "" : " with " + sslContext.getProvider() + " " + sslContext.getProtocol()));
    server.getEndpoint().waitFor();
    // Thread.sleep(startWaitMillis); // hack
    return this;
}