001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.metrics; 019 020import static com.codahale.metrics.SharedMetricRegistries.getOrCreate; 021 022import com.codahale.metrics.MetricRegistry; 023 024/** 025 * Provide helpers for working with the Metrics registry 026 * 027 * @author cbeer 028 * @since Mar 22, 2013 029 */ 030public final class RegistryService { 031 032 private static final MetricRegistry METRICS = getOrCreate("fcrepo-metrics"); 033 034 private static volatile RegistryService instance = null; 035 036 private RegistryService() { 037 // New instances should come from the singleton 038 } 039 040 /** 041 * Create the instance 042 * @return the local object 043 */ 044 public synchronized static RegistryService getInstance() { 045 RegistryService local = instance; 046 if (null == local) { 047 instance = local = new RegistryService(); 048 } 049 return local; 050 } 051 052 /** 053 * Get the current registry service 054 * 055 * TODO the new upstream SharedMetricRegistries may make this obsolete 056 * @return the current registry service 057 */ 058 @SuppressWarnings("static-method") 059 public MetricRegistry getMetrics() { 060 return METRICS; 061 } 062 063}