Package com.helger.dao
Class AbstractDAO
java.lang.Object
com.helger.dao.AbstractDAO
- All Implemented Interfaces:
com.helger.commons.log.IHasConditionalLogger,IAutoSaveAware,IDAO
- Direct Known Subclasses:
AbstractSimpleDAO,AbstractWALDAO
@ThreadSafe
public abstract class AbstractDAO
extends Object
implements IDAO, com.helger.commons.log.IHasConditionalLogger
Base implementation of
IDAO- Author:
- Philip Helger
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.helger.dao.IDAO
IDAO.EMode -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final com.helger.commons.log.ConditionalLoggerstatic final booleanBy default auto-save is enabledstatic final StringThe default extension for a file that is newly created.static final StringThe default extension for an old file that was not yet deleted.protected final com.helger.commons.concurrent.SimpleReadWriteLockprotected static final com.helger.commons.concurrent.SimpleReadWriteLock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidStart doing something without auto save.protected static voidcheckFileAccess(File aFile, IDAO.EMode eMode) Check the access to the passed file using the specified mode.final voidEnd doing something without auto save.static final com.helger.commons.callback.CallbackList<IDAOReadExceptionCallback>static final com.helger.commons.callback.CallbackList<IDAOWriteExceptionCallback>final booleanfinal booleanprotected final booleanfinal voidinternalSetPendingChanges(boolean bPendingChanges) final booleanstatic booleanstatic booleansetSilentMode(boolean bSilentMode) Enable or disable certain regular log messages.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.dao.IAutoSaveAware
performWithoutAutoSave, performWithoutAutoSave, performWithoutAutoSaveThrowing, performWithoutAutoSaveThrowingMethods inherited from interface com.helger.dao.IDAO
getInitCount, getLastInitDateTime, getLastReadDateTime, getLastWriteDateTime, getReadCount, getWriteCount, isReloadable, reload, writeToFileOnPendingChanges
-
Field Details
-
DEFAULT_AUTO_SAVE_ENABLED
public static final boolean DEFAULT_AUTO_SAVE_ENABLEDBy default auto-save is enabled- See Also:
-
FILENAME_EXTENSION_PREV
The default extension for an old file that was not yet deleted. Mainly used in the WAL DAO- See Also:
-
FILENAME_EXTENSION_NEW
The default extension for a file that is newly created. Mainly used in the WAL DAO- See Also:
-
RW_LOCK
protected static final com.helger.commons.concurrent.SimpleReadWriteLock RW_LOCK -
CONDLOG
protected static final com.helger.commons.log.ConditionalLogger CONDLOG -
m_aRWLock
protected final com.helger.commons.concurrent.SimpleReadWriteLock m_aRWLock
-
-
Constructor Details
-
AbstractDAO
protected AbstractDAO()
-
-
Method Details
-
isSilentMode
public static boolean isSilentMode()- Returns:
trueif logging is disabled,falseif it is enabled.- Since:
- 9.2.0
-
setSilentMode
public static boolean setSilentMode(boolean bSilentMode) Enable or disable certain regular log messages.- Parameters:
bSilentMode-trueto disable logging,falseto enable logging- Returns:
- The previous value of the silent mode.
- Since:
- 9.2.0
-
exceptionHandlersRead
@Nonnull @ReturnsMutableObject public static final com.helger.commons.callback.CallbackList<IDAOReadExceptionCallback> exceptionHandlersRead()- Returns:
- The static mutable exception handler list that is invoked for read
exceptions. Never
null. The list applies to ALL DAOs since it is static.
-
exceptionHandlersWrite
@Nonnull @ReturnsMutableObject public static final com.helger.commons.callback.CallbackList<IDAOWriteExceptionCallback> exceptionHandlersWrite()- Returns:
- The static mutable exception handler list that is invoked for write
exceptions. Never
null. The list applies to ALL DAOs since it is static.
-
internalIsAutoSaveEnabled
@MustBeLocked(READ) protected final boolean internalIsAutoSaveEnabled()- Returns:
trueif auto save is enabled,falseotherwise.
-
isAutoSaveEnabled
public final boolean isAutoSaveEnabled()- Specified by:
isAutoSaveEnabledin interfaceIAutoSaveAware- Returns:
trueif auto save is enabled,falseotherwise.
-
internalSetPendingChanges
@MustBeLocked(WRITE) public final void internalSetPendingChanges(boolean bPendingChanges) -
internalHasPendingChanges
@MustBeLocked(READ) public final boolean internalHasPendingChanges()- Returns:
trueif unsaved changes are present
-
hasPendingChanges
public final boolean hasPendingChanges()- Specified by:
hasPendingChangesin interfaceIDAO- Returns:
trueif unsaved changes are present
-
beginWithoutAutoSave
public final void beginWithoutAutoSave()Description copied from interface:IAutoSaveAwareStart doing something without auto save.- Specified by:
beginWithoutAutoSavein interfaceIAutoSaveAware
-
endWithoutAutoSave
public final void endWithoutAutoSave()Description copied from interface:IAutoSaveAwareEnd doing something without auto save. It must be ensure that each call toIAutoSaveAware.beginWithoutAutoSave()is always correctly ended with a call to this method.- Specified by:
endWithoutAutoSavein interfaceIAutoSaveAware
-
checkFileAccess
protected static void checkFileAccess(@Nonnull File aFile, @Nonnull IDAO.EMode eMode) throws DAOException Check the access to the passed file using the specified mode. If the access is not provided, aDAOExceptionis thrown. If everything is good, this method returns without a comment.- Parameters:
aFile- The file to check. May not benull.eMode- The access mode. May not benull.- Throws:
DAOException- If the requested access mode cannot be provided.
-
toString
-