2.17.2: 2011-06-17

net.sf.basedb.clients.web.extensions
Class Settings

java.lang.Object
  extended by net.sf.basedb.util.extensions.DefaultFilter
      extended by net.sf.basedb.clients.web.extensions.Settings
All Implemented Interfaces:
ExtensionsFilter

public class Settings
extends DefaultFilter
implements ExtensionsFilter

Class for keeping settings for the extensions system. Settings are kept in the file WEB-INF/extensions/settings.xml.

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
private static String AUTO_INSTALL
           
private  ExtensionsDirectory directory
           
private  Presets.Preset disabledExtensionPoints
           
private  Presets.Preset disabledExtensions
           
private  File file
           
private  boolean hasChanged
           
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
Settings(ExtensionsDirectory directory, File file)
          Create a new Settings object.
 
Method Summary
 void enableExtension(String extensionId, boolean enable)
          Enable/disable an extension.
 void enableExtensionPoint(String extensionPointId, boolean enable)
          Enable/disable an extension point.
 int getAutoInstall()
          Get the interval, in seconds, between automatic checks for new/modified/deleted extensions.
 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.
 void save()
          Save the settings to disk.
 void setAutoInstall(int autoInstall)
          Change the interval, in seconds, between automatic checks for new/modified/deleted extensions.
 
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

AUTO_INSTALL

private static final String AUTO_INSTALL
See Also:
Constant Field Values

directory

private final ExtensionsDirectory directory

file

private final File file

hasChanged

private boolean hasChanged

presets

private Presets presets

settings

private Presets.Preset settings

disabledExtensions

private Presets.Preset disabledExtensions

disabledExtensionPoints

private Presets.Preset disabledExtensionPoints
Constructor Detail

Settings

public Settings(ExtensionsDirectory directory,
                File file)
Create a new Settings object. If the given file doesn't exists it will be created if save() is called. The settings file must be an XML file that can be read by the Presets class.

Parameters:
file - The file to load/save settings in
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 interface ExtensionsFilter
Overrides:
isEnabled in class DefaultFilter
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 interface ExtensionsFilter
Overrides:
isEnabled in class DefaultFilter
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/disable
enable - 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/disable
enable - TRUE to enable the extension point, FALSE to disable it

getAutoInstall

public int getAutoInstall()
Get the interval, in seconds, between automatic checks for new/modified/deleted extensions.

Returns:
The interval in seconds or 0 if the auto-install feature is disabled (the default)

setAutoInstall

public void setAutoInstall(int autoInstall)
Change the interval, in seconds, between automatic checks for new/modified/deleted extensions.

Parameters:
autoInstall - The interval in seconds, or 0 to disable the feature

save

public void save()
Save the settings to disk. If the settings has not been changed the file is not written.


2.17.2: 2011-06-17