/*******************************************************************************
 * Copyright (c) 2001, 2008 IBM Corporation and others.
 * 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.soda.sat.eclipse.dependency.observer.internal.bundle;

import org.eclipse.soda.sat.core.framework.BaseBundleActivator;
import org.eclipse.soda.sat.core.service.BundleDependencyService;
import org.eclipse.soda.sat.eclipse.dependency.observer.internal.Observer;

public class Activator extends BaseBundleActivator {
	private Observer model;
	
	protected void activate() {
		Observer model = new Observer();
		setModel(model);
		BundleDependencyService bundleDependencyService = getBundleDependencyService();
		model.bind(bundleDependencyService);
	}

	protected void deactivate() {
		Observer model = getModel();
		model.unbind();
		setModel(null);
	}
	
	private BundleDependencyService getBundleDependencyService() {
		return (BundleDependencyService) getImportedService(BundleDependencyService.SERVICE_NAME);
	}

	protected String[] getImportedServiceNames() {
		return new String[] { 
			BundleDependencyService.SERVICE_NAME
		};
	}

	private Observer getModel() {
		return model;
	}

	private void setModel(Observer model) {
		this.model = model;
	}
}