Пример #1
0
  public boolean createEndpoint(String uri) throws Exception {
    if (context.hasEndpoint(uri) != null) {
      // endpoint already exists
      return false;
    }

    Endpoint endpoint = context.getEndpoint(uri);
    if (endpoint != null) {
      // ensure endpoint is registered, as the management strategy could have been configured to not
      // always
      // register new endpoints in JMX, so we need to check if its registered, and if not register
      // it manually
      ObjectName on =
          context
              .getManagementStrategy()
              .getManagementNamingStrategy()
              .getObjectNameForEndpoint(endpoint);
      if (on != null && !context.getManagementStrategy().getManagementAgent().isRegistered(on)) {
        // register endpoint as mbean
        Object me =
            context
                .getManagementStrategy()
                .getManagementObjectStrategy()
                .getManagedObjectForEndpoint(context, endpoint);
        context.getManagementStrategy().getManagementAgent().register(me, on);
      }
      return true;
    } else {
      return false;
    }
  }