001/* 002 * (C) Copyright 2006-2009 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id$ 020 */ 021package org.nuxeo.runtime.management.counters; 022 023import org.nuxeo.runtime.api.Framework; 024 025/** 026 * Dummy helper class to be used by code that updates the counters to avoid having to do the service lookup 027 * 028 * @author Tiry (tdelprat@nuxeo.com) 029 * @deprecated since 11.4: use dropwizard metrics counter instead 030 */ 031@Deprecated(since = "11.4") 032public class CounterHelper { 033 034 protected static CounterManager cm = Framework.getService(CounterManager.class); 035 036 public static void increaseCounter(String counterName) { 037 if (cm != null) { 038 cm.increaseCounter(counterName); 039 } 040 } 041 042 public static void increaseCounter(String counterName, long value) { 043 if (cm != null) { 044 cm.increaseCounter(counterName, value); 045 } 046 } 047 048 public static void setCounterValue(String counterName, long value) { 049 if (cm != null) { 050 cm.setCounterValue(counterName, value); 051 } 052 } 053 054 public static void decreaseCounter(String counterName) { 055 if (cm != null) { 056 cm.decreaseCounter(counterName); 057 } 058 } 059 060 public static void decreaseCounter(String counterName, long value) { 061 if (cm != null) { 062 cm.decreaseCounter(counterName, value); 063 } 064 } 065 066}