comparison src/org/eclipse/jetty/server/handler/AbstractHandler.java @ 802:3428c60d7cfc

replace jetty jars with source
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 07 Sep 2016 21:15:48 -0600
parents
children 8e9db0bbf4f9
comparison
equal deleted inserted replaced
801:6a21393191c1 802:3428c60d7cfc
1 //
2 // ========================================================================
3 // Copyright (c) 1995-2014 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.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.server.handler;
20
21
22 import java.io.IOException;
23
24 import org.eclipse.jetty.server.Handler;
25 import org.eclipse.jetty.server.Server;
26 import org.eclipse.jetty.util.component.AggregateLifeCycle;
27 import org.eclipse.jetty.util.log.Log;
28 import org.eclipse.jetty.util.log.Logger;
29
30
31 /* ------------------------------------------------------------ */
32 /** AbstractHandler.
33 *
34 *
35 */
36 public abstract class AbstractHandler extends AggregateLifeCycle implements Handler
37 {
38 private static final Logger LOG = Log.getLogger(AbstractHandler.class);
39
40 private Server _server;
41
42 /* ------------------------------------------------------------ */
43 /**
44 *
45 */
46 public AbstractHandler()
47 {
48 }
49
50 /* ------------------------------------------------------------ */
51 /*
52 * @see org.eclipse.thread.LifeCycle#start()
53 */
54 @Override
55 protected void doStart() throws Exception
56 {
57 LOG.debug("starting {}",this);
58 super.doStart();
59 }
60
61 /* ------------------------------------------------------------ */
62 /*
63 * @see org.eclipse.thread.LifeCycle#stop()
64 */
65 @Override
66 protected void doStop() throws Exception
67 {
68 LOG.debug("stopping {}",this);
69 super.doStop();
70 }
71
72 /* ------------------------------------------------------------ */
73 public void setServer(Server server)
74 {
75 Server old_server=_server;
76 if (old_server!=null && old_server!=server)
77 old_server.getContainer().removeBean(this);
78 _server=server;
79 if (_server!=null && _server!=old_server)
80 _server.getContainer().addBean(this);
81 }
82
83 /* ------------------------------------------------------------ */
84 public Server getServer()
85 {
86 return _server;
87 }
88
89 /* ------------------------------------------------------------ */
90 public void destroy()
91 {
92 if (!isStopped())
93 throw new IllegalStateException("!STOPPED");
94 super.destroy();
95 if (_server!=null)
96 _server.getContainer().removeBean(this);
97 }
98
99 /* ------------------------------------------------------------ */
100 public void dumpThis(Appendable out) throws IOException
101 {
102 out.append(toString()).append(" - ").append(getState()).append('\n');
103 }
104
105 }