001    /**
002     * Copyright (c) 2000-2013 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                    _rangeSize = rangeSize;
031                    _counterHolder = counterHolder;
032                    _competeLatch = new CompeteLatch();
033            }
034    
035            public CounterRegister(
036                    String name, long rangeMin, long rangeMax, int rangeSize) {
037    
038                    this(name, new CounterHolder(rangeMin, rangeMax), rangeSize);
039            }
040    
041            public CompeteLatch getCompeteLatch() {
042                    return _competeLatch;
043            }
044    
045            public CounterHolder getCounterHolder() {
046                    return _counterHolder;
047            }
048    
049            public String getName() {
050                    return _name;
051            }
052    
053            public int getRangeSize() {
054                    return _rangeSize;
055            }
056    
057            public void setCounterHolder(CounterHolder holder) {
058                    _counterHolder = holder;
059            }
060    
061            public void setName(String name) {
062                    _name = name;
063            }
064    
065            private final CompeteLatch _competeLatch;
066            private volatile CounterHolder _counterHolder;
067            private String _name;
068            private final int _rangeSize;
069    
070    }