01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.server;
18:
19: import org.apache.log4j.Logger;
20: import org.kuali.rice.lifecycle.Lifecycle;
21: import org.mortbay.jetty.Server;
22:
23: public abstract class BaseTestServer implements Lifecycle {
24: private static final Logger LOG = Logger
25: .getLogger(BaseTestServer.class);
26:
27: private Server server;
28:
29: protected abstract Server createServer();
30:
31: public Server getServer() {
32: return server;
33: }
34:
35: public void start() throws Exception {
36: server = createServer();
37: server.start();
38: }
39:
40: public void stop() throws Exception {
41: // make sure to test the server before stopping,
42: // in case the reason we are stopping is that there was
43: // an error creating the server to begin with
44: // we don't want to mask that error
45: if (server == null) {
46: LOG.warn("Jetty Server was null");
47: } else {
48: server.stop();
49: }
50: server = null;
51: }
52:
53: public boolean isStarted() {
54: return server.isStarted();
55: }
56:
57: }
|