Пример #1
0
  public void start() throws IOException {
    log.infof("Starting JMX Remoting Server %s", Version.getVersionString());

    // Initialise general Remoting - this step would be implemented elsewhere when
    // running within an application server.
    final Xnio xnio = Xnio.getInstance();
    endpoint = Remoting.createEndpoint("JMXRemoting", xnio, OptionMap.EMPTY);
    endpoint.addConnectionProvider(
        "remote", new RemoteConnectionProviderFactory(), OptionMap.EMPTY);

    final NetworkServerProvider nsp =
        endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SocketAddress bindAddress = new InetSocketAddress(host, listenerPort);
    final OptionMap serverOptions = createOptionMap();

    server = nsp.createServer(bindAddress, serverOptions, authenticationProvider, null);

    Map<String, Object> configMap = new HashMap<String, Object>();
    if (excludedVersions != null) {
      configMap.put(EXCLUDED_VERSIONS, excludedVersions);
    }
    // Initialise the components that will provide JMX connectivity.
    if (mbeanServerLocator == null) {
      connectorServer =
          new RemotingConnectorServer(
              mbeanServer, endpoint, configMap, serverMessageEventHandlerFactory);
      connectorServer.start();
    } else {
      delegatingServer =
          new DelegatingRemotingConnectorServer(
              mbeanServerLocator, endpoint, configMap, serverMessageEventHandlerFactory);
      delegatingServer.start();
    }
  }
Пример #2
0
  public void stop() throws IOException {
    log.infof("Stopping JMX Remoting Server %s", Version.getVersionString());

    // Services using an existing Remoting installation only need to stop the JMXConnectorServer
    // to disassociate it from Remoting.
    if (connectorServer != null) {
      connectorServer.stop();
    }
    if (delegatingServer != null) {
      delegatingServer.stop();
    }
    if (server != null) {
      server.close();
    }

    if (endpoint != null) {
      endpoint.close();
    }
  }