Permalink
Browse files

[server] - allow overriding of JettyWebServer subcomponents creation

This allow to create a JettyWebServer with some tweaking, e.g. add init parameter
 to default servlet.
  • Loading branch information...
xhanin committed Nov 4, 2014
1 parent 352c463 commit 6378fa69f3aa5232c3d8d97202210bf95d04a8ee
Showing with 4 additions and 8 deletions.
  1. +4 −8 restx-server-jetty/src/main/java/restx/server/JettyWebServer.java
@@ -1,8 +1,6 @@
package restx.server;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.eventbus.EventBus;
import org.eclipse.jetty.security.DefaultIdentityService;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Handler;
@@ -17,10 +15,8 @@
import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import restx.common.MoreFiles;
import restx.common.Version;
import java.io.File;
import java.util.concurrent.atomic.AtomicLong;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -136,21 +132,21 @@ public synchronized boolean isStarted() {
return server != null;
}
private ThreadPool createThreadPool() {
protected ThreadPool createThreadPool() {
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMinThreads(1);
threadPool.setMaxThreads(Math.max(10, Runtime.getRuntime().availableProcessors()));
return threadPool;
}
private SelectChannelConnector createConnector() {
protected SelectChannelConnector createConnector() {
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
connector.setHost(bindInterface);
return connector;
}
private HandlerCollection createHandlers(WebAppContext webAppContext) {
protected HandlerCollection createHandlers(WebAppContext webAppContext) {
HandlerList contexts = new HandlerList();
contexts.setHandlers(new Handler[]{webAppContext});
@@ -161,7 +157,7 @@ private HandlerCollection createHandlers(WebAppContext webAppContext) {
return result;
}
private WebAppContext createContext() {
protected WebAppContext createContext() {
final WebAppContext ctx = new WebAppContext();
ctx.setContextPath("/");
ctx.setWar(appBase);

0 comments on commit 6378fa6

Please sign in to comment.