/** * Retrieve instance of {@link HystrixMetricsPublisher} to use based on order of precedence as defined in {@link HystrixPlugins} class header. * <p> * Override default by using {@link #registerMetricsPublisher(HystrixMetricsPublisher)} or setting property (via Archaius): <code>hystrix.plugin.HystrixMetricsPublisher.implementation</code> with the full * classname to load. * * @return {@link HystrixMetricsPublisher} implementation to use */ public HystrixMetricsPublisher getMetricsPublisher() { if (metricsPublisher.get() == null) { // check for an implementation from Archaius first Object impl = getPluginImplementation(HystrixMetricsPublisher.class); if (impl == null) { // nothing set via Archaius so initialize with default metricsPublisher.compareAndSet(null, HystrixMetricsPublisherDefault.getInstance()); // we don't return from here but call get() again in case of thread-race so the winner will always get returned } else { // we received an implementation from Archaius so use it metricsPublisher.compareAndSet(null, (HystrixMetricsPublisher) impl); } } return metricsPublisher.get(); }
/** * Retrieve instance of {@link HystrixMetricsPublisher} to use based on order of precedence as defined in {@link HystrixPlugins} class header. * <p> * Override default by using {@link #registerMetricsPublisher(HystrixMetricsPublisher)} or setting property (via Archaius): <code>hystrix.plugin.HystrixMetricsPublisher.implementation</code> with the full * classname to load. * * @return {@link HystrixMetricsPublisher} implementation to use */ public HystrixMetricsPublisher getMetricsPublisher() { if (metricsPublisher.get() == null) { // check for an implementation from Archaius first Object impl = getPluginImplementation(HystrixMetricsPublisher.class); if (impl == null) { // nothing set via Archaius so initialize with default metricsPublisher.compareAndSet(null, HystrixMetricsPublisherDefault.getInstance()); // we don't return from here but call get() again in case of thread-race so the winner will always get returned } else { // we received an implementation from Archaius so use it metricsPublisher.compareAndSet(null, (HystrixMetricsPublisher) impl); } } return metricsPublisher.get(); }