Search in sources :

Example 1 with DetectRequestImpl

use of org.opennms.netmgt.provision.support.DetectRequestImpl in project opennms by OpenNMS.

the class GenericJMXDetectorFactory method buildRequest.

@Override
public DetectRequest buildRequest(String location, InetAddress address, Integer port, Map<String, String> attributes) {
    // in case port is null, but url is provided, the port is extracted from the url
    if (port == null && attributes.containsKey("url")) {
        try {
            final JmxConnectionConfig config = JmxConnectionConfigBuilder.buildFrom(address, attributes).build();
            port = new JMXServiceURL(config.getUrl()).getPort();
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("url is not valid", e);
        }
    }
    return new DetectRequestImpl(address, port, getRuntimeAttributes(address, port));
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) MalformedURLException(java.net.MalformedURLException) DetectRequestImpl(org.opennms.netmgt.provision.support.DetectRequestImpl) JmxConnectionConfig(org.opennms.netmgt.jmx.connection.JmxConnectionConfig)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 JMXServiceURL (javax.management.remote.JMXServiceURL)1 JmxConnectionConfig (org.opennms.netmgt.jmx.connection.JmxConnectionConfig)1 DetectRequestImpl (org.opennms.netmgt.provision.support.DetectRequestImpl)1