com.mooapi.server.util
Interface IdProvider<T>

All Known Implementing Classes:
PooledIdProvider, SequenceIdProvider

public interface IdProvider<T>

This interface defines a service that provides unique IDs of the specified type.

Author:
Steve Taylor

Method Summary
 T acquireId()
          Acquire a unique ID from this provider.
 void releaseId(T id)
          Release an ID to this provider.
 

Method Detail

acquireId

T acquireId()
Acquire a unique ID from this provider. A unique ID is defined as an ID that is not found in the set of IDs currently on loan from this provider.

Returns:
A unique ID.

releaseId

void releaseId(T id)

Release an ID to this provider.

Users of a provider must return only IDs to that provider that they have acquired from it and not since released back to it. However, for performance reasons, implementations of this method may assume this contract is being honoured without actually checking that this in fact is the case. If all users of a provider that make this assumption honour the contract, they all may assume that the provider will continue to honour its contract by returning unique IDs.

Parameters:
id - The ID to release.


Copyright © 2009. All Rights Reserved.