1 /* 2 * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved. 3 * 4 * Project: OpenSubsystems 5 * 6 * $Id: GlobalSequence.java,v 1.3 2007/01/07 06:14:01 bastafidli Exp $ 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; version 2 of the License. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 */ 21 22 package org.opensubsystems.core.util; 23 24 /** 25 * Base class for getting of unique sequence numbers. 26 * 27 * @version $Id: GlobalSequence.java,v 1.3 2007/01/07 06:14:01 bastafidli Exp $ 28 * @author Julo Legeny 29 * @code.reviewer Miro Halas 30 * @code.reviewed Initial revision 31 */ 32 public final class GlobalSequence 33 { 34 // Attributes /////////////////////////////////////////////////////////////// 35 36 /** 37 * Last request ID 38 */ 39 private static int s_lastRequest = 0; 40 41 // Constructors ///////////////////////////////////////////////////////////// 42 43 /** 44 * Private constructor since this class cannot be instantiated 45 */ 46 private GlobalSequence( 47 ) 48 { 49 // Do nothing 50 // Since this cannot be never invoked, this is here just to avoid Checkstyle 51 // warning. 52 s_lastRequest = 0; 53 } 54 55 // Public methods /////////////////////////////////////////////////////////// 56 57 /** 58 * Get new sequence number which is guaranteed to be unique in this class loader. 59 * 60 * @return int 61 */ 62 public static synchronized int getNextSequenceNumber( 63 ) 64 { 65 return s_lastRequest++; 66 } 67 } 68