001/* 002 * (C) Copyright 2006-2009 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 * $Id$ 018 */ 019package org.nuxeo.runtime.management.counters; 020 021import org.nuxeo.runtime.api.Framework; 022 023/** 024 * Dummy helper class to be used by code that updates the counters to avoid having to do the service lookup 025 * 026 * @author Tiry (tdelprat@nuxeo.com) 027 */ 028public class CounterHelper { 029 030 protected static CounterManager cm = Framework.getLocalService(CounterManager.class); 031 032 public static void increaseCounter(String counterName) { 033 if (cm != null) { 034 cm.increaseCounter(counterName); 035 } 036 } 037 038 public static void increaseCounter(String counterName, long value) { 039 if (cm != null) { 040 cm.increaseCounter(counterName, value); 041 } 042 } 043 044 public static void setCounterValue(String counterName, long value) { 045 if (cm != null) { 046 cm.setCounterValue(counterName, value); 047 } 048 } 049 050 public static void decreaseCounter(String counterName) { 051 if (cm != null) { 052 cm.decreaseCounter(counterName); 053 } 054 } 055 056 public static void decreaseCounter(String counterName, long value) { 057 if (cm != null) { 058 cm.decreaseCounter(counterName, value); 059 } 060 } 061 062}