Implementing a Service Provider to indicate a Skin as default Skin

This chapter describes the process of indicating a skin as the default skin to be used. For t

  1. Implement a Service Provider for org.eclipse.stardust.engine.core.spi.preferences.IStaticConfigurationProvider.
  2. In this provider class provide a default value for the skin. Refer to chapter Implementing a Static Configuration Provider for Default Preferences for details on implementing the provider class.
  3. Add this class to the custom plugin jar file created for the skin. For details on how to create plugin jars to provide custom skins, refer to section Creating a Plugin Jar to provide custom Portal Skins of chapter Extending the Infinity Portal Components.
  4. Create service factory org.eclipse.stardust.engine.core.spi.preferences.IStaticConfigurationProvider$Factory
  5. Add a folder services to the META-INF folder, where you put the service factory

Now this jar file can be imported in your Portal project as described in section Importing a Skin provided as Plugin Jar of chapter Creating and Using Custom Skins.

Example Implementation

The following example implementation shows a configuration that sets a previously designed skin named custom as default skin.

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.stardust.engine.core.spi.preferences.IStaticConfigurationProvider;

public class CustomSkinStaticConfigurationProvider
      implements IStaticConfigurationProvider, IStaticConfigurationProvider.Factory
{

   private static final IStaticConfigurationProvider INSTANCE = new CustomSkinStaticConfigurationProvider();

   public static final String M_PORTAL = "ipp-portal-common";

   public static final String V_PORTAL_CONFIG = "configuration";

   public static final String F_SKIN = "prefs.skin";

   public static final String PREF_ID = "preference";

   public static final String CUSTOM_SKIN = "custom";

   /**
    * Get the moduleId which the static preferences are provided for
    */
   public String getModuleId()
   {
      return M_PORTAL;
   }

   /**
    * lookup default preferences for the specified preferencesId.
    */
   public Map getPreferenceDefaults(String preferencesId)
   {

      Map preferencesDefault = new HashMap<String, String>();
      String prefKey = getModuleId() + "." + V_PORTAL_CONFIG + "." + F_SKIN;
      preferencesDefault.put(prefKey, CUSTOM_SKIN);
      return preferencesDefault;
   }

   /**
    * Get the preferenceIds for which the static configuration provider provides 
    * preferences for.
    */
   public List getPreferenceIds()
   {
      return Collections.singletonList(PREF_ID);
   }

   /**
    * 
    */
   public IStaticConfigurationProvider getProvider()
   {
      return INSTANCE;
   }

}

The plugin jar structure could look like the following:

CustomSkinStaticConfigurationProvider.class
META-INF/
   MANIFEST.MF
   custom
   services/
      org.eclipse.stardust.engine.core.spi.preferences.IStaticConfigurationProvider$Factory
   spring/
      plugin-project-context.xml
      plugin-projectUi-context.xml
   xhtml/
      public/
         skins/
            custom/
               images/
               custom.css
               login.css