| CounterUtil.java |
1 /**
2 * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.liferay.counter.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.bean.BeanLocatorUtil;
27
28 import java.util.List;
29
30 /**
31 * <a href="CounterUtil.java.html"><b><i>View Source</i></b></a>
32 *
33 * @author Brian Wing Shun Chan
34 *
35 */
36 public class CounterUtil {
37
38 public static List<String> getNames() throws SystemException {
39 return getPersistence().getNames();
40 }
41
42 public static long increment() throws SystemException {
43 return getPersistence().increment();
44 }
45
46 public static long increment(String name) throws SystemException {
47 return getPersistence().increment(name);
48 }
49
50 public static long increment(String name, int size)
51 throws SystemException {
52
53 return getPersistence().increment(name, size);
54 }
55
56 public static void rename(String oldName, String newName)
57 throws SystemException {
58
59 getPersistence().rename(oldName, newName);
60 }
61
62 public static void reset(String name) throws SystemException {
63 getPersistence().reset(name);
64 }
65
66 public static void reset(String name, long size) throws SystemException {
67 getPersistence().reset(name, size);
68 }
69
70 public static CounterPersistence getPersistence() {
71 return _getUtil()._persistence;
72 }
73
74 public void setPersistence(CounterPersistence persistence) {
75 _persistence = persistence;
76 }
77
78 private static CounterUtil _getUtil() {
79 if (_util == null) {
80 _util = (CounterUtil)BeanLocatorUtil.locate(_UTIL);
81 }
82
83 return _util;
84 }
85
86 private static final String _UTIL = CounterUtil.class.getName();
87
88 private static CounterUtil _util;
89
90 private CounterPersistence _persistence;
91
92 }