Search in sources :

Example 1 with IMarketplaceServiceLocator

use of org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator in project epp.mpc by eclipse.

the class DefaultCatalogService method registerDynamicFavoritesService.

private void registerDynamicFavoritesService(String catalogUrl, String favoritesApiServer, String favoritesApiKey) {
    IMarketplaceServiceLocator marketplaceServiceLocator = ServiceHelper.getMarketplaceServiceLocator();
    IUserFavoritesService favoritesService = marketplaceServiceLocator.getFavoritesService(catalogUrl);
    if (favoritesService != null) {
        return;
    }
    ((ServiceLocator) marketplaceServiceLocator).registerFavoritesService(catalogUrl, favoritesApiServer, favoritesApiKey);
}
Also used : IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator) ServiceLocator(org.eclipse.epp.internal.mpc.core.ServiceLocator) IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService) IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator)

Example 2 with IMarketplaceServiceLocator

use of org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator in project epp.mpc by eclipse.

the class ServiceLocator method getInstance.

/**
 * @deprecated acquire the registered {@link IMarketplaceServiceLocator} OSGi service instead.
 */
@Deprecated
public static synchronized ServiceLocator getInstance() {
    if (instance != null) {
        return instance;
    }
    IMarketplaceServiceLocator locator = getCompatibilityLocator();
    if (locator != null && locator instanceof ServiceLocator) {
        // don't remember service instance, it might get deregistered
        return (ServiceLocator) locator;
    }
    // remember new default instance
    instance = new ServiceLocator();
    return instance;
}
Also used : IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator) IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator)

Example 3 with IMarketplaceServiceLocator

use of org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator in project epp.mpc by eclipse.

the class ServiceLocator method getCompatibilityLocator.

/**
 * This method is not intended to be referenced by clients. Acquire the registered
 * {@link IMarketplaceServiceLocator} OSGi service instead.
 * <p>
 * This method provides legacy compatibility with the ServiceLocator singleton for internal use only. It will return
 * the ServiceLocator singleton if it has been set explicitly. Otherwise it will return the registered default
 * {@link IMarketplaceServiceLocator} OSGi service.
 *
 * @noreference This method is not intended to be referenced by clients.
 */
public static synchronized IMarketplaceServiceLocator getCompatibilityLocator() {
    if (instance != null) {
        return instance;
    }
    IMarketplaceServiceLocator locator = ServiceHelper.getMarketplaceServiceLocator();
    if (locator == null) {
        // remember new default instance
        instance = new ServiceLocator();
        locator = instance;
    }
    return locator;
}
Also used : IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator) IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator)

Example 4 with IMarketplaceServiceLocator

use of org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator in project epp.mpc by eclipse.

the class DiscoverNatureSupportJob method run.

@Override
protected IStatus run(IProgressMonitor monitor) {
    BundleContext bundleContext = MarketplaceClientUiPlugin.getBundleContext();
    ServiceReference<IMarketplaceServiceLocator> locatorReference = bundleContext.getServiceReference(IMarketplaceServiceLocator.class);
    IMarketplaceServiceLocator locator = bundleContext.getService(locatorReference);
    IMarketplaceService marketplaceService = locator.getDefaultMarketplaceService();
    // $NON-NLS-1$]
    String fileExtensionTag = "nature_" + natureId;
    try {
        ISearchResult searchResult = marketplaceService.tagged(fileExtensionTag, monitor);
        nodes = searchResult.getNodes();
    } catch (CoreException ex) {
        IStatus status = new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.LookupByNatureJob_discoveryFailed, natureId), ex);
        MarketplaceClientUi.getLog().log(status);
        // Do not return this status as it would show an error
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ISearchResult(org.eclipse.epp.mpc.core.model.ISearchResult) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService) IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator) BundleContext(org.osgi.framework.BundleContext)

Example 5 with IMarketplaceServiceLocator

use of org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator in project epp.mpc by eclipse.

the class DiscoverFileSupportJob method run.

@Override
protected IStatus run(IProgressMonitor monitor) {
    BundleContext bundleContext = MarketplaceClientUiPlugin.getBundleContext();
    ServiceReference<IMarketplaceServiceLocator> locatorReference = bundleContext.getServiceReference(IMarketplaceServiceLocator.class);
    IMarketplaceServiceLocator locator = bundleContext.getService(locatorReference);
    IMarketplaceService marketplaceService = locator.getDefaultMarketplaceService();
    try {
        return run(marketplaceService, monitor);
    } finally {
        bundleContext.ungetService(locatorReference);
    }
}
Also used : IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService) IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator) BundleContext(org.osgi.framework.BundleContext)

Aggregations

IMarketplaceServiceLocator (org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator)5 IMarketplaceService (org.eclipse.epp.mpc.core.service.IMarketplaceService)2 BundleContext (org.osgi.framework.BundleContext)2 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ServiceLocator (org.eclipse.epp.internal.mpc.core.ServiceLocator)1 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)1 IUserFavoritesService (org.eclipse.epp.mpc.core.service.IUserFavoritesService)1