abstracted AbstractHandler setServer
This commit is contained in:
parent
82dc72cac2
commit
02a1350965
|
@ -36,6 +36,7 @@ import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||||
import org.eclipse.jetty.server.handler.HandlerList;
|
import org.eclipse.jetty.server.handler.HandlerList;
|
||||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||||
import org.eclipse.jetty.server.handler.RequestLogHandler;
|
import org.eclipse.jetty.server.handler.RequestLogHandler;
|
||||||
|
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
|
||||||
import org.eclipse.jetty.util.ajax.JSON;
|
import org.eclipse.jetty.util.ajax.JSON;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +128,7 @@ public class ManyHandlers
|
||||||
|
|
||||||
// link them all together
|
// link them all together
|
||||||
wrapper.setHandler(hello);
|
wrapper.setHandler(hello);
|
||||||
list.setHandlers(new Handler[] { param, wrapper, dft });
|
list.setHandlers(new Handler[] { param, new GzipHandler(), dft });
|
||||||
handlers.setHandlers(new Handler[] { list, requestLog });
|
handlers.setHandlers(new Handler[] { list, requestLog });
|
||||||
|
|
||||||
// Handler tree looks like the following
|
// Handler tree looks like the following
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Handler;
|
import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.server.HandlerContainer;
|
import org.eclipse.jetty.server.HandlerContainer;
|
||||||
|
import org.eclipse.jetty.server.Server;
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -117,4 +118,21 @@ public abstract class AbstractHandlerContainer extends AbstractHandler implement
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
@Override
|
||||||
|
public void setServer(Server server)
|
||||||
|
{
|
||||||
|
if (server==getServer())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isStarted())
|
||||||
|
throw new IllegalStateException(STARTED);
|
||||||
|
|
||||||
|
super.setServer(server);
|
||||||
|
Handler[] handlers=getHandlers();
|
||||||
|
if (handlers!=null)
|
||||||
|
for (Handler h : handlers)
|
||||||
|
h.setServer(server);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,17 +134,6 @@ public class HandlerCollection extends AbstractHandlerContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
@Override
|
|
||||||
public void setServer(Server server)
|
|
||||||
{
|
|
||||||
super.setServer(server);
|
|
||||||
Handler[] handlers=getHandlers();
|
|
||||||
if (handlers!=null)
|
|
||||||
for (Handler h : handlers)
|
|
||||||
h.setServer(server);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/* Add a handler.
|
/* Add a handler.
|
||||||
* This implementation adds the passed handler to the end of the existing collection of handlers.
|
* This implementation adds the passed handler to the end of the existing collection of handlers.
|
||||||
|
|
|
@ -120,23 +120,6 @@ public class HandlerWrapper extends AbstractHandlerContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
@Override
|
|
||||||
public void setServer(Server server)
|
|
||||||
{
|
|
||||||
if (server==getServer())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (isStarted())
|
|
||||||
throw new IllegalStateException(STARTED);
|
|
||||||
|
|
||||||
super.setServer(server);
|
|
||||||
Handler h=getHandler();
|
|
||||||
if (h!=null)
|
|
||||||
h.setServer(server);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
protected void expandChildren(List<Handler> list, Class<?> byClass)
|
protected void expandChildren(List<Handler> list, Class<?> byClass)
|
||||||
|
|
|
@ -122,20 +122,6 @@ public class HotSwapHandler extends AbstractHandlerContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
@Override
|
|
||||||
public void setServer(Server server)
|
|
||||||
{
|
|
||||||
if (isRunning())
|
|
||||||
throw new IllegalStateException(RUNNING);
|
|
||||||
|
|
||||||
super.setServer(server);
|
|
||||||
|
|
||||||
Handler h = getHandler();
|
|
||||||
if (h != null)
|
|
||||||
h.setServer(server);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
protected void expandChildren(List<Handler> list, Class<?> byClass)
|
protected void expandChildren(List<Handler> list, Class<?> byClass)
|
||||||
|
|
|
@ -380,7 +380,8 @@ public class GzipHandler extends HandlerWrapper implements GzipFactory
|
||||||
|
|
||||||
// install interceptor and handle
|
// install interceptor and handle
|
||||||
out.setInterceptor(new GzipHttpOutputInterceptor(this,_vary,baseRequest.getHttpChannel(),out.getInterceptor()));
|
out.setInterceptor(new GzipHttpOutputInterceptor(this,_vary,baseRequest.getHttpChannel(),out.getInterceptor()));
|
||||||
_handler.handle(target,baseRequest, request, response);
|
if (_handler!=null)
|
||||||
|
_handler.handle(target,baseRequest, request, response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue