All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rapidoid.net.ServerBuilder Maven / Gradle / Ivy

There is a newer version: 5.5.5
Show newest version
package org.rapidoid.net;

import org.rapidoid.RapidoidThing;
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;
import org.rapidoid.net.impl.RapidoidHelper;
import org.rapidoid.net.impl.RapidoidServerLoop;

/*
 * #%L
 * rapidoid-net
 * %%
 * Copyright (C) 2014 - 2016 Nikolche Mihajlovski and contributors
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

@Authors("Nikolche Mihajlovski")
@Since("5.1.0")
public class ServerBuilder extends RapidoidThing {

	private volatile String address = "0.0.0.0";

	private volatile int port = 8888;

	private volatile int workers = Runtime.getRuntime().availableProcessors();

	private volatile org.rapidoid.net.Protocol protocol = null;

	private volatile Class> exchangeClass = null;

	private volatile Class helperClass = RapidoidHelper.class;

	private volatile int bufSizeKB = 16;

	private volatile boolean noNelay = false;

	public ServerBuilder address(String address) {
		this.address = address;
		return this;
	}

	public String address() {
		return this.address;
	}

	public ServerBuilder port(int port) {
		this.port = port;
		return this;
	}

	public int port() {
		return this.port;
	}

	public ServerBuilder workers(int workers) {
		this.workers = workers;
		return this;
	}

	public int workers() {
		return this.workers;
	}

	public ServerBuilder protocol(org.rapidoid.net.Protocol protocol) {
		this.protocol = protocol;
		return this;
	}

	public org.rapidoid.net.Protocol protocol() {
		return this.protocol;
	}

	public ServerBuilder exchangeClass(Class> exchangeClass) {
		this.exchangeClass = exchangeClass;
		return this;
	}

	public Class> exchangeClass() {
		return this.exchangeClass;
	}

	public ServerBuilder helperClass(Class helperClass) {
		this.helperClass = helperClass;
		return this;
	}

	public Class helperClass() {
		return this.helperClass;
	}

	public int bufSizeKB() {
		return bufSizeKB;
	}

	public void bufSizeKB(int bufSizeKB) {
		this.bufSizeKB = bufSizeKB;
	}

	public boolean noNelay() {
		return noNelay;
	}

	public void noNelay(boolean noNelay) {
		this.noNelay = noNelay;
	}

	public Server build() {
		return new RapidoidServerLoop(protocol, exchangeClass, helperClass, address, port, workers, bufSizeKB, noNelay);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy