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 Summary
Fields 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 Summary
Constructors Constructor Description SettingsAgent()
-
Method Summary
All 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
-
access
protected IInternalAccess access
The service provider.
-
settingsdir
protected java.io.File settingsdir
Directory used to save settings.
-
filename
protected java.lang.String filename
The properties filename.
-
props
protected Properties props
The current properties.
-
providers
protected java.util.Map<java.lang.String,IPropertiesProvider> providers
The registered properties provider (id->provider).
-
saveonexit
protected boolean saveonexit
Save settings on exit?.
-
readonly
protected boolean readonly
Do not save settings?.
-
-
Method Detail
-
startService
public IFuture<java.lang.Void> startService()
Start the service.- Returns:
- A future that is done when the service has completed starting.
-
shutdownService
public IFuture<java.lang.Void> shutdownService()
Shutdown the service.- Returns:
- A future that is done when the service has completed its shutdown.
-
registerPropertiesProvider
public 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 interfaceISettingsService- 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.
-
deregisterPropertiesProvider
public 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 interfaceISettingsService- Parameters:
id- A unique id to identify the properties (e.g. component or service name).- Returns:
- A future indicating when registration is finished.
-
setProperties
public 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 interfaceISettingsService- 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.
-
getProperties
public IFuture<Properties> getProperties(java.lang.String id)
Get the properties for a given id.- Specified by:
getPropertiesin interfaceISettingsService- Parameters:
id- A unique id to identify the properties (e.g. component or service name).- Returns:
- A future containing the properties (if any).
-
loadProperties
public IFuture<java.lang.Void> loadProperties()
Load the default platform properties.- Specified by:
loadPropertiesin interfaceISettingsService- Returns:
- A future indicating when properties have been loaded.
-
readOrCreateProperties
protected IFuture<Properties> readOrCreateProperties()
-
readPropertiesFromStore
protected IFuture<Properties> readPropertiesFromStore()
Reads and returns the stored Properties, usually from a file.- Returns:
Properties- Throws:
java.io.FileNotFoundExceptionjava.lang.Exceptionjava.io.IOException
-
saveProperties
public IFuture<java.lang.Void> saveProperties()
Save the platform properties to the default location.- Specified by:
savePropertiesin interfaceISettingsService- Returns:
- A future indicating when properties have been saved.
-
saveProperties
public 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.
-
setSaveOnExit
public IFuture<java.lang.Void> setSaveOnExit(boolean saveonexit)
Set the save on exit policy.- Specified by:
setSaveOnExitin interfaceISettingsService- Parameters:
saveonexit- The saveonexit flag.
-
writePropertiesToStore
protected IFuture<java.lang.Void> writePropertiesToStore(Properties props)
Writes the given properties into a Store, usually a file.- Throws:
java.io.FileNotFoundExceptionjava.lang.Exceptionjava.io.IOException
-
-