1 11 package org.eclipse.core.internal.registry.osgi; 12 13 import org.eclipse.osgi.service.environment.EnvironmentInfo; 14 import org.eclipse.osgi.service.resolver.PlatformAdmin; 15 import org.osgi.framework.*; 16 17 26 public class EquinoxUtils { 27 28 31 public static String [] getCommandLine(BundleContext context, ServiceReference ref) { 32 if (ref == null) 33 return null; 34 try { 35 EnvironmentInfo environmentInfo = (EnvironmentInfo) context.getService(ref); 36 return environmentInfo == null ? null : environmentInfo.getNonFrameworkArgs(); 37 } finally { 38 context.ungetService(ref); 39 } 40 } 41 42 45 public static long getContainerTimestamp(BundleContext context, ServiceReference ref) { 46 if (ref == null) 47 return -1; 48 try { 49 PlatformAdmin admin = (PlatformAdmin) context.getService(ref); 50 return admin == null ? -1 : admin.getState(false).getTimeStamp(); 51 } finally { 52 context.ungetService(ref); 53 } 54 } 55 56 public static ServiceRegistration registerCommandProvider(BundleContext context) { 57 try { 59 return context.registerService("org.eclipse.osgi.framework.console.CommandProvider", new RegistryCommandProvider(), null); } catch (NoClassDefFoundError noClass) { 64 } 66 return null; 67 } 68 } 69 | Popular Tags |