1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.mina.example.chat;
21
22 import org.springframework.context.support.ClassPathXmlApplicationContext;
23
24
25
26
27
28
29
30
31 public class SpringMain {
32
33 public static void main(String[] args) throws Exception {
34 if (System.getProperty("com.sun.management.jmxremote") != null) {
35 new ClassPathXmlApplicationContext(getJmxApplicationContexts());
36 System.out.println("JMX enabled.");
37 } else {
38 new ClassPathXmlApplicationContext(getApplicationContext());
39 System.out
40 .println("JMX disabled. Please set the "
41 + "'com.sun.management.jmxremote' system property to enable JMX.");
42 }
43 System.out.println("Listening ...");
44 }
45
46 public static String getApplicationContext() {
47 return "org/apache/mina/example/chat/serverContext.xml";
48 }
49
50 public static String[] getJmxApplicationContexts() {
51 return new String[] { "org/apache/mina/example/chat/serverContext.xml",
52 "org/apache/mina/example/chat/jmxContext.xml" };
53 }
54 }