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

com.codahale.metrics.DefaultObjectNameFactory Maven / Gradle / Ivy

There is a newer version: 0.7.0
Show newest version
package com.codahale.metrics;

import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DefaultObjectNameFactory implements ObjectNameFactory {

	private static final Logger LOGGER = LoggerFactory.getLogger(JmxReporter.class);

	@Override
	public ObjectName createName(String type, String domain, String name) {
		try {
			ObjectName objectName = new ObjectName(domain, "name", name);
			if (objectName.isPattern()) {
				objectName = new ObjectName(domain, "name", ObjectName.quote(name));
			}
			return objectName;
		} catch (MalformedObjectNameException e) {
			try {
				return new ObjectName(domain, "name", ObjectName.quote(name));
			} catch (MalformedObjectNameException e1) {
				LOGGER.warn("Unable to register {} {}", type, name, e1);
				throw new RuntimeException(e1);
			}
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy