Available: | This service is available in Confluence 5.1.5, Confluence 5.2, and later. |
Confluence provides a feature discovery service that you can use in your plugin. Let's say you've added a new module or feature to your plugin, and you want to let users know about it. In other words, you need a way of letting users discover the new features. The feature discovery service is provided by the Confluence Feature Discovery plugin, which is bundled in Confluence 5.1.5, Confluence 5.2 and later.
In brief:
Details are on the rest of this page.
The feature discovery service keeps track of features via a context (usually the plugin key) and a key (usually the module key).
The plugin automatically detects when plugin modules are enabled, using the plugin key as the context and the module key as the key. You do not have to register features that are backed by plugin modules.
Examples of situations where you need to register your new feature manually:
To register a feature, call one of the register()
methods of the feature service, providing the context and key. See the methods reference below. You could do this in a plugin upgrade task or any other place. Feature registration is an idempotent operation - if you try to register something that has already been registered, nothing happens.
To register a feature, call one of the unregister()
methods. See the methods reference below.
Add the following dependency in your plugin's pom.xml
:
1 2<dependency> <groupId>com.atlassian.confluence.plugins</groupId> <artifactId>confluence-feature-discovery-plugin</artifactId> <version>1.7</version> <scope>provided</scope> </dependency>
Add the component-import in your plugin's atlassian-plugin.xml
:
1 2<component-import key="featureDiscoveryService" interface="com.atlassian.confluence.plugins.featurediscovery.service.FeatureDiscoveryService"/>
Call isNew()
to see if a given feature is newly installed/enabled on this Confluence site, or call getNew()
to get a list of new features within a given set. See the methods reference below.
It is up to your plugin to let the Confluence users know about the new functionality. For example, you could add code to your plugin that highlights the new options in the Confluence user interface. This functionality is not part of the feature discovery service. See the example below.
Method signature - registering a feature or module | Description |
---|---|
| Call this method to register your plugin module or feature with the feature discovery service. Parameters:
|
|
Call this method to register your plugin module with the feature discovery service. Parameters:
|
| You can use this function to register features that are not backed by a plugin module. Parameters:
|
Method signature - unregistering a feature or module | Description |
| Call this method to de-register a given module or feature. |
| Call this method to de-register a given module or feature. |
| Call this method to de-register a given feature. |
Method signature - checking if a feature or module is new | Description |
| Call this method to query if a given plugin module is new. A module is considered new if it has been registered within the specified time period. Parameters:
Returns: |
| Call this method to query if a given feature or plugin module is new. A feature or module is considered new if it has been registered within the specified time period. Parameters:
Returns: |
Method signature - checking multiple features or modules for newness | Description |
| Call this method to find the new plugin modules within a given set. A module is considered new if it has been registered within the specified time period. Parameters:
Returns: A collection with just the new module complete keys found in the given input collection. |
| Call this method to find the new features or plugin modules within a given set. A feature or module is considered new if it has been registered within the specified time period. Parameters:
Returns: A collection of complete keys for just the new features or modules found in the given input collection. |
In the Confluence 'Create' dialog, you will notice a 'NEW' lozenge next to recenty-installed blueprints. This dialog is produced by the Confluence Create Content plugin, which uses the feature discovery service to detect new blueprints. In the Confluence Create Content plugin, the DefaultBlueprintWebItemService
issues the following call to the feature discovery service:
1 2featureDiscoveryService.getNew(blueprintsModuleCompleteKeys);
Screenshot: The 'New' lozenge next to newly-installed blueprints
The Feature Discovery plugin exposes a limited REST API.
HTTP Method: | GET |
URL format: |
Path variables and URL parameters:
|
Sample response: |
|
HTTP Method: | POST |
URL format: |
Path variables and URL parameters:
|
Body: | The post body must contain a JSON array. Sample body:
|
The feature discovery service listens for plugin module 'enable' events. On enabling of a module, if an entry does not already exist, the service stores the plugin key, the module key and the current time in an Active Objects table.
The service also does a full scan of all enabled plugin modules when Confluence starts up and whenever the Feature Discovery plugin is enabled or reinstalled. Items discovered during scans are considered to be installed when the system was installed, because the plugin does not have a date for them.
If your plugin module has a DarkFeatureEnabledCondition
on it, and that is the only condition, the plugin module is ignored. This means it will not be recognised as new until the condition is removed.
If you wish to use the dark feature functionality, ensure that the only condition on your module is a dark feature condition. If there is more than one condition, the module will be registered and its installation date will be set to the date the dark feature was installed This is mostly due to limitations in the interfaces for compound conditions.
Make sure your context
does not clash with an existing plugin module key. If there is a clash, only the first key is registered.
More things to know:
The feature discovery is at the level of a plugin module (not the whole plugin).
The Confluence system installation date can now be programmatically accessed using the getInstallationDate()
method on the SystemInformationService
's ConfluenceInfo
object. System content is used to estimate the date if it was not recorded when Confluence was installed.
1 2featureDiscoveryService.getNew(blueprintsModuleCompleteKeys);
Rate this page: