public class ConfigFileManager extends Object implements ConfigurationFileManager
Modifier and Type | Class and Description |
---|---|
private static class |
ConfigFileManager.LoadInformations
Diese Klasse speichert alle Informationen, die nötig sind um ein als "ungültig" markiertes Objekt nachträglich komplett aus einer Datei in den Hauptspeicher
zu laden.
|
private static class |
ConfigFileManager.PidAndSimvar
Speichert eine Pid zusammen mit einer Simulationsvariante für die Verwaltung der Simulationsspezifischen Pids
|
Modifier and Type | Field and Description |
---|---|
private Map<String,ConfigurationAreaFile> |
_configurationFiles
HashMap, die alle Dateien und somit Konfigurationsbereiche verwaltet.
|
private static Debug |
_debug
DebugLogger für Debug-Ausgaben
|
private Map<Long,Object> |
_idMap
Speichert "alle" Objekte, aller Konfigurationsbereiche.
|
private Map<String,SystemObjectInformationInterface> |
_pidMapActive
Speichert alle aktiven Objekte, aller Konfigurationsbereiche.
|
private Map<String,Set<SystemObjectInformationInterface>> |
_pidMapNew
Speichert alle noch nicht aktiven Objekte, aller Konfigurationsbereiche.
|
private Map<ConfigFileManager.PidAndSimvar,SystemObjectInformationInterface> |
_pidMapSimulation
Speichert alle dynamischen Objekte aus Simulationen anhand von Pid und Simulationsvariente.
|
private Map<Short,Set<DynamicObjectInformation>> |
_simulationObjects
Speichert zu einer Simulationsvariante alle dynamischen Objekte.
|
Constructor and Description |
---|
ConfigFileManager() |
Modifier and Type | Method and Description |
---|---|
ConfigurationAreaFile |
addAreaFile(String configurationAreaPid,
File configurationAreaDir,
short activeVersion,
List<VersionInfo> localVersionTimes)
Der aktuellen Konfiguration wird der angegebene Konfigurationsbereich hinzugefügt.
|
void |
close()
Diese Methode wird aufgerufen, wenn ein System heruntegefahren werden soll.
|
ConfigurationAreaFile |
createAreaFile(String configurationAreaPid,
File configurationAreaDir)
Diese Methode erstellt zu einem neuen Konfigurationsbereich eine Konfigurationsdatei.
|
SystemObjectInformationInterface |
getActiveObject(long id) |
SystemObjectInformationInterface |
getActiveObject(String pid)
Diese Methode gibt ein Objekt zurück, das derzeit in einem Konfigurationsbereich aktiv ist.
|
ConfigurationAreaFile |
getAreaFile(String configurationAreaPid)
Diese Methode gibt ein Objekt zurück, das den Konfigurationsbereich darstellt.
|
ConfigurationAreaFile[] |
getConfigurationAreas()
Diese Methode gibt alle Konfigurationsbereiche zurück, die mit
ConfigurationFileManager.addAreaFile(java.lang.String, java.io.File, short, java.util.List<de.bsvrz.puk.config.main.managementfile.VersionInfo>) eingefügt wurden. |
SystemObjectInformationInterface[] |
getNewObjects(String pid)
Diese Methode gibt alle Objekte zurück, die derzeit in einem Konfigurationsbereich weder aktiv noch als ungültig markiert sind.
|
SystemObjectInformationInterface |
getObject(long id)
Gibt ein Objekt zurück, das über die Id identifiziert wird.
|
List<DynamicObjectInfo> |
getObjects(short simulationVariant)
Diese Methode gibt alle dynamischen Objekte zurück, die zu einer Simulationsvariante gehören.
|
SystemObjectInformationInterface |
getOldObject(long id) |
SystemObjectInformationInterface |
getSimulationObject(String pid,
short simulationVariant)
Gibt ein simulationsspezifisches Objekt anhand der Pid zurück.
|
private SystemObjectInformationInterface |
loadOldObject(ConfigFileManager.LoadInformations oldObject)
Lädt ein als ungültig markiertes Objekt in den Hauptspeicher
|
(package private) void |
newObjectCreated(SystemObjectInformationInterface newObjectInfo)
Diese Methode wird aufgerufen, wenn ein neues dynamisches Objekt oder Konfigurationsobjekt zu einem Konfigurationsbreich hinzugefügt wurde.
|
private void |
putActiveObjectPidHashMap(SystemObjectInformationInterface object)
Legt ein Objekt in der Map ab, die alle Pids, aller aktiven Objekte verwaltet.
|
private void |
putNewObjectPidHashMap(SystemObjectInformationInterface object) |
private void |
putObjectId(Long id,
ConfigFileManager.LoadInformations object) |
private void |
putObjectId(SystemObjectInformationInterface object) |
(package private) void |
putSimulationObject(DynamicObjectInformation dynamicObjectInformation)
Fügt ein dynamisches Objekt mit einer Simulationsvariante größer 0 in eine Map ein.
|
private void |
removeActiveObjectPidHashMap(DynamicObjectInfo dynamicObjectInfo)
Entfernt ein Objekt aus der Map, die alle Pids der aktiven Objekte verwaltet.
|
(package private) void |
removeDynamicSimulationObject(DynamicObjectInformation dynamicObjectInformation)
Entfernt ein dynamisches Objekt mit einer Simulationvariante größer 0 aus allen Datenstrukturen, die zum schnellen Zugriff auf Objekte angelegt wurden.
|
(package private) void |
removeNewObject(ConfigurationObjectInfo object)
Entfernt ein Objekt, das in zukünftig gültig sein wird, aus den Datenstrukturen des Objekts dieser Klasse.
|
(package private) void |
removeObject(long id)
Entfernt ein Objekt aus der Datenstruktur, die den schnellen Zugriff mittels Id auf Objekte zuläßt.
|
private void |
removeSimulationObjectFromMap(DynamicObjectInformation dynamicObjectInformation)
Entfernt ein dynamisches Objekt aus der Datenstruktur, die alle dynamischen Objekte über Simulationsvariante verwaltet.
|
private void |
removeSimulationObjectPidHashMap(DynamicObjectInfo dynamicObjectInfo,
short simulationVariant)
Dasselbe wie removeActiveObjectPidHashMap(DynamicObjectInfo), nur für Simulationsobjekte
|
void |
saveConfigurationAreaFiles()
Methode, die alle Konfigurationsbreiche speichert.
|
(package private) void |
setDynamicObjectInvalid(DynamicObjectInformation oldDynamicObject)
Ein dynamisches Objekt wird ungültig (Konfigurationsobjekte müssen nicht beachtet werden, da sie erst beim nächsten Neustart ungültig werden)
|
private static final Debug _debug
private final Map<Long,Object> _idMap
private final Map<String,SystemObjectInformationInterface> _pidMapActive
private final Map<ConfigFileManager.PidAndSimvar,SystemObjectInformationInterface> _pidMapSimulation
_pidMapActive
gespeichert, da Pids nur je Simulationsvariante eindeutig sein müssen und es sonst zu Kollisionen bei Verwendung
der gleichen Pid in unterschieldichen Simulationen kommen könnte.private final Map<String,Set<SystemObjectInformationInterface>> _pidMapNew
private final Map<String,ConfigurationAreaFile> _configurationFiles
private final Map<Short,Set<DynamicObjectInformation>> _simulationObjects
public ConfigurationAreaFile createAreaFile(String configurationAreaPid, File configurationAreaDir) throws IllegalArgumentException, IOException, NoSuchVersionException
createAreaFile
in interface ConfigurationFileManager
configurationAreaPid
- die Pid des neuen KonfigurationsbereichsconfigurationAreaDir
- das Verzeichnis, in dem die Konfigurationsdatei angelegt werden sollIllegalArgumentException
- Falls die Argumente ungültig sind.IOException
- Falls Fehler im Zusammenhang mit der Datei des Konfigurationsbereichs auftreten.NoSuchVersionException
- TBDpublic ConfigurationAreaFile addAreaFile(String configurationAreaPid, File configurationAreaDir, short activeVersion, List<VersionInfo> localVersionTimes) throws IllegalArgumentException, IOException, NoSuchVersionException
addAreaFile
in interface ConfigurationFileManager
configurationAreaPid
- die Pid des KonfigurationsbereichsconfigurationAreaDir
- das Verzeichnis, in dem die Konfigurationsdatei gespeichert wurde. Diese Verzeichnis wird benutzt um den Bereich zu laden.activeVersion
- die aktuelle Version des KonfigurationsbereichslocalVersionTimes
- Diese Liste speichert zu jeder Version, die jemals aktiviert wurde, den Zeitpunkt an dem die Version aktiviert wurde. Die
Zeitpunkte beziehen sich auf den Zeit, an dem sie auf der Konfiguration, die diese Methode aufruft, aktiviert wurden.IllegalArgumentException
- Falls der Konfigurationsbereich mit der Pid bereits zur Konfiguration hinzugefügt wurde.IllegalStateException
- Datei existiert nichtIOException
- TBDNoSuchVersionException
- TBDprivate void putActiveObjectPidHashMap(SystemObjectInformationInterface object)
object
- Objekt, das in die Map aufgenommen werden sollprivate void removeActiveObjectPidHashMap(DynamicObjectInfo dynamicObjectInfo)
dynamicObjectInfo
- Objekt, das aus der Map entfernt werden sollprivate void removeSimulationObjectPidHashMap(DynamicObjectInfo dynamicObjectInfo, short simulationVariant)
private void putNewObjectPidHashMap(SystemObjectInformationInterface object)
public ConfigurationAreaFile getAreaFile(String configurationAreaPid)
ConfigurationFileManager
getAreaFile
in interface ConfigurationFileManager
configurationAreaPid
- Pid des Konfigurationsbereichsnull
zurückgegeben.public SystemObjectInformationInterface getObject(long id)
ConfigurationFileManager
ConfigurationFileManager.addAreaFile(java.lang.String, java.io.File, short, java.util.List<de.bsvrz.puk.config.main.managementfile.VersionInfo>)
hinzugefügt
wurden.getObject
in interface ConfigurationFileManager
id
- Id des Objektsnull
falls kein Objekt gefunden werden konntevoid removeObject(long id)
id
- Id des Objekts, das entfernt werden sollvoid removeDynamicSimulationObject(DynamicObjectInformation dynamicObjectInformation)
dynamicObjectInformation
- Objekt, das entfernt werden sollpublic SystemObjectInformationInterface getActiveObject(long id)
public SystemObjectInformationInterface getActiveObject(String pid)
ConfigurationFileManager
ConfigurationFileManager.addAreaFile(java.lang.String, java.io.File, short, java.util.List<de.bsvrz.puk.config.main.managementfile.VersionInfo>)
hinzugefügt wurden. Objekte, die nur in Simulationen gültig sind werden hier nicht zurückgegeben,
stattdessen ist ConfigurationFileManager.getSimulationObject(String, short)
zu benutzen.getActiveObject
in interface ConfigurationFileManager
pid
- Pid des Objekts, das gesucht werden sollnull
falls kein Objekt existiertpublic SystemObjectInformationInterface getSimulationObject(String pid, short simulationVariant)
ConfigurationFileManager
getSimulationObject
in interface ConfigurationFileManager
pid
- PidsimulationVariant
- Simulationsvariantenull
falls kein Objekt existiertpublic SystemObjectInformationInterface[] getNewObjects(String pid)
ConfigurationFileManager
ConfigurationFileManager.addAreaFile(java.lang.String, java.io.File, short, java.util.List<de.bsvrz.puk.config.main.managementfile.VersionInfo>)
hinzugefügt wurden.getNewObjects
in interface ConfigurationFileManager
pid
- pid der gesuchten Objektepublic SystemObjectInformationInterface getOldObject(long id)
id
- null
falls nicht vorhandenprivate SystemObjectInformationInterface loadOldObject(ConfigFileManager.LoadInformations oldObject)
oldObject
- Objekt, das alle Informationen zum laden des Objekts enthältpublic ConfigurationAreaFile[] getConfigurationAreas()
ConfigurationFileManager
ConfigurationFileManager.addAreaFile(java.lang.String, java.io.File, short, java.util.List<de.bsvrz.puk.config.main.managementfile.VersionInfo>)
eingefügt wurden.getConfigurationAreas
in interface ConfigurationFileManager
void putSimulationObject(DynamicObjectInformation dynamicObjectInformation)
dynamicObjectInformation
- Objekt, das eingetragen werden sollprivate void removeSimulationObjectFromMap(DynamicObjectInformation dynamicObjectInformation)
dynamicObjectInformation
- Objekt, das entfernt werden sollpublic List<DynamicObjectInfo> getObjects(short simulationVariant) throws IllegalArgumentException
ConfigurationFileManager
getObjects
in interface ConfigurationFileManager
simulationVariant
- Simulationsvariante, für die alle dynamischen Objekte zurückgegeben werden sollen. (Wertebereich 1...999)IllegalArgumentException
void newObjectCreated(SystemObjectInformationInterface newObjectInfo)
newObjectInfo
- void setDynamicObjectInvalid(DynamicObjectInformation oldDynamicObject)
oldDynamicObject
- Objekt, das ungültig wurdevoid removeNewObject(ConfigurationObjectInfo object)
object
- Objekt, das aus allen Datenstrukturen entfernt werden sollprivate void putObjectId(SystemObjectInformationInterface object)
private void putObjectId(Long id, ConfigFileManager.LoadInformations object)
public void saveConfigurationAreaFiles() throws IOException
saveConfigurationAreaFiles
in interface ConfigurationFileManager
IOException
- Es ist beim speichern der Versorgungsdateien zu einem Fehler gekommen. Es wurde trotz des Fehlers bei jeder Datei ConfigurationAreaFile.flush()
aufgerufen. Die zuletzt aufgetretene IOException
wird zurückgegeben.public void close()
ConfigurationFileManager
ConfigurationFileManager.saveConfigurationAreaFiles()
und stellt einen Zustand her in dem das System wieder gestartet werden kann.close
in interface ConfigurationFileManager