Implementing a Static Configuration Provider for Default Preferences

The Preference Store uses the default scope (PreferenceScope.DEFAULT) to retrieve static preferences from an SPI. Default scoped preferences are looked up on the API before falling back to its own SPI.

The following interfaces are available to be implemented to provide default preferences for one moduleId and multiple preferenceIds scoped by the moduleId:

Using the IStaticConfigurationProvider

Create your own implementations for the interface depending on where the default preferences should be available. For example, the Infinity Process Platform Portal first looks up default preferences on the engine and falls back to the own SPI lookup, if no preferences are found in the engine.

Refer to chapter Configuring SPI Implementations per Tenant for details on how to configure custom Service Provider Interface implementations in general.

  1. The following file needs to be created depending on the SPI to use:
  2. Add the fully qualified class name of your implementations to the file named as the interface which the class implements.

When a call on PreferenceScope.DEFAULT is performed, all preferences provided by the SPI's implementors will be loaded into the preferences cache. Note that a new initialization for the SPI will only take place after the preference store caches are flushed.

Find the code of the interface to be implemented in the public Javadoc of the according provider classes mentioned above or here:

/**
 * An implementor of this interface can provide default preferences for one moduleId and
 * multiple preferenceIds scoped by the moduleId.<br>
 * <br>
 * To publish an implementor to the engine a file named by the interface's factory has to be created in
 * the '/META-INF/services' folder of the jar.<br>
 * In this case: org.eclipse.stardust.engine.core.spi.preferences.IStaticConfigurationProvider$Factory<br>
 * This file needs to contain the qualified class name of the implementor of the factory interface.<br>
 * <br>
 * This pattern follows the concept of the JDK6 ServiceLoader
 *
 */
public interface IStaticConfigurationProvider
{

   /**
    * @return the moduleId which the static preferences are provided for.
    */
   String getModuleId();

   /**
    * @return the preferenceIds for which the static configuration provider provides preferences for.
    */
   List/*<String>*/ getPreferenceIds();

   /**
    * @param preferencesId the preferencesId to lookup default preferences for.
    * @return a map containing default preferences for the specified preferencesId.
    */
   Map/*<String, Serializable>*/ getPreferenceDefaults(String preferencesId);

   /**
    * The factory interface for IStaticConfigurationProvider
    */
   interface Factory
   {
      IStaticConfigurationProvider getProvider();
   }

}