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: */
19:
20: package org.apache.axis2.jaxws.utility;
21:
22: import org.apache.axis2.AxisFault;
23: import org.apache.axis2.jaxws.TestLogger;
24: import org.apache.axis2.context.ConfigurationContext;
25: import org.apache.axis2.context.ConfigurationContextFactory;
26: import org.apache.axis2.transport.http.SimpleHTTPServer;
27: import org.apache.log4j.BasicConfigurator;
28:
29: public class SimpleServer {
30:
31: private static SimpleHTTPServer server;
32: private String repositoryDir;
33: private int port = 8080;
34:
35: public void init() {
36: repositoryDir = System.getProperty("basedir", ".") + "/"
37: + System.getProperty("build.repository");
38: // repositoryDir = "target/test-classes";
39: TestLogger.logger.debug(">> repositoryDir = " + repositoryDir);
40:
41: String axis2xml = System.getProperty("axis2.config");
42: TestLogger.logger.debug(">> axis2.xml = " + axis2xml);
43:
44: try {
45: ConfigurationContext config = ConfigurationContextFactory
46: .createConfigurationContextFromFileSystem(
47: repositoryDir, axis2xml);
48: server = new SimpleHTTPServer(config, port);
49: } catch (AxisFault e) {
50: e.printStackTrace();
51: }
52: }
53:
54: public void start() {
55: TestLogger.logger
56: .debug("------------ starting server ---------------");
57: init();
58: if (server != null) {
59: try {
60: server.start();
61: } catch (AxisFault e) {
62: e.printStackTrace();
63: }
64: }
65: TestLogger.logger
66: .debug("------------------ done --------------------");
67: }
68:
69: public void stop() {
70: TestLogger.logger
71: .debug("------------ stopping server ---------------");
72: if (server != null) {
73: server.stop();
74: }
75: TestLogger.logger
76: .debug("------------------ done --------------------");
77: }
78:
79: public static void main(String[] args) throws Exception {
80: // To change the settings, edit the log4j.property file
81: // in the test-resources directory.
82: BasicConfigurator.configure();
83: SimpleServer server = new SimpleServer();
84: server.start();
85: }
86: }
|