| CounterRegister.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 */
14
15 package com.liferay.counter.model;
16
17 import com.liferay.portal.kernel.concurrent.CompeteLatch;
18
19 /**
20 * <a href="CounterRegister.java.html"><b><i>View Source</i></b></a>
21 *
22 * @author Harry Mark
23 * @author Shuyang Zhou
24 * @author Edward Han
25 */
26 public class CounterRegister {
27
28 public CounterRegister(
29 String name, CounterHolder counterHolder, int rangeSize) {
30
31 _name = name;
32 _rangeSize = rangeSize;
33 _counterHolder = counterHolder;
34 _competeLatch = new CompeteLatch();
35 }
36
37 public CounterRegister(
38 String name, long rangeMin, long rangeMax, int rangeSize) {
39
40 this(name, new CounterHolder(rangeMin, rangeMax), rangeSize);
41 }
42
43 public CompeteLatch getCompeteLatch() {
44 return _competeLatch;
45 }
46
47 public CounterHolder getCounterHolder() {
48 return _counterHolder;
49 }
50
51 public String getName() {
52 return _name;
53 }
54
55 public int getRangeSize() {
56 return _rangeSize;
57 }
58
59 public void setCounterHolder(CounterHolder holder) {
60 _counterHolder = holder;
61 }
62
63 public void setName(String name) {
64 _name = name;
65 }
66
67 private final CompeteLatch _competeLatch;
68 private volatile CounterHolder _counterHolder;
69 private String _name;
70 private final int _rangeSize;
71
72 }