public final class Database extends java.util.Observable implements IXMLEncodable
Modifier and Type | Class and Description |
---|---|
static interface |
Database.IWebInfo |
private class |
Database.TimeoutThread |
Modifier and Type | Field and Description |
---|---|
private boolean |
m_bStopThread |
private java.lang.Class |
m_DatabaseEntryClass
The DatabaseEntry class for that this Database is registered.
|
private java.lang.Thread |
m_dbThread |
private MyRandom |
m_random |
private long |
m_randomSeed |
private java.util.Hashtable |
m_serviceDatabase
Stores services we know.
|
private java.util.Vector |
m_timeoutList
Chronological order (in relation to timeouts) of all objects in the
database.
|
private static boolean |
ms_bIsLoading |
private static boolean |
ms_bShutdown |
private static java.util.Hashtable |
ms_databases
The registered databases.
|
private static IDistributor |
ms_distributor
The distributor that forwards new database entries.
|
private static IEDBDatabase |
ms_edbDatabase |
private static java.lang.Thread |
ms_vacuumThread |
private static java.lang.Object |
SYNC_EXTERNAL_DATABASE |
private java.lang.Object |
SYNC_THREAD |
private static java.lang.String |
XML_ALL_DB_NAME |
FIELD_XML_ELEMENT_CONTAINER_NAME, FIELD_XML_ELEMENT_NAME, XML_ATTR_ID, XML_ATTR_LANGUAGE, XML_ATTR_VERSION
Modifier | Constructor and Description |
---|---|
private |
Database(java.lang.Class a_DatabaseEntryClass)
Creates a new instance of a Database.
|
Modifier and Type | Method and Description |
---|---|
private void |
addExternal_int(AbstractDatabaseEntry a_newEntry) |
private void |
addExternal(AbstractDatabaseEntry a_newEntry) |
void |
addObserver(java.util.Observer a_observer)
Adds an observer to this database.
|
private static void |
doVacuum() |
static org.w3c.dom.Document |
dumpToXML(java.lang.Class[] classesToDump) |
AbstractDatabaseEntry |
getEntryById(java.lang.String entryId)
Returns the DatabaseEntry with the given ID.
|
java.lang.Class |
getEntryClass()
Returns the DatabaseEntry class for that this Database is registered.
|
java.util.Hashtable |
getEntryHash() |
java.util.Vector |
getEntryList()
Returns a snapshot of all values in the serviceDatabase.
|
java.util.Vector |
getEntryList(boolean a_bForceRandomize) |
java.util.Enumeration |
getEntrySnapshotAsEnumeration()
Returns a snapshot of all entries in the Database as an Enumeration.
|
static Database |
getInstance(java.lang.Class a_DatabaseEntryClass)
Gets the Database for the specified database entries.
|
int |
getNumberOfEntries()
Returns the number of DatabaseEntries in the Database.
|
AbstractDatabaseEntry |
getRandomEntry()
Returns a random entry from the database.
|
java.util.Vector |
getSortedEntryList(Util.Comparable c) |
int |
getTimeoutListSize() |
org.w3c.dom.Document |
getWebInfos() |
private static org.w3c.dom.Document |
getWebInfos(java.lang.Class a_webInfoClass)
get WebInfos for all entries
|
private static org.w3c.dom.Document |
getWebInfos(java.lang.Class a_webInfoClass,
java.lang.String a_ID)
get WebInfos for an entry with the specified ID
|
org.w3c.dom.Document |
getWebInfos(java.lang.String a_ID) |
boolean |
isEntryIdInTimeoutList(java.lang.String a_entryId) |
static void |
loadFromExternalDatabase_int() |
static void |
loadFromExternalDatabase() |
int |
loadFromXml(org.w3c.dom.Element a_dbNode)
Adds all database entries that are subnodes of the given element to the
database.
|
int |
loadFromXml(org.w3c.dom.Element a_dbNode,
boolean a_bVerify)
Adds all database entries that are subnodes of the given element to the
database.
|
void |
randomize() |
static void |
registerDistributor(IDistributor a_distributor)
Registers a distributor that forwards new database entries.
|
static boolean |
registerExternalDatabase(IEDBConfiguration a_dbConf) |
private static Database |
registerInstance(Database a_Database)
Registers a Database object.
|
boolean |
remove(AbstractDatabaseEntry a_deleteEntry)
Removes an entry from the database.
|
boolean |
remove(java.lang.String a_entryID)
Removes an entry from the database.
|
void |
removeAll()
Removes all entries from the database.
|
private void |
removeExternal_int(AbstractDatabaseEntry a_newEntry) |
private void |
removeExternal(AbstractDatabaseEntry a_newEntry) |
boolean |
removeThis(AbstractDatabaseEntry a_deleteEntry) |
static void |
restoreFromXML(org.w3c.dom.Document xmlAllDBs,
java.lang.Class[] classesToRestore) |
static void |
shutdownDatabases() |
private void |
startThread() |
private void |
stopThread() |
private static boolean |
testDB(IEDBConfiguration a_dbConf) |
org.w3c.dom.Element |
toXmlElement(org.w3c.dom.Document a_doc)
If the entries of this database implement IXMLEncodable and has a proper
value for the field XML_ELEMENT_CONTAINER_NAME, this database is
transformed into an XML element.
|
org.w3c.dom.Element |
toXmlElement(org.w3c.dom.Document a_doc,
java.lang.String a_xmlContainerName)
Creates an XML node with all database entries, but only for those entries
that implement IXMLEncodable.
|
private static Database |
unregisterInstance(java.lang.Class a_DatabaseEntryClass)
Unregisters the Database object that contains instances of the specified
DatabaseEntry class.
|
private static void |
unregisterInstances()
Unregisters all Database instances This method is used for testing
purposes and should not be removed.
|
boolean |
update(AbstractDatabaseEntry newEntry)
Updates an entry in the database.
|
boolean |
update(AbstractDatabaseEntry newEntry,
boolean a_bDistribute)
Updates an entry in the database.
|
private static java.lang.String XML_ALL_DB_NAME
private static java.util.Hashtable ms_databases
private static java.lang.Thread ms_vacuumThread
private static IDistributor ms_distributor
private static boolean ms_bShutdown
private java.lang.Class m_DatabaseEntryClass
private java.lang.Thread m_dbThread
private final java.lang.Object SYNC_THREAD
private java.util.Hashtable m_serviceDatabase
private MyRandom m_random
private long m_randomSeed
private java.util.Vector m_timeoutList
private volatile boolean m_bStopThread
private static final java.lang.Object SYNC_EXTERNAL_DATABASE
private static IEDBDatabase ms_edbDatabase
private static boolean ms_bIsLoading
private Database(java.lang.Class a_DatabaseEntryClass) throws java.lang.IllegalArgumentException
a_DatabaseEntryClass
- the DatabaseEntry class for that this Database is registeredjava.lang.IllegalArgumentException
- if the argument is no valid DatabaseEntry classpublic static void registerDistributor(IDistributor a_distributor)
a_distributor
- a distributor that forwards new database entriespublic static boolean registerExternalDatabase(IEDBConfiguration a_dbConf)
private static boolean testDB(IEDBConfiguration a_dbConf) throws java.lang.Exception
java.lang.Exception
private static Database registerInstance(Database a_Database)
a_Database
- the registered Databaseprivate static Database unregisterInstance(java.lang.Class a_DatabaseEntryClass)
a_DatabaseEntryClass
- the DatabaseEntry class for that the corresponding Database is
unregisteredprivate static void unregisterInstances()
public static Database getInstance(java.lang.Class a_DatabaseEntryClass) throws java.lang.IllegalArgumentException
a_DatabaseEntryClass
- the DatabaseEntry class for that the method returns the
corresponding Database objectjava.lang.IllegalArgumentException
- if the argument is no valid DatabaseEntry classpublic static void restoreFromXML(org.w3c.dom.Document xmlAllDBs, java.lang.Class[] classesToRestore)
public static org.w3c.dom.Document dumpToXML(java.lang.Class[] classesToDump)
public static void shutdownDatabases()
private void startThread()
private void stopThread()
public boolean update(AbstractDatabaseEntry newEntry) throws java.lang.IllegalArgumentException
newEntry
- The database entry to update.java.lang.IllegalArgumentException
- if the database entry is not of the type the Database can
storepublic boolean update(AbstractDatabaseEntry newEntry, boolean a_bDistribute) throws java.lang.IllegalArgumentException
newEntry
- The database entry to update.a_bDistribute
- distribute to other InfoServices if distributor object is set;
should be defaultjava.lang.IllegalArgumentException
- if the database entry is not of the type the Database can
storepublic java.lang.Class getEntryClass()
public boolean remove(java.lang.String a_entryID)
a_entryID
- The ID of the entry to remove. If it is not in the database,
nothing is done.public boolean remove(AbstractDatabaseEntry a_deleteEntry)
a_deleteEntry
- The entry to remove. If it is not in the database, nothing is
done.public boolean removeThis(AbstractDatabaseEntry a_deleteEntry)
public void removeAll()
public int loadFromXml(org.w3c.dom.Element a_dbNode)
a_dbNode
- The xml node that contains db entries.public int loadFromXml(org.w3c.dom.Element a_dbNode, boolean a_bVerify)
a_dbNode
- The xml node that contains db entries.a_signatureDocumentClass
- if set to a value greater -1, the document is verified against
certificates of the given class before getting loadedpublic org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
toXmlElement
in interface IXMLEncodable
a_doc
- a Documentpublic org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc, java.lang.String a_xmlContainerName)
a_doc
- The XML document, which is the environment for the created XML
node.a_xmlContainerName
- the name of the XML element that should contain the entriespublic void randomize()
public java.util.Hashtable getEntryHash()
public java.util.Vector getEntryList()
public java.util.Vector getEntryList(boolean a_bForceRandomize)
public java.util.Vector getSortedEntryList(Util.Comparable c)
public java.util.Enumeration getEntrySnapshotAsEnumeration()
public int getNumberOfEntries()
public AbstractDatabaseEntry getEntryById(java.lang.String entryId)
entryId
- The ID of the database entry.public AbstractDatabaseEntry getRandomEntry()
public void addObserver(java.util.Observer a_observer)
addObserver
in class java.util.Observable
a_observer
- The observer to add to this database.public boolean isEntryIdInTimeoutList(java.lang.String a_entryId)
public int getTimeoutListSize()
public org.w3c.dom.Document getWebInfos(java.lang.String a_ID)
public org.w3c.dom.Document getWebInfos()
private static org.w3c.dom.Document getWebInfos(java.lang.Class a_webInfoClass, java.lang.String a_ID)
private static org.w3c.dom.Document getWebInfos(java.lang.Class a_webInfoClass)
private void addExternal(AbstractDatabaseEntry a_newEntry)
private static void doVacuum() throws EDBException
EDBException
private void addExternal_int(AbstractDatabaseEntry a_newEntry) throws EDBException
EDBException
private void removeExternal(AbstractDatabaseEntry a_newEntry)
private void removeExternal_int(AbstractDatabaseEntry a_newEntry) throws EDBException
EDBException
public static void loadFromExternalDatabase()
public static void loadFromExternalDatabase_int() throws EDBException
EDBException
Copyright © 2023. All rights reserved.