Package com.github.ddth.dlock.impl
Class AbstractDLockFactory
- java.lang.Object
-
- com.github.ddth.dlock.impl.AbstractDLockFactory
-
- All Implemented Interfaces:
IDLockFactory,AutoCloseable
- Direct Known Subclasses:
BaseRedisDLockFactory,InmemDLockFactory
public abstract class AbstractDLockFactory extends Object implements IDLockFactory, AutoCloseable
Abstract implementation ofIDLockFactorythat createsAbstractDLockinstances.- Since:
- 0.1.0
- Author:
- Thanh Ba Nguyen
-
-
Constructor Summary
Constructors Constructor Description AbstractDLockFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringbuildLockName(String lockName)voidclose()protected AbstractDLockcreateAndInitLockInstance(String name, Properties lockProps)Create and initializes anIDLockinstance, ready for use.AbstractDLockcreateLock(String name)Create a new lock.protected abstract AbstractDLockcreateLockInternal(String name, Properties lockProps)Create a new lock instance, but does not initialize it.voiddestroy()StringgetLockNamePrefix()protected PropertiesgetLockProperties(String name)Get a lock's properties.protected Map<String,Properties>getLockPropertiesMap()Get all locks properties settings.AbstractDLockFactoryinit()AbstractDLockFactorysetLockNamePrefix(String lockNamePrefix)Name of locks created by this factory will be prefixed by this string.AbstractDLockFactorysetLockProperties(Map<String,Properties> lockProperties)
-
-
-
Method Detail
-
init
public AbstractDLockFactory init()
-
destroy
public void destroy()
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
getLockNamePrefix
public String getLockNamePrefix()
-
setLockNamePrefix
public AbstractDLockFactory setLockNamePrefix(String lockNamePrefix)
Name of locks created by this factory will be prefixed by this string.- Parameters:
lockNamePrefix-- Returns:
-
setLockProperties
public AbstractDLockFactory setLockProperties(Map<String,Properties> lockProperties)
-
getLockPropertiesMap
protected Map<String,Properties> getLockPropertiesMap()
Get all locks properties settings.- Returns:
-
getLockProperties
protected Properties getLockProperties(String name)
Get a lock's properties.- Parameters:
name-- Returns:
-
createLock
public AbstractDLock createLock(String name)
Create a new lock.- Specified by:
createLockin interfaceIDLockFactory- Returns:
-
createAndInitLockInstance
protected AbstractDLock createAndInitLockInstance(String name, Properties lockProps)
Create and initializes anIDLockinstance, ready for use.- Parameters:
name-lockProps-- Returns:
-
createLockInternal
protected abstract AbstractDLock createLockInternal(String name, Properties lockProps)
Create a new lock instance, but does not initialize it. Convenient method for sub-class to override.- Parameters:
name-lockProps-- Returns:
-
-