blob: 9d2766a7574198f9434f463d4628e388cac4122c [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009 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.ptp.services.core;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;
/**
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the RDT team.
*
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.ptp.services.core"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
// If the plugin fails to activate because of an exception in the ServiceModelManager
// then we need to know what happened, so log it.
try {
ServiceModelManager.getInstance().loadModelConfiguration();
} catch (Exception e) {
log(e);
}
ProjectDeletionListener.startListening();
}
@Override
public void stop(BundleContext context) throws Exception {
try {
ProjectDeletionListener.stopListening();
try {
ServiceModelManager.getInstance().saveModelConfiguration();
} catch (Exception e) {
log(e);
}
}
finally {
plugin = null;
super.stop(context);
}
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
public void log(Throwable e) {
log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Error", e)); //$NON-NLS-1$
}
public void log(IStatus status) {
getLog().log(status);
}
public void logErrorMessage(String message) {
log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, null));
}
}