369214: HotSwapHandler code format
This commit is contained in:
parent
5c0c8c7e73
commit
ab5592daf0
|
@ -24,8 +24,8 @@ import org.eclipse.jetty.server.Request;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/** A <code>HandlerContainer</code> that allows a hot swap
|
/**
|
||||||
* of a wrapped handler.
|
* A <code>HandlerContainer</code> that allows a hot swap of a wrapped handler.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class HotSwapHandler extends AbstractHandlerContainer
|
public class HotSwapHandler extends AbstractHandlerContainer
|
||||||
|
@ -48,19 +48,21 @@ public class HotSwapHandler extends AbstractHandlerContainer
|
||||||
{
|
{
|
||||||
return _handler;
|
return _handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @return Returns the handlers.
|
* @return Returns the handlers.
|
||||||
*/
|
*/
|
||||||
public Handler[] getHandlers()
|
public Handler[] getHandlers()
|
||||||
{
|
{
|
||||||
return new Handler[] {_handler};
|
return new Handler[]
|
||||||
|
{ _handler };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @param handler Set the {@link Handler} which should be wrapped.
|
* @param handler
|
||||||
|
* Set the {@link Handler} which should be wrapped.
|
||||||
*/
|
*/
|
||||||
public void setHandler(Handler handler)
|
public void setHandler(Handler handler)
|
||||||
{
|
{
|
||||||
|
@ -68,17 +70,16 @@ public class HotSwapHandler extends AbstractHandlerContainer
|
||||||
{
|
{
|
||||||
Handler old_handler = _handler;
|
Handler old_handler = _handler;
|
||||||
_handler = handler;
|
_handler = handler;
|
||||||
if (handler!=null)
|
if (handler != null)
|
||||||
{
|
{
|
||||||
handler.setServer(getServer());
|
handler.setServer(getServer());
|
||||||
if (isStarted())
|
if (isStarted())
|
||||||
handler.start();
|
handler.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getServer()!=null)
|
if (getServer() != null)
|
||||||
getServer().getContainer().update(this, old_handler, handler, "handler");
|
getServer().getContainer().update(this,old_handler,handler,"handler");
|
||||||
|
|
||||||
|
|
||||||
// if there is an old handler and it was started, stop it
|
// if there is an old handler and it was started, stop it
|
||||||
if (old_handler != null && isStarted())
|
if (old_handler != null && isStarted())
|
||||||
{
|
{
|
||||||
|
@ -86,74 +87,73 @@ public class HotSwapHandler extends AbstractHandlerContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(RuntimeException e)
|
catch (RuntimeException e)
|
||||||
{
|
{
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.thread.AbstractLifeCycle#doStart()
|
* @see org.eclipse.thread.AbstractLifeCycle#doStart()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws Exception
|
protected void doStart() throws Exception
|
||||||
{
|
{
|
||||||
if (_handler!=null)
|
if (_handler != null)
|
||||||
_handler.start();
|
_handler.start();
|
||||||
super.doStart();
|
super.doStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.thread.AbstractLifeCycle#doStop()
|
* @see org.eclipse.thread.AbstractLifeCycle#doStop()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void doStop() throws Exception
|
protected void doStop() throws Exception
|
||||||
{
|
{
|
||||||
super.doStop();
|
super.doStop();
|
||||||
if (_handler!=null)
|
if (_handler != null)
|
||||||
_handler.stop();
|
_handler.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jetty.server.server.EventHandler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
* @see org.eclipse.jetty.server.server.EventHandler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||||
*/
|
*/
|
||||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (_handler!=null && isStarted())
|
if (_handler != null && isStarted())
|
||||||
{
|
{
|
||||||
_handler.handle(target,baseRequest, request, response);
|
_handler.handle(target,baseRequest,request,response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public void setServer(Server server)
|
public void setServer(Server server)
|
||||||
{
|
{
|
||||||
Server old_server=getServer();
|
Server old_server = getServer();
|
||||||
if (server==old_server)
|
if (server == old_server)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isRunning())
|
if (isRunning())
|
||||||
throw new IllegalStateException(RUNNING);
|
throw new IllegalStateException(RUNNING);
|
||||||
|
|
||||||
super.setServer(server);
|
super.setServer(server);
|
||||||
|
|
||||||
Handler h=getHandler();
|
Handler h = getHandler();
|
||||||
if (h!=null)
|
if (h != null)
|
||||||
h.setServer(server);
|
h.setServer(server);
|
||||||
|
|
||||||
if (server!=null && server!=old_server)
|
if (server != null && server != old_server)
|
||||||
server.getContainer().update(this, null,_handler, "handler");
|
server.getContainer().update(this,null,_handler,"handler");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
protected Object expandChildren(Object list, Class byClass)
|
protected Object expandChildren(Object list, Class byClass)
|
||||||
|
@ -167,8 +167,8 @@ public class HotSwapHandler extends AbstractHandlerContainer
|
||||||
{
|
{
|
||||||
if (!isStopped())
|
if (!isStopped())
|
||||||
throw new IllegalStateException("!STOPPED");
|
throw new IllegalStateException("!STOPPED");
|
||||||
Handler child=getHandler();
|
Handler child = getHandler();
|
||||||
if (child!=null)
|
if (child != null)
|
||||||
{
|
{
|
||||||
setHandler(null);
|
setHandler(null);
|
||||||
child.destroy();
|
child.destroy();
|
||||||
|
|
Loading…
Reference in New Issue