Class Settings
java.lang.Object
net.sf.basedb.util.extensions.DefaultFilter
net.sf.basedb.util.extensions.manager.Settings
- All Implemented Interfaces:
ExtensionsFilter
Class for keeping settings for the extensions system. Settings
are kept in the
settings.xml
file in the plug-ins
directory.
Extension points and extensions can be disabled/enabled by
enableExtensionPoint(String, boolean)
and
enableExtension(String, boolean)
.
This class also implements the ExtensionsFilter
interface, and can be used on the
Registry.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 the DefaultFilter
.
- Version:
- 2.7
- Author:
- nicklas
- Last modified
- $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate Presets.Preset
private Presets.Preset
private final File
private boolean
private Presets.Preset
private Presets.Preset
private final ExtensionsManager
private final String
private Presets
private Presets.Preset
private final String
Fields inherited from class net.sf.basedb.util.extensions.DefaultFilter
INDEX_COMPARATOR_CTX, INDEX_COMPARATOR_EXT
-
Constructor Summary
ConstructorDescriptionSettings
(ExtensionsManager manager, File file) Create a new Settings object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
enableExtension
(String extensionId, boolean enable) Enable/disable an extension.void
enableExtensionPoint
(String extensionPointId, boolean enable) Enable/disable an extension point.private Presets.Preset
fixPaths
(Presets.Preset preset) Fix paths in older config files.Get a list with all files that are ignored.Get a list with all files that are installed.getSetting
(String extensionId, String key) Get a configuration setting for an extension.getSettingsForExtension
(String extensionId) Get a preset containing settings for the given extesion.boolean
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.private File
A file is typically stored under the absolute path, but if it matches the plug-ins directory we replace it with {plugins.dir}.private String
A file is typically stored under the absolute path, but if it matches the plug-ins directory we replace it with {plugins.dir}.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 Details
-
file
-
manager
-
pluginsDir
-
userFilesDir
-
hasChanged
private boolean hasChanged -
presets
-
settings
-
installedFiles
-
ignoredFiles
-
disabledExtensions
-
disabledExtensionPoints
-
-
Constructor Details
-
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 Details
-
isEnabled
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
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
Enable/disable an extension.- Parameters:
extensionId
- The ID of the extension to enable/disableenable
- TRUE to enable the extension, FALSE to disable it
-
enableExtensionPoint
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
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
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
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
-
toKey
A file is typically stored under the absolute path, but if it matches the plug-ins directory we replace it with {plugins.dir}.- Since:
- 3.19.6
-
toFile
A file is typically stored under the absolute path, but if it matches the plug-ins directory we replace it with {plugins.dir}.- Since:
- 3.19.6
-
fixPaths
Fix paths in older config files. This code can be removed some time in the future when we are sure that everyone has upgraded. Eg. in BASE 3.21 since we must allow upgrades between BASE 3.19.x and BASE 3.20.x. -
isInstalledFile
Check if the given file is marked as installed.- Since:
- 3.0
-
setInstalledFile
Mark the given file as installed by the extension system.- Since:
- 3.0
-
setUninstalledFile
Mark the given file as uninstalled.- Since:
- 3.0
-
getInstalledFiles
Get a list with all files that are installed.- Since:
- 3.0
-
isIgnoredFile
Check if the given file is marked as ignored.- Since:
- 3.10
-
setIgnoredFile
Mark the given file as ignored/not ignored by the extension system.- Since:
- 3.10
-
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.
-