| /******************************************************************************* |
| * Copyright (c) 2008 Versant Corp. |
| * 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 Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation |
| ******************************************************************************/ |
| |
| package org.eclipse.ecf.internal.remoteservices.ui; |
| |
| import org.eclipse.ecf.core.IContainerManager; |
| import org.eclipse.ui.plugin.AbstractUIPlugin; |
| import org.osgi.framework.BundleContext; |
| import org.osgi.util.tracker.ServiceTracker; |
| |
| public class Activator extends AbstractUIPlugin { |
| |
| private volatile ServiceTracker containerManagerTracker; |
| // The shared instance |
| private volatile static Activator plugin; |
| |
| /** |
| * The constructor |
| */ |
| public Activator() { |
| plugin = this; |
| } |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see |
| * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext |
| * ) |
| */ |
| public void stop(BundleContext context) throws Exception { |
| plugin = null; |
| if (containerManagerTracker != null) { |
| containerManagerTracker.close(); |
| containerManagerTracker = null; |
| } |
| super.stop(context); |
| } |
| |
| /** |
| * Returns the shared instance |
| * |
| * @return the shared instance |
| */ |
| public static Activator getDefault() { |
| return plugin; |
| } |
| |
| public IContainerManager getContainerManager() { |
| BundleContext context = getBundle().getBundleContext(); |
| if (containerManagerTracker == null) { |
| containerManagerTracker = new ServiceTracker(context, |
| IContainerManager.class.getName(), null); |
| containerManagerTracker.open(); |
| } |
| return (IContainerManager) containerManagerTracker.getService(); |
| } |
| } |