1 11 package org.eclipse.core.internal.registry.osgi; 12 13 import java.io.File ; 14 import java.util.Map ; 15 import org.eclipse.core.internal.registry.RegistryMessages; 16 import org.eclipse.core.internal.runtime.RuntimeLog; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.Status; 19 import org.osgi.framework.BundleContext; 20 import org.osgi.framework.ServiceReference; 21 22 33 public class EquinoxRegistryStrategy extends RegistryStrategyOSGI { 34 35 public static final String PLUGIN_NAME = "org.eclipse.equinox.registry"; public static final String OPTION_DEBUG = PLUGIN_NAME + "/debug"; public static final String OPTION_DEBUG_EVENTS = PLUGIN_NAME + "/debug/events"; 39 private static boolean DEBUG_ECLIPSE_REGISTRY = OSGIUtils.getDefault().getBooleanDebugOption(OPTION_DEBUG, false); 40 private static boolean DEBUG_ECLIPSE_EVENTS = OSGIUtils.getDefault().getBooleanDebugOption(OPTION_DEBUG_EVENTS, false); 41 42 private boolean useJobs = true; 43 44 public EquinoxRegistryStrategy(File [] theStorageDir, boolean[] cacheReadOnly, Object key) { 45 super(theStorageDir, cacheReadOnly, key); 46 } 47 48 public boolean debug() { 49 return DEBUG_ECLIPSE_REGISTRY; 50 } 51 52 public boolean debugRegistryEvents() { 53 return DEBUG_ECLIPSE_EVENTS; 54 } 55 56 public final void log(IStatus status) { 57 RuntimeLog.log(status); 58 } 59 60 public long getContainerTimestamp() { 61 BundleContext context = Activator.getContext(); 62 if (context == null) { 63 RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.bundle_not_activated, null)); 64 return -1; 65 } 66 ServiceReference ref = context.getServiceReference("org.eclipse.osgi.service.resolver.PlatformAdmin"); if (ref == null) 69 return -1; 70 return EquinoxUtils.getContainerTimestamp(context, ref); 71 } 72 73 82 public final void scheduleChangeEvent(Object [] listeners, Map deltas, Object registry) { 83 if (useJobs) { 84 try { 85 new ExtensionEventDispatcherJob(listeners, deltas, registry).schedule(); 86 return; } catch (NoClassDefFoundError e) { 88 useJobs = false; } 90 } 91 super.scheduleChangeEvent(listeners, deltas, registry); 92 } 93 94 } 95 | Popular Tags |