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 samples.util;
21:
22: import org.apache.commons.logging.Log;
23: import org.apache.commons.logging.LogFactory;
24:
25: public class SampleAxis2Server {
26:
27: private static final Log log = LogFactory
28: .getLog(SampleAxis2Server.class);
29:
30: /**
31: * Expected system properties
32: * http_port: Port to bind HTTP transport (default is 9000)
33: * https_port: Port to bind HTTPS transport (default is 9002)
34: * server_name: Name of this instance of the server (optional)
35: *
36: * @param args 1: Axis2 repository
37: * 2: Axis2 configuration file (axis2.xml)
38: * @throws Exception
39: */
40: public static void main(String[] args) throws Exception {
41: startServer(args);
42: addShutdownHook();
43: }
44:
45: private static void addShutdownHook() {
46: Thread shutdownHook = new Thread() {
47: public void run() {
48: log.info("Shutting down SimpleAxisServer ...");
49: try {
50: stopServer();
51: log.info("Shutdown complete");
52: log.info("Halting JVM");
53: } catch (Exception e) {
54: log
55: .warn("Error occurred while shutting down SimpleAxisServer : "
56: + e);
57: }
58: }
59: };
60: Runtime.getRuntime().addShutdownHook(shutdownHook);
61: }
62:
63: public static void startServer(String[] args) throws Exception {
64: SampleAxis2ServerManager.getInstance().start(args);
65: }
66:
67: public static void stopServer() throws Exception {
68: SampleAxis2ServerManager.getInstance().stop();
69: }
70: }
|