/******************************************************************************* * Copyright (c) 2014, 2015 Wind River Systems, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.tcf.remote.ui.activator; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; /** * The activator class controls the plug-in life cycle */ public class UIPlugin extends AbstractUIPlugin { private static final String PLUGIN_ID = "org.eclipse.tcf.te.tcf.remote.ui"; //$NON-NLS-1$ // The shared instance private static UIPlugin plugin; /** * The constructor */ public UIPlugin() { } /** * Returns the shared instance * * @return the shared instance */ public static UIPlugin getDefault() { return plugin; } /** * Convenience method which returns the unique identifier of this plugin. */ public static String getUniqueIdentifier() { return PLUGIN_ID; } @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; } @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); } public static <T> T getService(Class<T> service) { if (plugin == null) return null; BundleContext context = plugin.getBundle().getBundleContext(); ServiceReference<T> ref = context.getServiceReference(service); return ref != null ? context.getService(ref) : null; } }