01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.systest.aegis;
19:
20: import java.net.URISyntaxException;
21:
22: import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
23: import org.mortbay.jetty.Connector;
24: import org.mortbay.jetty.Handler;
25: import org.mortbay.jetty.handler.DefaultHandler;
26: import org.mortbay.jetty.handler.HandlerCollection;
27: import org.mortbay.jetty.nio.SelectChannelConnector;
28: import org.mortbay.jetty.webapp.WebAppContext;
29:
30: public class AegisServer extends AbstractBusTestServerBase {
31:
32: private org.mortbay.jetty.Server server;
33:
34: protected void run() {
35: System.out.println("Starting Server");
36:
37: server = new org.mortbay.jetty.Server();
38:
39: SelectChannelConnector connector = new SelectChannelConnector();
40: connector.setPort(9002);
41: server.setConnectors(new Connector[] { connector });
42:
43: WebAppContext webappcontext = new WebAppContext();
44: String contextPath = null;
45: try {
46: contextPath = getClass().getResource("/webapp").toURI()
47: .getPath();
48: } catch (URISyntaxException e1) {
49: e1.printStackTrace();
50: }
51: webappcontext.setContextPath("/");
52:
53: webappcontext.setWar(contextPath);
54:
55: HandlerCollection handlers = new HandlerCollection();
56: handlers.setHandlers(new Handler[] { webappcontext,
57: new DefaultHandler() });
58:
59: server.setHandler(handlers);
60: try {
61: server.start();
62:
63: } catch (Exception e) {
64: e.printStackTrace();
65: }
66:
67: }
68:
69: public boolean stopInProcess() throws Exception {
70: boolean ret = super .stopInProcess();
71: if (server != null) {
72: server.stop();
73: }
74: return ret;
75: }
76:
77: public static void main(String args[]) {
78: try {
79: AegisServer s = new AegisServer();
80: s.start();
81: } catch (Exception ex) {
82: ex.printStackTrace();
83: System.exit(-1);
84: } finally {
85: System.out.println("done!");
86: }
87: }
88:
89: }
|