01: /*
02: * $Id: JMXConnectorService.java 590 2005-11-24 14:07:44Z hengels $
03: * (c) Copyright 2004 con:cern development team.
04: *
05: * This file is part of con:cern (http://concern.org).
06: *
07: * con:cern is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU Lesser General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.concern.jboss;
15:
16: import org.jboss.system.ServiceMBeanSupport;
17:
18: import javax.management.remote.JMXConnectorServer;
19: import javax.management.remote.JMXConnectorServerFactory;
20: import javax.management.remote.JMXServiceURL;
21: import java.io.IOException;
22:
23: /**
24: * @author hengels
25: * @version $Revision: 590 $
26: */
27: public class JMXConnectorService extends ServiceMBeanSupport implements
28: JMXConnectorServiceMBean {
29:
30: private String jndiName = "JMXConnectorServer";
31: JMXConnectorServer connectorServer;
32:
33: public String getJndiName() {
34: return jndiName;
35: }
36:
37: public void setJndiName(String jndiName) {
38: this .jndiName = jndiName;
39: }
40:
41: public void start() throws Exception {
42: super .start();
43: if (connectorServer == null) {
44: JMXServiceURL url = new JMXServiceURL(
45: "service:jmx:rmi:///jndi/JMXConnectorServer");
46: connectorServer = JMXConnectorServerFactory
47: .newJMXConnectorServer(url, null, getServer());
48: connectorServer.start();
49: }
50: }
51:
52: public void stop() {
53: if (connectorServer != null) {
54: try {
55: connectorServer.stop();
56: connectorServer = null;
57: } catch (IOException e) {
58: e.printStackTrace();
59: //log.error(connectorServer, e);
60: }
61: }
62: super.stop();
63: }
64: }
|