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
Support class for
NamedLockFactory implementations providing reference counting.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanSystem property key to enable locking diagnostic collection.private final booleanprivate final ConcurrentMap<String, NamedLockFactorySupport.NamedLockHolder> protected final org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected abstract NamedLockSupportcreateLock(String name) Implementations shall create and returnNamedLockSupportfor givenname, this method must never returnnull.protected voiddestroyLock(String name) Implementation may override this (empty) method to perform some sort of implementation specific cleanup for given lock name.Creates or reuses existingNamedLock.booleanReturnstrueif 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.voidshutdown()Performs a clean shut down of the factory.
-
Field Details
-
DIAGNOSTIC_ENABLED
private static final boolean DIAGNOSTIC_ENABLEDSystem property key to enable locking diagnostic collection.- Since:
- 1.9.11
-
logger
protected final org.slf4j.Logger logger -
locks
-
diagnosticEnabled
private final boolean diagnosticEnabled
-
-
Constructor Details
-
NamedLockFactorySupport
public NamedLockFactorySupport() -
NamedLockFactorySupport
public NamedLockFactorySupport(boolean diagnosticEnabled)
-
-
Method Details
-
isDiagnosticEnabled
public boolean isDiagnosticEnabled()Returnstrueif factory diagnostic collection is enabled.- Since:
- 1.9.11
-
getLock
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:
name- the lock name, must not benull.- Returns:
- named lock instance, never
null.
-
shutdown
public void shutdown()Description copied from interface:NamedLockFactoryPerforms a clean shut down of the factory.- Specified by:
shutdownin interfaceNamedLockFactory
-
onFailure
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
-
createLock
Implementations shall create and returnNamedLockSupportfor 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.
-