Package jadex.platform.service.settings
Class SettingsAgent
- java.lang.Object
- 
- jadex.platform.service.settings.SettingsAgent
 
- 
- All Implemented Interfaces:
- ISettingsService
 
 public class SettingsAgent extends java.lang.Object implements ISettingsService Agent that provides the settings service.
- 
- 
Field SummaryFields Modifier and Type Field Description protected IInternalAccessaccessThe service provider.protected java.lang.StringfilenameThe properties filename.protected PropertiespropsThe current properties.protected java.util.Map<java.lang.String,IPropertiesProvider>providersThe registered properties provider (id->provider).protected booleanreadonlyDo not save settings?.protected booleansaveonexitSave settings on exit?.protected java.io.FilesettingsdirDirectory used to save settings.
 - 
Constructor SummaryConstructors Constructor Description SettingsAgent()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.Void>deregisterPropertiesProvider(java.lang.String id)Deregister a property provider.IFuture<Properties>getProperties(java.lang.String id)Get the properties for a given id.IFuture<java.lang.Void>loadProperties()Load the default platform properties.protected IFuture<Properties>readOrCreateProperties()protected IFuture<Properties>readPropertiesFromStore()Reads and returns the stored Properties, usually from a file.IFuture<java.lang.Void>registerPropertiesProvider(java.lang.String id, IPropertiesProvider provider)Register a property provider.IFuture<java.lang.Void>saveProperties()Save the platform properties to the default location.IFuture<java.lang.Void>saveProperties(boolean shutdown)Save the platform properties to the default location.IFuture<java.lang.Void>setProperties(java.lang.String id, Properties props)Set the properties for a given id.IFuture<java.lang.Void>setSaveOnExit(boolean saveonexit)Set the save on exit policy.IFuture<java.lang.Void>shutdownService()Shutdown the service.IFuture<java.lang.Void>startService()Start the service.protected IFuture<java.lang.Void>writePropertiesToStore(Properties props)Writes the given properties into a Store, usually a file.
 
- 
- 
- 
Field Detail- 
accessprotected IInternalAccess access The service provider.
 - 
settingsdirprotected java.io.File settingsdir Directory used to save settings.
 - 
filenameprotected java.lang.String filename The properties filename.
 - 
propsprotected Properties props The current properties.
 - 
providersprotected java.util.Map<java.lang.String,IPropertiesProvider> providers The registered properties provider (id->provider).
 - 
saveonexitprotected boolean saveonexit Save settings on exit?.
 - 
readonlyprotected boolean readonly Do not save settings?.
 
- 
 - 
Method Detail- 
startServicepublic IFuture<java.lang.Void> startService() Start the service.- Returns:
- A future that is done when the service has completed starting.
 
 - 
shutdownServicepublic IFuture<java.lang.Void> shutdownService() Shutdown the service.- Returns:
- A future that is done when the service has completed its shutdown.
 
 - 
registerPropertiesProviderpublic IFuture<java.lang.Void> registerPropertiesProvider(java.lang.String id, IPropertiesProvider provider) Register a property provider. Settings of registered property providers will be automatically saved and restored, when properties are loaded.- Specified by:
- registerPropertiesProviderin interface- ISettingsService
- Parameters:
- id- A unique id to identify the properties (e.g. component or service name).
- provider- The properties provider.
- Returns:
- A future indicating when registration is finished.
 
 - 
deregisterPropertiesProviderpublic IFuture<java.lang.Void> deregisterPropertiesProvider(java.lang.String id) Deregister a property provider. Settings of a deregistered property provider will be saved before the property provider is removed.- Specified by:
- deregisterPropertiesProviderin interface- ISettingsService
- Parameters:
- id- A unique id to identify the properties (e.g. component or service name).
- Returns:
- A future indicating when registration is finished.
 
 - 
setPropertiespublic IFuture<java.lang.Void> setProperties(java.lang.String id, Properties props) Set the properties for a given id. Overwrites existing settings (if any).- Specified by:
- setPropertiesin interface- ISettingsService
- Parameters:
- id- A unique id to identify the properties (e.g. component or service name).
- properties- The properties to set.
- save- Save platform properties after setting.
- Returns:
- A future indicating when properties have been set.
 
 - 
getPropertiespublic IFuture<Properties> getProperties(java.lang.String id) Get the properties for a given id.- Specified by:
- getPropertiesin interface- ISettingsService
- Parameters:
- id- A unique id to identify the properties (e.g. component or service name).
- Returns:
- A future containing the properties (if any).
 
 - 
loadPropertiespublic IFuture<java.lang.Void> loadProperties() Load the default platform properties.- Specified by:
- loadPropertiesin interface- ISettingsService
- Returns:
- A future indicating when properties have been loaded.
 
 - 
readOrCreatePropertiesprotected IFuture<Properties> readOrCreateProperties() 
 - 
readPropertiesFromStoreprotected IFuture<Properties> readPropertiesFromStore() Reads and returns the stored Properties, usually from a file.- Returns:
- Properties
- Throws:
- java.io.FileNotFoundException
- java.lang.Exception
- java.io.IOException
 
 - 
savePropertiespublic IFuture<java.lang.Void> saveProperties() Save the platform properties to the default location.- Specified by:
- savePropertiesin interface- ISettingsService
- Returns:
- A future indicating when properties have been saved.
 
 - 
savePropertiespublic IFuture<java.lang.Void> saveProperties(boolean shutdown) Save the platform properties to the default location.- Parameters:
- shutdown- Flag indicating if called during shutdown.
- Returns:
- A future indicating when properties have been saved.
 
 - 
setSaveOnExitpublic IFuture<java.lang.Void> setSaveOnExit(boolean saveonexit) Set the save on exit policy.- Specified by:
- setSaveOnExitin interface- ISettingsService
- Parameters:
- saveonexit- The saveonexit flag.
 
 - 
writePropertiesToStoreprotected IFuture<java.lang.Void> writePropertiesToStore(Properties props) Writes the given properties into a Store, usually a file.- Throws:
- java.io.FileNotFoundException
- java.lang.Exception
- java.io.IOException
 
 
- 
 
-