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,LocalReadWriteLockNamedLockFactory,LocalSemaphoreNamedLockFactory,NoopNamedLockFactory
public abstract class NamedLockFactorySupport extends java.lang.Object implements NamedLockFactory
Support class forNamedLockFactoryimplementations providing reference counting.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Loggerloggerstatic java.lang.StringSYSTEM_PROP_DIAGNOSTIC_ENABLEDSystem property key to enable locking diagnostic collection.
-
Constructor Summary
Constructors Constructor Description NamedLockFactorySupport()NamedLockFactorySupport(boolean diagnosticEnabled)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcloseLock(NamedLockKey key)protected abstract NamedLockSupportcreateLock(NamedLockKey key)Implementations shall create and returnNamedLockSupportfor givenname, this method must never returnnull.protected voiddestroyLock(NamedLock namedLock)Implementation may override this (empty) method to perform some sort of implementation specific cleanup for given lock name.protected NamedLockdoGetLock(java.util.Collection<NamedLockKey> keys)protected voiddoShutdown()NamedLockgetLock(java.util.Collection<NamedLockKey> keys)Creates or reuses existingNamedLock.protected NamedLockgetLockAndRefTrack(NamedLockKey key, java.util.function.Supplier<NamedLockSupport> supplier)booleanisDiagnosticEnabled()Returnstrueif factory diagnostic collection is enabled.<E extends java.lang.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.voidshutdown()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 Detail
-
SYSTEM_PROP_DIAGNOSTIC_ENABLED
public static final java.lang.String SYSTEM_PROP_DIAGNOSTIC_ENABLED
System property key to enable locking diagnostic collection.- Since:
- 1.9.11
- See Also:
- Constant Field Values
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Detail
-
NamedLockFactorySupport
public NamedLockFactorySupport()
-
NamedLockFactorySupport
public NamedLockFactorySupport(boolean diagnosticEnabled)
-
-
Method Detail
-
isDiagnosticEnabled
public boolean isDiagnosticEnabled()
Returnstrueif factory diagnostic collection is enabled.- Since:
- 1.9.11
-
getLock
public final NamedLock getLock(java.util.Collection<NamedLockKey> keys)
Description copied from interface:NamedLockFactoryCreates or reuses existingNamedLock. Returns instance MUST BE treated as "resource", best in try-with-resource block.- Specified by:
getLockin interfaceNamedLockFactory- Parameters:
keys- the lock keys, must not benulland must not be empty collection.- Returns:
- named lock instance, never
null.
-
doGetLock
protected NamedLock doGetLock(java.util.Collection<NamedLockKey> keys)
-
getLockAndRefTrack
protected NamedLock getLockAndRefTrack(NamedLockKey key, java.util.function.Supplier<NamedLockSupport> supplier)
-
shutdown
public void shutdown()
Description copied from interface:NamedLockFactoryPerforms a clean shut down of the factory.- Specified by:
shutdownin interfaceNamedLockFactory
-
doShutdown
protected void doShutdown()
-
onFailure
public <E extends java.lang.Throwable> E onFailure(E failure)
Description copied from interface:NamedLockFactoryMethod 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:
onFailurein interfaceNamedLockFactory
-
closeLock
public void closeLock(NamedLockKey key)
-
createLock
protected abstract NamedLockSupport createLock(NamedLockKey key)
Implementations shall create and returnNamedLockSupportfor givenname, this method must never returnnull.
-
destroyLock
protected void destroyLock(NamedLock namedLock)
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.
-
-