return new Server(component.getContext().createChildContext(), Protocol.valueOf(endpoint.getProtocol()), endpoint.getPort());
}
protected void addServerIfNecessary(RestletEndpoint endpoint) throws Exception {
String key = buildKey(endpoint);
Server server;
synchronized (servers) {
server = servers.get(key);
if (server == null) {
server = createServer(endpoint);
component.getServers().add(server);
// Add any Restlet server parameters that were included
Series<Parameter> params = server.getContext().getParameters();
if (getControllerDaemon() != null) {
params.add("controllerDaemon", getControllerDaemon().toString());
}
if (getControllerSleepTimeMs() != null) {
params.add("controllerSleepTimeMs", getControllerSleepTimeMs().toString());
}
if (getInboundBufferSize() != null) {
params.add("inboundBufferSize", getInboundBufferSize().toString());
}
if (getMinThreads() != null) {
params.add("minThreads", getMinThreads().toString());
}
if (getMaxThreads() != null) {
params.add("maxThreads", getMaxThreads().toString());
}
if (getMaxConnectionsPerHost() != null) {
params.add("maxConnectionsPerHost", getMaxConnectionsPerHost().toString());
}
if (getMaxTotalConnections() != null) {
params.add("maxTotalConnections", getMaxTotalConnections().toString());
}
if (getOutboundBufferSize() != null) {
params.add("outboundBufferSize", getOutboundBufferSize().toString());
}
if (getPersistingConnections() != null) {
params.add("persistingConnections", getPersistingConnections().toString());
}
if (getPipeliningConnections() != null) {
params.add("pipeliningConnections", getPipeliningConnections().toString());
}
if (getThreadMaxIdleTimeMs() != null) {
params.add("threadMaxIdleTimeMs", getThreadMaxIdleTimeMs().toString());
}
if (getUseForwardedForHeader() != null) {
params.add("useForwardedForHeader", getUseForwardedForHeader().toString());
}
LOG.debug("Setting parameters: {} to server: {}", params, server);
server.getContext().setParameters(params);
servers.put(key, server);
LOG.debug("Added server: {}", key);
server.start();
}
}
}