001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.counter.model;
016    
017    import com.liferay.portal.kernel.concurrent.CompeteLatch;
018    
019    /**
020     * @author Harry Mark
021     * @author Shuyang Zhou
022     * @author Edward Han
023     */
024    public class CounterRegister {
025    
026            public CounterRegister(
027                    String name, CounterHolder counterHolder, int rangeSize) {
028    
029                    _name = name;
030                    _counterHolder = counterHolder;
031                    _rangeSize = rangeSize;
032    
033                    _competeLatch = new CompeteLatch();
034            }
035    
036            public CounterRegister(
037                    String name, long rangeMin, long rangeMax, int rangeSize) {
038    
039                    this(name, new CounterHolder(rangeMin, rangeMax), rangeSize);
040            }
041    
042            public CompeteLatch getCompeteLatch() {
043                    return _competeLatch;
044            }
045    
046            public CounterHolder getCounterHolder() {
047                    return _counterHolder;
048            }
049    
050            public String getName() {
051                    return _name;
052            }
053    
054            public int getRangeSize() {
055                    return _rangeSize;
056            }
057    
058            public void setCounterHolder(CounterHolder holder) {
059                    _counterHolder = holder;
060            }
061    
062            public void setName(String name) {
063                    _name = name;
064            }
065    
066            private final CompeteLatch _competeLatch;
067            private volatile CounterHolder _counterHolder;
068            private String _name;
069            private final int _rangeSize;
070    
071    }