Storing Plugin Settings for FishEye
This tutorial demonstrates how to use SAL (Shared Access Layer) to let your plugin store its configuration settings.SAL offers a product independent way to store and retrieve settings.
Configuring your Plugin
When you are developing against FishEye/Crucible 2.1.x, the SAL library is already configured as a maven dependency, which means you won't need to configure anything when you use an IDE with maven integration.
Prior to FishEye/Crucibe 2.1, the SAL library did not come as a pre-configured maven dependency and you will need to manually add it to your
Next thing to do is to import the SAL service we are going to use by declaring it in our
atlassian-plugin.xml file. SAL services that are not explicitly declared will not be available:
Data Storage and Retrieval
With SAL configured, you can now get FishEye/Crucible to inject the
com.atlassian.sal.api.pluginsettings.PluginSettingsFactory into your plugin modules. This factory gives access to plugin settings.
In FishEye/Crucible, plugin settings are linked to repositories. This allows plugins to use different settings per repository. Per-repository settings are accessed through the
PluginSettingsFactory.createSettingsForKey(String repoKey) method.
In addition to the per-repository settings there is a global settings pool where your plugin can store settings that are not repository dependent. This is used by the example below:
PluginSettings service supports the following value types:
java.lang.String– stored as-is
toString()on the list items
toString()on both the keys and values in the Map
Properties.store()to let the
Propertiesobject serialize itself
PluginSettings mechanism is suitable for storing simple string-based key/value pairs, but should generally not be used to store large amounts of data.
Plugin configuration properties are not isolated from other plugins, but all share the same storage area. As a result, your plugin settings could be retrieved by other plugins if they knew which keys you are using. Consequently, you must be careful not to accidentally overwrite other plugins' settings by using the same property keys. Instead, always prefix your configuration keys with a unique string. Your plugin's unique key string makes a good prefix.