KEY - EntryKeyENTRY - EntryTypeMAP - RegistryEntryMapREGISTRY - RegistryPLUGIN - RegistryPluginTypepublic class AbstractRegistry<KEY,ENTRY extends Identifiable<KEY>,MAP extends Map<KEY,ENTRY>,REGISTRY extends Registry<KEY,ENTRY>,PLUGIN extends RegistryPlugin<KEY,ENTRY,REGISTRY>> extends org.openbase.jul.pattern.ObservableImpl<Map<KEY,ENTRY>> implements Registry<KEY,ENTRY>
Shutdownable.ShutdownDeamon| Modifier and Type | Field and Description |
|---|---|
protected boolean |
consistent |
protected org.slf4j.Logger |
logger |
protected RegistryPluginPool<KEY,ENTRY,PLUGIN,REGISTRY> |
pluginPool |
protected RegistrySandbox<KEY,ENTRY,MAP,REGISTRY> |
sandbox |
latestValueHash, observers, unchangedValueFilterTYPE_FIELD_NAME| Constructor and Description |
|---|
AbstractRegistry(MAP entryMap) |
AbstractRegistry(MAP entryMap,
RegistryPluginPool<KEY,ENTRY,PLUGIN,REGISTRY> pluginPool) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDependencyObserver(org.openbase.jul.pattern.Observer<Map<KEY,ENTRY>> observer) |
protected void |
afterConsistencyCheck()
Can be overwritten for further registry actions scheduled after consistency checks.
|
int |
checkConsistency() |
void |
checkWriteAccess() |
void |
clear() |
boolean |
contains(ENTRY entry) |
boolean |
contains(KEY key) |
protected void |
finishTransaction() |
ENTRY |
get(KEY key) |
List<ENTRY> |
getEntries()
Copies all entries into a list.
|
Map<KEY,ENTRY> |
getEntryMap()
An unmodifiable map of the current entry map.
|
Class |
getEntryMapClass() |
String |
getName()
Method returns the name of this registry.
|
void |
info(String message)
Deprecated.
please use method
log(String message). |
boolean |
isBusy() |
boolean |
isBusyByCurrentThread() |
boolean |
isConsistent() |
protected boolean |
isDependingOnConsistentRegistries()
If this registry depends on other registries, this method can be used to tell this registry if all depending registries are consistent.
|
boolean |
isEmpty()
Return true if this registry does not contain any entries.
|
boolean |
isReadOnly() |
boolean |
isReady()
This method checks if the registry is not handling any tasks or notification and is currently consistent.
|
boolean |
isSandbox() |
protected boolean |
isWriteLockedByCurrentThread() |
ENTRY |
load(ENTRY entry) |
protected void |
lock()
Blocks until this registries write lock and the write locks of all registries this one depends on are acquired.
|
protected void |
log(String message)
This method can be used to log registry log messages which are only printed for the origin registry.
|
protected void |
log(String message,
LogLevel logLevel)
This method can be used to log registry log messages which are only printed for the origin registry.
|
protected void |
log(String message,
LogLevel logLevel,
Throwable throwable)
This method can be used to log registry log messages which are only printed for the origin registry.
|
protected void |
notifyObservers() |
boolean |
recursiveTryLockRegistry(Set<Registry> lockedRegistries)
Try to acquire the write lock for this registry and the registries it depends
on recursively.
|
ENTRY |
register(ENTRY entry)
Method registers the given entry.
|
void |
registerConsistencyHandler(ConsistencyHandler<KEY,ENTRY,MAP,REGISTRY> consistencyHandler) |
void |
registerDependency(Registry registry)
If this registry depends on other registries, this method can be used to tell this registry all depending registries.
|
void |
registerPlugin(PLUGIN plugin)
Method can be used to register any compatible registry plugin for this
registry.
|
ENTRY |
remove(ENTRY entry) |
ENTRY |
remove(KEY key) |
void |
removeAllDependencies()
Removal of all registered registry dependencies in the reversed order in which they where added.
|
void |
removeConsistencyHandler(ConsistencyHandler<KEY,ENTRY,MAP,REGISTRY> consistencyHandler) |
void |
removeDependency(Registry registry)
This method allows the removal of a registered registry dependency.
|
void |
removeDependencyObserver(org.openbase.jul.pattern.Observer<Map<KEY,ENTRY>> observer) |
void |
replaceInternalMap(Map<KEY,ENTRY> map)
Replaces the internal registry map by the given one.
|
void |
replaceInternalMap(Map<KEY,ENTRY> map,
boolean finishTransaction)
Replaces the internal registry map by the given one.
|
void |
setName(String name)
Method defines the name of this registry.
|
protected <S extends AbstractRegistry<KEY,ENTRY,MAP,REGISTRY,PLUGIN> & RegistrySandbox<KEY,ENTRY,MAP,REGISTRY>> |
setupSandbox(S sandbox) |
void |
shutdown() |
int |
size()
Method returns the amount of registry entries.
|
ENTRY |
superRemove(ENTRY entry) |
String |
toString() |
boolean |
tryLockRegistry()
Try to acquire the write lock for this registry.
|
protected void |
unlock() |
void |
unlockRegistry()
Unlock the write lock of the registry.
|
ENTRY |
update(ENTRY entry) |
protected KEY |
verifyID(ENTRY entry) |
protected KEY |
verifyID(KEY key) |
applyValueUpdate, getValue, getValueFuture, isValueAvailable, waitForValueaddObserver, isNotificationInProgess, notifyObservers, notifyObservers, removeObserver, setExecutorService, setHashGenerator, waitUntilNotificationIsFinishedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisWritableaddObserver, getLatestValue, getValue, getValueFuture, isValueAvailable, removeObserver, waitForValue, waitForValueregisterShutdownHook, registerShutdownHookprotected final org.slf4j.Logger logger
protected final RegistryPluginPool<KEY,ENTRY extends Identifiable<KEY>,PLUGIN extends RegistryPlugin<KEY,ENTRY,REGISTRY>,REGISTRY extends Registry<KEY,ENTRY>> pluginPool
protected RegistrySandbox<KEY,ENTRY extends Identifiable<KEY>,MAP extends Map<KEY,ENTRY>,REGISTRY extends Registry<KEY,ENTRY>> sandbox
protected boolean consistent
public AbstractRegistry(MAP entryMap) throws InstantiationException
InstantiationExceptionpublic AbstractRegistry(MAP entryMap, RegistryPluginPool<KEY,ENTRY,PLUGIN,REGISTRY> pluginPool) throws InstantiationException
InstantiationExceptionprotected <S extends AbstractRegistry<KEY,ENTRY,MAP,REGISTRY,PLUGIN> & RegistrySandbox<KEY,ENTRY,MAP,REGISTRY>> void setupSandbox(S sandbox) throws CouldNotPerformException
CouldNotPerformExceptionpublic ENTRY register(ENTRY entry) throws CouldNotPerformException
register in interface Registry<KEY,ENTRY extends Identifiable<KEY>>entry - the new entry to register which is not yet included in the registryCouldNotPerformException - is thrown if the given entry is not valid, already registered or something else went wrong during the registration.public ENTRY load(ENTRY entry) throws CouldNotPerformException
CouldNotPerformExceptionpublic ENTRY update(ENTRY entry) throws CouldNotPerformException
update in interface Registry<KEY,ENTRY extends Identifiable<KEY>>entry - CouldNotPerformExceptionpublic ENTRY remove(KEY key) throws CouldNotPerformException
remove in interface Registry<KEY,ENTRY extends Identifiable<KEY>>key - CouldNotPerformExceptionpublic ENTRY remove(ENTRY entry) throws CouldNotPerformException
remove in interface Registry<KEY,ENTRY extends Identifiable<KEY>>entry - CouldNotPerformExceptionpublic ENTRY superRemove(ENTRY entry) throws CouldNotPerformException
CouldNotPerformExceptionpublic ENTRY get(KEY key) throws CouldNotPerformException
get in interface Registry<KEY,ENTRY extends Identifiable<KEY>>key - CouldNotPerformExceptionpublic List<ENTRY> getEntries() throws CouldNotPerformException
getEntries in interface Registry<KEY,ENTRY extends Identifiable<KEY>>CouldNotPerformException - if something failspublic Map<KEY,ENTRY> getEntryMap()
RegistrygetEntryMap in interface Registry<KEY,ENTRY extends Identifiable<KEY>>public int size()
public boolean isEmpty()
public boolean contains(ENTRY entry) throws CouldNotPerformException
contains in interface Registry<KEY,ENTRY extends Identifiable<KEY>>entry - CouldNotPerformExceptionpublic boolean contains(KEY key) throws CouldNotPerformException
contains in interface Registry<KEY,ENTRY extends Identifiable<KEY>>key - CouldNotPerformExceptionpublic void clear()
throws CouldNotPerformException
clear in interface Registry<KEY,ENTRY extends Identifiable<KEY>>CouldNotPerformExceptionpublic void replaceInternalMap(Map<KEY,ENTRY> map) throws CouldNotPerformException
Use with care!
map - CouldNotPerformExceptionpublic Class getEntryMapClass()
public void replaceInternalMap(Map<KEY,ENTRY> map, boolean finishTransaction) throws CouldNotPerformException
Use with care!
map - finishTransaction - is true the registry transaction will be verified.CouldNotPerformExceptionpublic void checkWriteAccess()
throws RejectedException
checkWriteAccess in interface WritableRejectedExceptionprotected boolean isDependingOnConsistentRegistries()
public void registerDependency(Registry registry) throws CouldNotPerformException
registry - the dependency of these registry.CouldNotPerformExceptionpublic void removeDependency(Registry registry) throws CouldNotPerformException
registry - the dependency to remove.CouldNotPerformExceptionpublic void removeAllDependencies()
public boolean isReadOnly()
isReadOnly in interface Registry<KEY,ENTRY extends Identifiable<KEY>>protected final void notifyObservers()
protected KEY verifyID(ENTRY entry) throws VerificationFailedException
VerificationFailedExceptionprotected KEY verifyID(KEY key) throws VerificationFailedException
VerificationFailedExceptionpublic void registerConsistencyHandler(ConsistencyHandler<KEY,ENTRY,MAP,REGISTRY> consistencyHandler) throws CouldNotPerformException
CouldNotPerformExceptionpublic void removeConsistencyHandler(ConsistencyHandler<KEY,ENTRY,MAP,REGISTRY> consistencyHandler) throws CouldNotPerformException
CouldNotPerformExceptionpublic final int checkConsistency()
throws CouldNotPerformException
CouldNotPerformExceptionprotected void afterConsistencyCheck()
throws CouldNotPerformException
Don't forgett to pass-througt the call to the super class. (super.afterConsistencyCheck())
CouldNotPerformException - is thrown if any plugin afterConsistencyCheck fails.protected void finishTransaction()
throws CouldNotPerformException
CouldNotPerformExceptionpublic boolean isConsistent()
isConsistent in interface Registry<KEY,ENTRY extends Identifiable<KEY>>public boolean isReady()
public void shutdown()
shutdown in interface Shutdownableshutdown in class org.openbase.jul.pattern.AbstractObservable<Map<KEY,ENTRY extends Identifiable<KEY>>>public void registerPlugin(PLUGIN plugin) throws CouldNotPerformException, InterruptedException
plugin - the plugin to register.CouldNotPerformException - is thrown in case the plugin could not
be registered.InterruptedException - is thrown if the thread is externally
interrupted.public String getName()
getName in interface NameProvidergetName in interface Registry<KEY,ENTRY extends Identifiable<KEY>>public void setName(String name)
name - public boolean isSandbox()
protected void log(String message)
message - the info message to print as string.protected void log(String message, LogLevel logLevel, Throwable throwable)
message - the info message to print as string.logLevel - the log level to log the message.throwable - the cause of the message.protected void log(String message, LogLevel logLevel)
message - the info message to print as string.logLevel - the log level to log the message.@Deprecated public void info(String message)
log(String message).message - the info message to print as string.public String toString()
toString in class org.openbase.jul.pattern.AbstractObservable<Map<KEY,ENTRY extends Identifiable<KEY>>>protected void lock()
throws CouldNotPerformException
CouldNotPerformException - Is thrown if the process gets interrupted. Additionally the interrupt flag is restored.public boolean isBusy()
public boolean isBusyByCurrentThread()
protected void unlock()
protected boolean isWriteLockedByCurrentThread()
public boolean tryLockRegistry()
throws RejectedException
tryLockRegistry in interface Registry<KEY,ENTRY extends Identifiable<KEY>>RejectedException - If the registry does not support to be locked externally which is for example the case for remote registries.public boolean recursiveTryLockRegistry(Set<Registry> lockedRegistries) throws RejectedException
recursiveTryLockRegistry in interface Registry<KEY,ENTRY extends Identifiable<KEY>>lockedRegistries - Set of already locked registries. Should be given empty to this method and will contain all locked registries afterwards.RejectedException - If the registry does not support to be locked externally which is for example the case for remote registries.public void unlockRegistry()
unlockRegistry in interface Registry<KEY,ENTRY extends Identifiable<KEY>>public void addDependencyObserver(org.openbase.jul.pattern.Observer<Map<KEY,ENTRY>> observer)
addDependencyObserver in interface Registry<KEY,ENTRY extends Identifiable<KEY>>public void removeDependencyObserver(org.openbase.jul.pattern.Observer<Map<KEY,ENTRY>> observer)
removeDependencyObserver in interface Registry<KEY,ENTRY extends Identifiable<KEY>>Copyright © 2015–2018 openbase.org. All rights reserved.