Class NumberPoolDomainImpl
- All Implemented Interfaces:
Serializable, NumberPoolDomain, DomainContextProvider, DomainDelegate<NumberPool>, DomainObject<NumberPool>, PdoProvider<NumberPool>, ProxyDelegate<NumberPool>, EffectiveClassProvider<NumberPool>, Interceptable, SessionProvider
- Author:
- harald
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class AbstractDomainObject
assertRootEntity, findByUniqueDomainKey, getDomainContext, getEffectiveClass, getEffectiveSuperClasses, getPdo, getPersistenceDelegate, getPlural, getSession, getSingular, getUniqueDomainKey, getUniqueDomainKeyType, isUniqueDomainKeyProvided, me, setPdo, setUniqueDomainKey, toGenericStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface DomainContextProvider
getDomainContext, isWithinContext, isWithinContext, on, on, op, opMethods inherited from interface DomainDelegate
getPersistenceDelegateMethods inherited from interface DomainObject
findByUniqueDomainKey, getPlural, getSingular, getUniqueDomainKey, getUniqueDomainKeyType, isUniqueDomainKeyProvided, setUniqueDomainKey, toGenericStringMethods inherited from interface PdoProvider
getPdo, on, onMethods inherited from interface ProxyDelegate
meMethods inherited from interface SessionProvider
getSession
-
Constructor Details
-
NumberPoolDomainImpl
-
NumberPoolDomainImpl
public NumberPoolDomainImpl()
-
-
Method Details
-
toString
Description copied from class:AbstractDomainObjectGets the string representation of this domain object.The default implementation returns the domain key if this is a root entity. If a component, its single-name will be returned. If evaluating the domain key failed, the generic string is returned along with the exception in parentheses. This is because
toString()should never throw an exception as it is used for logging and debugging.- Overrides:
toStringin classAbstractDomainObject<NumberPool, NumberPoolDomainImpl>- Returns:
- the string representation
-
getCurrentRange
Get the current range.
This is the first non-empty range with the lowest "begin".Despite its name, the method modifies the pool: exhausted ranges are removed from
NumberPoolPersistence.getNumberRangeList()along the way and are deleted from the database when the pool is next persisted. This also happens when the pool turns out to be empty, i.e., before theNumberSourceEmptyExceptionis thrown.Invoke it only within a transaction that persists the pool afterward or is rolled back, and with the pool locked, as
DefaultNumberSourcedoes. It performs no locking itself.This method modifies the pool. While scanning for the lowest non-empty range it drops every exhausted range from
NumberPoolPersistence.getNumberRangeList(). That list is aTrackedList, so the removed ranges are deleted from the database as soon as the pool is persisted (seeNumberPoolPersistenceImpl.deleteReferencingRelations) — this is the intended housekeeping that keeps the range table from filling up with used-up rows.Two consequences for callers:
- The pruning happens on the failure path as well: when the pool turns out to be empty, the
ranges have already been removed before the
NumberSourceEmptyExceptionis thrown. - Call this within a transaction that either persists the pool afterward or is rolled back, and hold the pool locked while doing so — otherwise the in-memory list silently diverges from the database, or the deletions ride along with an unrelated later save.
DefaultNumberSourceis the intended caller and provides all of it: its methods aresynchronized, run inside a transaction, take a database row lock on the pool viareloadForUpdate(), and persist the pool at the end.- Specified by:
getCurrentRangein interfaceNumberPoolDomain- Returns:
- the current range, never null
- Throws:
NumberSourceEmptyException- if no non-empty range is left
- The pruning happens on the failure path as well: when the pool turns out to be empty, the
ranges have already been removed before the
-
isSlave
public boolean isSlave()Description copied from interface:NumberPoolDomainReturns whether this pool is a slave pool and gets its ranges from an uplink.- Specified by:
isSlavein interfaceNumberPoolDomain- Returns:
- true if slave
-