package org.cishell.reference.gui.datamanager;
import org.cishell.app.service.datamanager.DataManagerService;
import org.cishell.framework.CIShellContext;
import org.cishell.framework.LocalCIShellContext;
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
public class Activator extends AbstractUIPlugin {
public static final String PLUGIN_ID = "org.cishell.reference.gui.datamanager";
public static BundleContext context;
private static Activator plugin;
plugin = this;
}
public void start(BundleContext context)
throws Exception {
super.start(context);
Activator.context = context;
}
public void stop(BundleContext context)
throws Exception {
plugin = null;
super.stop(context);
}
return plugin;
}
ServiceReference serviceReference = context.getServiceReference(DataManagerService.class.getName());
DataManagerService manager = null;
if (serviceReference != null) {
manager = (DataManagerService) context.getService(serviceReference);
}
return manager;
}
ServiceReference serviceReference = context.getServiceReference(DataManagerService.class.getName());
LogService log = null;
if (serviceReference != null) {
log = (LogService) context.getService(
context.getServiceReference(LogService.class.getName()));
}
return log;
}
protected static AlgorithmFactory
getService(String service) {
ServiceReference[] refs;
try {
refs = context.getServiceReferences(AlgorithmFactory.class.getName(),
"(&("+Constants.SERVICE_PID+"="+service+"))");
if (refs != null && refs.length > 0) {
return (AlgorithmFactory) context.getService(refs[0]);
} else {
return null;
}
} catch (InvalidSyntaxException e) {
e.printStackTrace();
return null;
}
}
return context;
}
return new LocalCIShellContext(context);
}
}