001/* 002 * (C) Copyright 2006-2007 Nuxeo (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Dragos Mihalache 018 */ 019package org.nuxeo.ecm.core.uidgen; 020 021/** 022 * UID Sequencer interface defines a method to retrieve next ids based on a given key. 023 */ 024public interface UIDSequencer { 025 026 /** 027 * Gets the sequencer name. 028 * 029 * @since 7.4 030 */ 031 String getName(); 032 033 /** 034 * Sets the sequencer name. 035 * 036 * @since 7.4 037 */ 038 void setName(String name); 039 040 /** 041 * Init Sequencer 042 * 043 * @since 7.3 044 */ 045 void init(); 046 047 /** 048 * Initializes the sequencer with the given key to at least the given long id. 049 * <p> 050 * A sequence can only be incremented, so if its current id is greater than the given id the sequence won't be 051 * decremented to reach the given id. 052 * 053 * @since 9.10 054 */ 055 void initSequence(String key, long id); 056 057 /** 058 * Initializes the sequencer with the given key to at least the given id. 059 * @since 7.4 060 * @deprecated since 9.10 use {@link #initSequence(String, long)} instead. 061 */ 062 @Deprecated 063 void initSequence(String key, int id); 064 065 /** 066 * For the given key returns the incremented UID which is also stored in the same sequence entry. This is a 067 * "one time use" function for a document. 068 * 069 * @deprecated since 9.10 use {@link #getNextLong(String)} instead. 070 */ 071 @Deprecated 072 int getNext(String key); 073 074 /** 075 * Extends {@link UIDSequencer#getNext(java.lang.String)} to return a long value. This method is compatible 076 * with getNext in the integer range. 077 * 078 * @since 8.3 079 */ 080 long getNextLong(String key); 081 082 /** 083 * Cleanup callback 084 * 085 * @since 7.3 086 */ 087 void dispose(); 088 089}