01: /*
02: * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.wso2.esb.jmx.mbean;
17:
18: import org.wso2.esb.ServiceBus;
19: import org.wso2.esb.ServiceBusManager;
20:
21: /**
22: *
23: */
24:
25: public class ServerView implements ServerViewMBean {
26:
27: private final ServiceBus serviceBus;
28:
29: public ServerView() {
30: this .serviceBus = new ServiceBus();
31: }
32:
33: public void shutdown() throws Exception {
34: ServiceBusManager.getInstance().removeShutdownHook();
35: this .serviceBus.shutdown();
36: Thread th = new Thread() {
37: public void run() {
38: try {
39: Thread.sleep(1000);
40: System.exit(0);
41: } catch (Exception e) {
42: throw new RuntimeException(e);
43: }
44: }
45: };
46: th.start();
47: }
48:
49: public void shutdownGracefully(long millis) throws Exception {
50: ServiceBusManager.getInstance().removeShutdownHook();
51: this .serviceBus.shutdownGracefully(millis);
52: Thread th = new Thread() {
53: public void run() {
54: try {
55: Thread.sleep(1000);
56: System.exit(0);
57: } catch (Exception e) {
58: throw new RuntimeException(e);
59: }
60: }
61: };
62: th.start();
63: }
64:
65: public void startMaintenance() throws Exception {
66: this .serviceBus.startMaintenance();
67: }
68:
69: public void endMaintenance() throws Exception {
70: this .serviceBus.endMaintenance();
71: }
72:
73: // public void start() throws Exception {
74: // this.serviceBus.start();
75: // }
76: }
|