Skip Navigation

Creating a Notification Service

These step-by-step procedures show how to create access to INotificationService .

Before you begin, complete the following:

  • Add an Activator class to your plug-in using Eclipse.

  • On the Dependencies tab, add the following required dependencies:

  • com.sabre.edge.platform.core.common

  • com.sabre.edge.platform.optional.notifications

  • org.eclipse.ui

  • org.eclipse.core.runtime

After you add an Activator class, you are required to create access to INotificationService for all types of notifications. These steps show how.

  1. Using Eclipse, open Activator.java.

  2. Modify the Activator class to handle the new INotificationService service. After you make modifications to the code that is shown below, the service becomes accessible via the Activator.getDefault().getNotificationService() method.

    • Replace PLUGIN_ID with the ID of the plug-in project.

    • Replace PLUGIN_NAME with the name of the plug-in in the Activator.

Sample Java Code with Activator Class Modifications to Access INotificationService

package com.sabre.redapp.example.notifications;

import org.osgi.framework.BundleContext;
import com.sabre.edge.platform.core.common.plugin.base.AbstractBaseEdgePlugin;
import com.sabre.edge.platform.optional.notifications.INotificationService;

/**
 * The activator class controls the plug-in life cycle
 */
public class Activator extends AbstractEdgeBasePlugin {

  public static final String PLUGIN_ID = "com.sabre.redapp.example.notifications";

  private INotificationService notifService;

  private static Activator plugin;

  /**
   * The constructor
   */
  public Activator() {
  }

  /**
   * {@inheritDoc}
   */
  public void start(BundleContext context) throws Exception {
    super.start(context);

    plugin = this;
  }

  /**
   * {@inheritDoc}
   */
  public void stop(BundleContext context) throws Exception {
    plugin = null;

    super.stop(context);
  }

  /**
   * Returns the shared instance
   *
   * @return the shared instance
   */
  public static Activator getDefault() {
    return plugin;
  }

  /**
   * Returns Notification service.
   *
   * @return INotificationService service
   */
  public INotificationService getNotificationService() {
         return notifService;
  }

}
  1. Save your Java code.

Your Next Steps

Now that you are done providing access to INotificationService , complete the instructions to create the notification of your choice, and then add the behavior that you want:

After you have created a notification, you can add the following functionality: