Skip Navigation

Creating Access to Agent Profile Service

Before you begin, you need the following:

Complete either of the following procedures:

Inheriting from the AbstractEdgeBasePlugin Class

In your Eclipse project, open the Dependencies tab. Add the com.sabre.edge.platform.core.common dependency to your plug-in. Modify your Activator class to extend com.sabre.edge.platform.core.common.AbstractEdgeBasePlugin. Retrieve the service by calling Activator.getDefault().getServiceReference(IAgentProfileService.class) outside your Activator class.

Retrieving Access to Agent Profile Service Directly

  1. In your Eclipse project, open the Dependencies tab. Add the com.sabre.edge.platform.core.sso dependency to your plug-in.

  2. Modify your Activator class in your plug-in to obtain a new IAgentProfileService service.

  3. Retrieve the service by calling Activator.getDefault().getAgentProfileService() outside your Activator class.

  4. To retrieve the service outside the Activator, do the following:

    • Add service(private IAgentProfileService agentProfileService)

    • Retrieve AgentProfileService in the start() method of Activator

    • Add the getAgentProfileService() method to retrieve the service.

The following code sample shows retrieving the service outside an Activator class.

package com.sabre.redapp.example.agentprofileservice;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import com.sabre.edge.platform.core.sso.base.IAgentProfileService;
import org.osgi.util.tracker.ServiceTracker;

/**
 * The activator class controls the plug-in life cycle
 */
public class Activator extends AbstractUIPlugin
{
    public static final String ID = "com.sabre.redapp.example.agentprofileservice";
    private static Activator plugin;
    private ServiceTracker agentProfileServiceTracker;

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

        agentProfileServiceTracker = new ServiceTracker(context, IAgentProfileService.class.getName(), null);
        agentProfileServiceTracker.open();
    }

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

    /**
     * Returns the shared instance
     *
     * @return the shared instance
     */

    public static Activator getDefault()
    {
        return plugin;
    }

    /**
     * Retrieves IAgentProfileService service
     * @return IAgentProfileService service
     */
    public IAgentProfileService getAgentProfileService()
    {
        return (IAgentProfileService) agentProfileServiceTracker.getService();
    }
}