Class Settings
- java.lang.Object
-
- net.sf.basedb.util.extensions.DefaultFilter
-
- net.sf.basedb.util.extensions.manager.Settings
-
- All Implemented Interfaces:
ExtensionsFilter
public class Settings extends DefaultFilter implements ExtensionsFilter
Class for keeping settings for the extensions system. Settings are kept in thesettings.xml
file in the plug-ins directory.Extension points and extensions can be disabled/enabled by
enableExtensionPoint(String, boolean)
andenableExtension(String, boolean)
.This class also implements the
ExtensionsFilter
interface, and can be used on theRegistry.useExtensions(net.sf.basedb.util.extensions.ClientContext, ExtensionsFilter, String...)
method. This means that disabling/enabling extensions and extension points will immediately be visible in the web interface. Sorting is delegated to theDefaultFilter
.- Version:
- 2.7
- Author:
- nicklas
- Last modified
- $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
-
-
Field Summary
Fields Modifier and Type Field Description private Presets.Preset
disabledExtensionPoints
private Presets.Preset
disabledExtensions
private File
file
private boolean
hasChanged
private Presets.Preset
ignoredFiles
private Presets.Preset
installedFiles
private ExtensionsManager
manager
private Presets
presets
private Presets.Preset
settings
-
Fields inherited from class net.sf.basedb.util.extensions.DefaultFilter
INDEX_COMPARATOR_CTX, INDEX_COMPARATOR_EXT
-
-
Constructor Summary
Constructors Constructor Description Settings(ExtensionsManager manager, File file)
Create a new Settings object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
enableExtension(String extensionId, boolean enable)
Enable/disable an extension.void
enableExtensionPoint(String extensionPointId, boolean enable)
Enable/disable an extension point.List<File>
getIgnoredFiles()
Get a list with all files that are ignored.List<File>
getInstalledFiles()
Get a list with all files that are installed.String
getSetting(String extensionId, String key)
Get a configuration setting for an extension.Presets.Preset
getSettingsForExtension(String extensionId)
Get a preset containing settings for the given extesion.boolean
isEnabled(Extension<?> extension)
Check if an extension is enabled or disabled.boolean
isEnabled(ExtensionPoint<?> extensionPoint)
Check if an extension point is enabled or disabled.boolean
isIgnoredFile(File file)
Check if the given file is marked as ignored.boolean
isInstalledFile(File file)
Check if the given file is marked as installed.void
save()
Save the settings to disk.void
setIgnoredFile(File file, boolean ignore)
Mark the given file as ignored/not ignored by the extension system.void
setInstalledFile(File file)
Mark the given file as installed by the extension system.void
setSetting(String extensionId, String key, String value)
Set a configuration setting for an extension.void
setUninstalledFile(File file)
Mark the given file as uninstalled.-
Methods inherited from class net.sf.basedb.util.extensions.DefaultFilter
sort
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.basedb.util.extensions.ExtensionsFilter
sort
-
-
-
-
Field Detail
-
file
private final File file
-
manager
private final ExtensionsManager manager
-
hasChanged
private boolean hasChanged
-
presets
private Presets presets
-
settings
private Presets.Preset settings
-
installedFiles
private Presets.Preset installedFiles
-
ignoredFiles
private Presets.Preset ignoredFiles
-
disabledExtensions
private Presets.Preset disabledExtensions
-
disabledExtensionPoints
private Presets.Preset disabledExtensionPoints
-
-
Constructor Detail
-
Settings
Settings(ExtensionsManager manager, File file)
Create a new Settings object. If the given file doesn't exists it will be created ifsave()
is called. The settings file must be an XML file that can be read by thePresets
class.- Parameters:
file
- The file to load/save settings in. If null, settings only are kept in memory and are lost when the server is shutdown.
-
-
Method Detail
-
isEnabled
public boolean isEnabled(ExtensionPoint<?> extensionPoint)
Description copied from interface:ExtensionsFilter
Check if an extension point is enabled or disabled.- Specified by:
isEnabled
in interfaceExtensionsFilter
- Overrides:
isEnabled
in classDefaultFilter
- Parameters:
extensionPoint
- The extension point to check- Returns:
- TRUE if the extension point is enabled, FALSE if it is disabled
-
isEnabled
public boolean isEnabled(Extension<?> extension)
Description copied from interface:ExtensionsFilter
Check if an extension is enabled or disabled.- Specified by:
isEnabled
in interfaceExtensionsFilter
- Overrides:
isEnabled
in classDefaultFilter
- Parameters:
extension
- The extension to check- Returns:
- TRUE if the extension is enabled, FALSE if it is disabled
-
enableExtension
public void enableExtension(String extensionId, boolean enable)
Enable/disable an extension.- Parameters:
extensionId
- The ID of the extension to enable/disableenable
- TRUE to enable the extension, FALSE to disable it
-
enableExtensionPoint
public void enableExtensionPoint(String extensionPointId, boolean enable)
Enable/disable an extension point.- Parameters:
extensionPointId
- The ID of the extension point to enable/disableenable
- TRUE to enable the extension point, FALSE to disable it
-
getSettingsForExtension
public Presets.Preset getSettingsForExtension(String extensionId)
Get a preset containing settings for the given extesion. If no settings exists, null is returned. Do not make modifications to the returned preset since the result is undefined. UsesetSetting(String, String, String)
to set values.- Since:
- 3.4
-
setSetting
public void setSetting(String extensionId, String key, String value)
Set a configuration setting for an extension. Do not forget tosave()
.- Parameters:
extensionId
- The ID of the extension to save a setting forkey
- The name of the settingvalue
- The value of the setting, use null to remove- Since:
- 3.4
-
getSetting
public String getSetting(String extensionId, String key)
Get a configuration setting for an extension.- Parameters:
extensionId
- The ID of the extension to save a setting forkey
- The name of the setting- Returns:
- The value or null if it doesn't exists
- Since:
- 3.4
-
isInstalledFile
public boolean isInstalledFile(File file)
Check if the given file is marked as installed.- Since:
- 3.0
-
setInstalledFile
public void setInstalledFile(File file)
Mark the given file as installed by the extension system.- Since:
- 3.0
-
setUninstalledFile
public void setUninstalledFile(File file)
Mark the given file as uninstalled.- Since:
- 3.0
-
getInstalledFiles
public List<File> getInstalledFiles()
Get a list with all files that are installed.- Since:
- 3.0
-
isIgnoredFile
public boolean isIgnoredFile(File file)
Check if the given file is marked as ignored.- Since:
- 3.10
-
setIgnoredFile
public void setIgnoredFile(File file, boolean ignore)
Mark the given file as ignored/not ignored by the extension system.- Since:
- 3.10
-
getIgnoredFiles
public List<File> getIgnoredFiles()
Get a list with all files that are ignored.- Since:
- 3.10
-
save
public void save()
Save the settings to disk. If the settings has not been changed the file is not written.
-
-