1 11 12 package org.eclipse.update.configurator; 13 14 import java.io.*; 15 import java.net.*; 16 17 import org.eclipse.update.internal.configurator.ConfigurationActivator; 18 import org.eclipse.update.internal.configurator.Utils; 19 import org.osgi.framework.*; 20 21 32 public class ConfiguratorUtils { 33 40 public static IPlatformConfiguration getCurrentPlatformConfiguration() { 41 BundleContext context = ConfigurationActivator.getBundleContext(); 43 ServiceReference configFactorySR = context.getServiceReference(IPlatformConfigurationFactory.class.getName()); 44 if (configFactorySR == null) 45 throw new IllegalStateException (); 46 IPlatformConfigurationFactory configFactory = (IPlatformConfigurationFactory) context.getService(configFactorySR); 47 if (configFactory == null) 48 throw new IllegalStateException (); 49 IPlatformConfiguration currentConfig = configFactory.getCurrentPlatformConfiguration(); 51 context.ungetService(configFactorySR); 52 return currentConfig; 53 } 54 55 63 public static IPlatformConfiguration getPlatformConfiguration(URL url) throws IOException { 64 BundleContext context = ConfigurationActivator.getBundleContext(); 66 ServiceReference configFactorySR = context.getServiceReference(IPlatformConfigurationFactory.class.getName()); 67 if (configFactorySR == null) 68 throw new IllegalStateException (); 69 IPlatformConfigurationFactory configFactory = (IPlatformConfigurationFactory) context.getService(configFactorySR); 70 if (configFactory == null) 71 throw new IllegalStateException (); 72 IPlatformConfiguration config = configFactory.getPlatformConfiguration(url); 74 context.ungetService(configFactorySR); 75 return config; 76 } 77 78 81 public static URL getInstallURL() { 82 return Utils.getInstallURL(); 83 } 84 } 85 | Popular Tags |