1 /* 2 * The contents of this file are subject to the terms 3 * of the Common Development and Distribution License 4 * (the License). You may not use this file except in 5 * compliance with the License. 6 * 7 * You can obtain a copy of the license at 8 * https://glassfish.dev.java.net/public/CDDLv1.0.html or 9 * glassfish/bootstrap/legal/CDDLv1.0.txt. 10 * See the License for the specific language governing 11 * permissions and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL 14 * Header Notice in each file and include the License file 15 * at glassfish/bootstrap/legal/CDDLv1.0.txt. 16 * If applicable, add the following below the CDDL Header, 17 * with the fields enclosed by brackets [] replaced by 18 * you own identifying information: 19 * "Portions Copyrighted [year] [name of copyright owner]" 20 * 21 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 22 */ 23 24 package com.sun.enterprise.util; 25 26 /** 27 * A unique value generator is used to generate numbers 28 * that are guaranteed to be unique within a particular 29 * scope and lifetime of a J2EE server. See below for details. 30 * Generators support concurrent access. Each generator 31 * generates unique numbers within a particular context. 32 * Clients that need to draw numbers from the same "bucket" 33 * must use the same context. 34 * 35 * @author Kenneth Saks 36 */ 37 public interface UniqueValueGenerator { 38 39 /** 40 * Generate a number that is guaranteed to be unique 41 * within the lifetime of one J2EE server instance 42 * on one machine.(in both single-vm and multi-vm modes) 43 * That is, between "j2ee -start" and "j2ee -stop". 44 * @exception UniqueValueGeneratorException if error occurs 45 */ 46 long nextNumber() throws UniqueValueGeneratorException; 47 48 /** 49 * Generate an id that is guaranteed to be unique across 50 * multiple sessions of the same j2ee server on the same machine. 51 * @exception UniqueValueGeneratorException if error occurs 52 */ 53 String nextId() throws UniqueValueGeneratorException; 54 55 /** 56 * Get the context within which unique numbers will be generated. 57 */ 58 String getContext() throws UniqueValueGeneratorException; 59 60 } 61