1 15 16 package org.eclipse.core.internal.net; 17 18 import java.util.Hashtable ; 19 20 import org.eclipse.core.net.proxy.IProxyService; 21 import org.eclipse.core.runtime.*; 22 import org.eclipse.core.runtime.preferences.InstanceScope; 23 import org.osgi.framework.BundleContext; 24 import org.osgi.framework.ServiceRegistration; 25 26 public class Activator extends Plugin { 27 30 public static final String ID = "org.eclipse.core.net"; 32 public static final String PT_AUTHENTICATOR = "authenticator"; 34 private static final String PROP_REGISTER_SERVICE = "org.eclipse.net.core.enableProxyService"; 36 39 private static Activator instance; 40 41 private ServiceRegistration proxyService; 42 43 46 public Activator() { 47 super(); 48 instance = this; 49 } 50 51 55 static public Activator getInstance() { 56 return instance; 57 } 58 59 public void start(BundleContext context) throws Exception { 60 super.start(context); 61 if (Boolean.valueOf(System.getProperty(PROP_REGISTER_SERVICE, "true")).booleanValue()) { ProxyManager proxyManager = (ProxyManager)ProxyManager.getProxyManager(); 63 proxyManager.initialize(); 64 proxyService = getBundle().getBundleContext().registerService(IProxyService.class.getName(), proxyManager, new Hashtable ()); 65 } 66 } 67 68 public void stop(BundleContext context) throws Exception { 69 if (proxyService != null) { 70 proxyService.unregister(); 71 proxyService = null; 72 } 73 super.stop(context); 74 } 75 76 public static void logError(String message, Throwable exc) { 77 IStatus status = new Status(IStatus.ERROR, ID, 0, message, exc); 78 79 getInstance().getLog().log(status); 80 } 81 82 public static void logInfo(String message, Throwable exc) { 83 IStatus status = new Status(IStatus.INFO, ID, 0, message, exc); 84 85 getInstance().getLog().log(status); 86 } 87 88 public org.osgi.service.prefs.Preferences getInstancePreferences() { 89 return new InstanceScope().getNode(getBundle().getSymbolicName()); 90 } 91 92 public static void log(int severity, String message, Throwable throwable) { 93 getInstance().getLog().log(new Status(severity, ID, 0, message, throwable)); 94 } 95 } 96 | Popular Tags |