Package org.eclipse.aether.named.support
Class NamedLockFactorySupport
java.lang.Object
org.eclipse.aether.named.support.NamedLockFactorySupport
- All Implemented Interfaces:
NamedLockFactory
- Direct Known Subclasses:
FileLockNamedLockFactory
,HazelcastSemaphoreNamedLockFactory
,LocalReadWriteLockNamedLockFactory
,LocalSemaphoreNamedLockFactory
,NoopNamedLockFactory
,RedissonNamedLockFactorySupport
Support class for
NamedLockFactory
implementations providing reference counting.-
Field Summary
Modifier and TypeFieldDescriptionprotected final org.slf4j.Logger
static final String
System property key to enable locking diagnostic collection. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
closeLock
(NamedLockKey key) protected abstract NamedLockSupport
createLock
(NamedLockKey key) Implementations shall create and returnNamedLockSupport
for givenname
, this method must never returnnull
.protected void
destroyLock
(NamedLock namedLock) Implementation may override this (empty) method to perform some sort of implementation specific cleanup for given lock name.protected NamedLock
doGetLock
(Collection<NamedLockKey> keys) protected void
final NamedLock
getLock
(Collection<NamedLockKey> keys) Creates or reuses existingNamedLock
.protected NamedLock
getLockAndRefTrack
(NamedLockKey key, Supplier<NamedLockSupport> supplier) boolean
Returnstrue
if factory diagnostic collection is enabled.<E extends Throwable>
EonFailure
(E failure) Method to notify factory about locking failure, to make it possible to provide more (factory specific) information about factory state when a locking operation failed.void
shutdown()
Performs a clean shut down of the factory.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.aether.named.NamedLockFactory
getLock
-
Field Details
-
SYSTEM_PROP_DIAGNOSTIC_ENABLED
System property key to enable locking diagnostic collection.- Since:
- 1.9.11
- See Also:
- Sourced from:
System.getProperty(String, String)
- Value type:
Boolean
- Default value:
- false
-
logger
-
-
Constructor Details
-
NamedLockFactorySupport
public NamedLockFactorySupport() -
NamedLockFactorySupport
-
-
Method Details
-
isDiagnosticEnabled
Returnstrue
if factory diagnostic collection is enabled.- Since:
- 1.9.11
-
getLock
Description copied from interface:NamedLockFactory
Creates or reuses existingNamedLock
. Returns instance MUST BE treated as "resource", best in try-with-resource block.- Specified by:
getLock
in interfaceNamedLockFactory
- Parameters:
keys
- the lock keys, must not benull
and must not be empty collection.- Returns:
- named lock instance, never
null
.
-
doGetLock
-
getLockAndRefTrack
-
shutdown
Description copied from interface:NamedLockFactory
Performs a clean shut down of the factory.- Specified by:
shutdown
in interfaceNamedLockFactory
-
doShutdown
-
onFailure
Description copied from interface:NamedLockFactory
Method to notify factory about locking failure, to make it possible to provide more (factory specific) information about factory state when a locking operation failed. Factory may alter provided failure or provide information via some other side effect (for example via logging).The default implementation merely does what happened before: adds no extra information.
- Specified by:
onFailure
in interfaceNamedLockFactory
-
closeLock
-
createLock
Implementations shall create and returnNamedLockSupport
for givenname
, this method must never returnnull
. -
destroyLock
Implementation may override this (empty) method to perform some sort of implementation specific cleanup for given lock name. Invoked when reference count for given name drops to zero and named lock was removed.
-