mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
29 lines
618 B
Java
29 lines
618 B
Java
package io.ebean.metric;
|
|
|
|
import java.util.Iterator;
|
|
import java.util.ServiceLoader;
|
|
|
|
/**
|
|
* Lookup MetricFactory service.
|
|
*/
|
|
final class MetricServiceProvider {
|
|
|
|
private static final MetricFactory metricFactory = init();
|
|
|
|
private static MetricFactory init() {
|
|
Iterator<MetricFactory> loader = ServiceLoader.load(MetricFactory.class).iterator();
|
|
if (loader.hasNext()) {
|
|
return loader.next();
|
|
}
|
|
throw new IllegalStateException("MetricFactory not service loaded?");
|
|
}
|
|
|
|
/**
|
|
* Return the MetricFactory implementation.
|
|
*/
|
|
static MetricFactory get() {
|
|
return metricFactory;
|
|
}
|
|
|
|
}
|