public void start(final BundleContext context) throws Exception { bundleContext = context; final ServiceReference ref = context.getServiceReference(PackageAdmin.class.getName()); packageAdmin = (PackageAdmin) context.getService(ref); context.addBundleListener(this); context.addFrameworkListener(this); loadHostComponents(registrar); if (null != frameworkBundlesUrl) { conditionallyExtractZipFile(frameworkBundlesUrl, frameworkBundlesDir); } installFrameworkBundles(); // unregister the optional instrumentation service instrumentationServiceReference.ifPresent(ServiceRegistration::unregister); instrumentationServiceReference = Optional.empty(); // register the instrumentation service if it's present, keeping aware that InstrumentRegistry might not be in the class loader final Optional instrumentRegistry = PluginSystemInstrumentation.instance().getInstrumentRegistry(); if (instrumentRegistry.isPresent()) { instrumentationServiceReference = Optional.of(context.registerService(PluginSystemInstrumentation.INSTRUMENT_REGISTRY_CLASS, instrumentRegistry.get(), null)); } else { instrumentationServiceReference = Optional.empty(); } }
private static Scanner buildZipScanner(final URL url, final File pluginPath) { // checkArgument used to preserve historical behaviour of throwing IllegalArgumentException checkArgument(null != url, "Bundled plugins url cannot be null"); Scanner scanner = null; // Legacy behaviour - treat file:// urls as per buildSourceScanner, but we don't // want the error or the empty scanner. final File file = FileUtils.toFile(url); if (null != file) { scanner = buildScannerCommon(file); } if (null == scanner) { // Not handled by file:// urls, so it's a zip url com.atlassian.plugin.util.FileUtils.conditionallyExtractZipFile(url, pluginPath); scanner = new DirectoryScanner(pluginPath); } return scanner; }