2 // ========================================================================
3 // Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.server.handler;
22 import java.io.IOException;
24 import org.eclipse.jetty.server.Handler;
25 import org.eclipse.jetty.server.Server;
26 import org.eclipse.jetty.util.annotation.ManagedObject;
27 import org.eclipse.jetty.util.component.ContainerLifeCycle;
28 import org.eclipse.jetty.util.log.Log;
29 import org.eclipse.jetty.util.log.Logger;
32 /* ------------------------------------------------------------ */
35 @ManagedObject("Jetty Handler")
36 public abstract class AbstractHandler extends ContainerLifeCycle implements Handler
38 private static final Logger LOG = Log.getLogger(AbstractHandler.class);
40 private Server _server;
42 /* ------------------------------------------------------------ */
46 public AbstractHandler()
50 /* ------------------------------------------------------------ */
52 * @see org.eclipse.thread.LifeCycle#start()
55 protected void doStart() throws Exception
57 if (LOG.isDebugEnabled())
58 LOG.debug("starting {}",this);
60 LOG.warn("No Server set for {}",this);
64 /* ------------------------------------------------------------ */
66 * @see org.eclipse.thread.LifeCycle#stop()
69 protected void doStop() throws Exception
71 if (LOG.isDebugEnabled())
72 LOG.debug("stopping {}",this);
76 /* ------------------------------------------------------------ */
78 public void setServer(Server server)
83 throw new IllegalStateException(STARTED);
87 /* ------------------------------------------------------------ */
89 public Server getServer()
94 /* ------------------------------------------------------------ */
99 throw new IllegalStateException("!STOPPED");
103 /* ------------------------------------------------------------ */
105 public void dumpThis(Appendable out) throws IOException
107 out.append(toString()).append(" - ").append(getState()).append('\n');