All Downloads are FREE. Search and download functionalities are using the official Maven repository.

su.nlq.prometheus.jmx.connection.remote.Connector Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
package su.nlq.prometheus.jmx.connection.remote;

import org.jetbrains.annotations.NotNull;

import javax.management.remote.JMXConnector;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

public abstract class Connector {
  private final @NotNull String address;
  private final @NotNull Optional credentials;

  protected Connector(@NotNull String address, @NotNull Optional credentials) {
    this.address = address;
    this.credentials = credentials;
  }

  public abstract @NotNull JMXConnector connect() throws IOException;

  public final @NotNull String address() {
    return address;
  }

  protected final @NotNull Map environment() {
    final Map environment = new HashMap<>();
    credentials.ifPresent(value -> environment.put(JMXConnector.CREDENTIALS, value));
    return environment;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy