org.eclipse.jetty.server.handler
类 ShutdownHandler

java.lang.Object
  继承者 org.eclipse.jetty.util.component.AbstractLifeCycle
      继承者 org.eclipse.jetty.util.component.AggregateLifeCycle
          继承者 org.eclipse.jetty.server.handler.AbstractHandler
              继承者 org.eclipse.jetty.server.handler.ShutdownHandler
所有已实现的接口:
Handler, Destroyable, Dumpable, LifeCycle

public class ShutdownHandler
extends AbstractHandler

A handler that shuts the server down on a valid request. Used to do "soft" restarts from Java. If _exitJvm ist set to true a hard System.exit() call is being made. This handler is a contribution from Johannes Brodwall: https://bugs.eclipse.org/bugs/show_bug.cgi?id=357687 Usage:

    Server server = new Server(8080);
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[]
    { someOtherHandler, new ShutdownHandler(server,"secret password") });
    server.setHandler(handlers);
    server.start();
   
   public static void attemptShutdown(int port, String shutdownCookie) {
        try {
            URL url = new URL("http://localhost:" + port + "/shutdown?token=" + shutdownCookie);
            HttpURLConnection connection = (HttpURLConnection)url.openConnection();
            connection.setRequestMethod("POST");
            connection.getResponseCode();
            logger.info("Shutting down " + url + ": " + connection.getResponseMessage());
        } catch (SocketException e) {
            logger.debug("Not running");
            // Okay - the server is not running
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
  


嵌套类摘要
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的嵌套类/接口
AbstractLifeCycle.AbstractLifeCycleListener
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的嵌套类/接口
LifeCycle.Listener
 
字段摘要
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的字段
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
构造方法摘要
ShutdownHandler(Server server, String shutdownToken)
          Creates a listener that lets the server be shut down remotely (but only from localhost).
 
方法摘要
protected  String getRemoteAddr(HttpServletRequest request)
           
 void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
          Handle a request.
 void setExitJvm(boolean exitJvm)
           
 
从类 org.eclipse.jetty.server.handler.AbstractHandler 继承的方法
destroy, doStart, doStop, dumpThis, getServer, setServer
 
从类 org.eclipse.jetty.util.component.AggregateLifeCycle 继承的方法
addBean, addBean, contains, dump, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanage
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的方法
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的方法
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

构造方法详细信息

ShutdownHandler

public ShutdownHandler(Server server,
                       String shutdownToken)
Creates a listener that lets the server be shut down remotely (but only from localhost).

参数:
server - the Jetty instance that should be shut down
shutdownToken - a secret password to avoid unauthorized shutdown attempts
方法详细信息

handle

public void handle(String target,
                   Request baseRequest,
                   HttpServletRequest request,
                   HttpServletResponse response)
            throws IOException,
                   ServletException
从接口 Handler 复制的描述
Handle a request.

参数:
target - The target of the request - either a URI or a name.
baseRequest - The original unwrapped request object.
request - The request either as the Request object or a wrapper of that request. The AbstractHttpConnection.getCurrentConnection() method can be used access the Request object if required.
response - The response as the Response object or a wrapper of that request. The AbstractHttpConnection.getCurrentConnection() method can be used access the Response object if required.
抛出:
IOException
ServletException

getRemoteAddr

protected String getRemoteAddr(HttpServletRequest request)

setExitJvm

public void setExitJvm(boolean exitJvm)


Copyright © 2013. All Rights Reserved.