public @Override void bundleChanged(BundleEvent event) { Bundle bundle = event.getBundle(); switch (event.getType()) { case BundleEvent.STARTED: // System.err.println("started " + bundle.getSymbolicName()); Dictionary<?,?> headers = bundle.getHeaders(); load(queue.offer(bundle, provides(headers), requires(headers), needs(headers))); break; case BundleEvent.STOPPED: // System.err.println("stopped " + bundle.getSymbolicName()); if (framework.getState() == Bundle.STOPPING) { // System.err.println("fwork stopping during " + bundle.getSymbolicName()); // ActiveQueue.stop(); } else { unload(queue.retract(bundle)); } break; } }
/** * create a new bundle object from InputStream. This is used when a new bundle is installed. * * @param location the bundle location. * @param stream the input stream. * @throws BundleException if something goes wrong. * @throws IOException */ BundleImpl(final File bundleDir, final String location, final InputStream stream, final File file, String unique_tag, boolean installForCurrentVersion, long dexPatchVersion) throws BundleException, IOException{ this.location = location; this.bundleDir = bundleDir; if(installForCurrentVersion) { Framework.notifyBundleListeners(BundleEvent.BEFORE_INSTALL, this); } if (stream != null) { this.archive = new BundleArchive(location,bundleDir, stream,unique_tag, dexPatchVersion); } else if (file != null) { this.archive = new BundleArchive(location,bundleDir, file,unique_tag, dexPatchVersion); } this.state = INSTALLED; if (installForCurrentVersion) { resolveBundle(); Framework.bundles.put(location, this); // notify the listeners Framework.notifyBundleListeners(BundleEvent.INSTALLED, this); } }
/** * the actual starting happens here. * * @throws BundleException if the bundle cannot be resolved or the Activator throws an exception. */ public synchronized void startBundle() { if (state == UNINSTALLED) { throw new IllegalStateException("Cannot start uninstalled bundle " + toString()); } if (state == ACTIVE) { return; } if (state == INSTALLED) { throw new RuntimeException("can not start bundle which is not resolved"); } state = STARTING; Framework.notifyBundleListeners(BundleEvent.BEFORE_STARTED, this); Framework.notifyBundleListeners(BundleEvent.STARTED, this); if (Framework.DEBUG_BUNDLES) { Log.i("Framework","Bundle " + toString() + " started."); } }
/** * uninstall the bundle. * * @throws BundleException if bundle is already uninstalled * @see org.osgi.framework.Bundle#uninstall() * @category Bundle */ public synchronized void uninstall() throws BundleException { if (state == UNINSTALLED) { throw new IllegalStateException("Bundle " + toString() + " is already uninstalled."); } if (state == ACTIVE) { try { stop(); } catch (Throwable t) { Framework.notifyFrameworkListeners(FrameworkEvent.ERROR, this, t); } } state = UNINSTALLED; classloader.cleanup(true); classloader = null; Framework.bundles.remove(getLocation()); Framework.notifyBundleListeners(BundleEvent.UNINSTALLED, this); }
/** * notify all bundle listeners. * * @param state the new state. * @param bundle the bundle. */ static void notifyBundleListeners(final int state, final Bundle bundle) { if (syncBundleListeners.isEmpty() && bundleListeners.isEmpty()) { return; } final BundleEvent event = new BundleEvent(state, bundle); // inform the synchrounous bundle listeners first ... final BundleListener[] syncs = (BundleListener[]) syncBundleListeners.toArray(new BundleListener[syncBundleListeners.size()]); for (int i = 0; i < syncs.length; i++) { syncs[i].bundleChanged(event); } if (bundleListeners.isEmpty()) { return; } final BundleListener[] asyncs = (BundleListener[]) bundleListeners.toArray(new BundleListener[bundleListeners.size()]); for (int i = 0; i < asyncs.length; i++) { asyncs[i].bundleChanged(event); } }
@Activate void activate(BundleContext ctx) { this.base = new File("").toURI(); // Find the resolved vaadin bundle this.vaadinResourceBundles = new BundleTracker<Bundle>(ctx, Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, new BundleTrackerCustomizer<Bundle>() { @Override public Bundle addingBundle(Bundle bundle, BundleEvent event) { return VAADIN_SERVER_BUNDLE.equals(bundle.getSymbolicName()) ? bundle : null; } @Override public void modifiedBundle(Bundle bundle, BundleEvent event, Bundle object) { } @Override public void removedBundle(Bundle bundle, BundleEvent event, Bundle object) { } }); this.vaadinResourceBundles.open(); }
/** * A bundle has been started, stopped, resolved, or unresolved. This method is a synchronous callback, do not do * any long-running work in this thread. * * @see org.osgi.framework.SynchronousBundleListener#bundleChanged */ public void bundleChanged(BundleEvent event) { boolean trace = log.isTraceEnabled(); // check if the listener is still alive if (isClosed) { if (trace) log.trace("Listener is closed; events are being ignored"); return; } if (trace) { log.trace("Processing bundle event [" + OsgiStringUtils.nullSafeToString(event) + "] for bundle [" + OsgiStringUtils.nullSafeSymbolicName(event.getBundle()) + "]"); } try { handleEvent(event); } catch (Exception ex) { /* log exceptions before swallowing */ log.warn("Got exception while handling event " + event, ex); } }
@Override @SuppressWarnings("IllegalCatch") public void removedBundle(final Bundle bundle, final BundleEvent event, final Collection<ObjectRegistration<YangModuleInfo>> regs) { if (regs == null) { return; } for (ObjectRegistration<YangModuleInfo> reg : regs) { try { reg.close(); } catch (final Exception e) { LOG.error("Unable to unregister YangModuleInfo {}", reg.getInstance(), e); } } }
@Override public Boolean addingBundle(final Bundle bundle, final BundleEvent event) { URL resource = bundle.getEntry("META-INF/services/" + ModuleFactory.class.getName()); LOG.trace("Got addingBundle event of bundle {}, resource {}, event {}", bundle, resource, event); if (resource != null) { try { for (String factoryClassName : Resources.readLines(resource, StandardCharsets.UTF_8)) { registerFactory(factoryClassName, bundle); } return Boolean.TRUE; } catch (final IOException e) { LOG.error("Error while reading {}", resource, e); throw new RuntimeException(e); } } return Boolean.FALSE; }
@Override public void removedBundle(final Bundle bundle, final BundleEvent event, final Future<T> object) { if (!object.isDone() && object.cancel(false)) { // We canceled adding event before it was processed // so it is safe to return LOG.trace("Adding Bundle event for {} was cancelled. No additional work required.", bundle); return; } try { LOG.trace("Invoking removedBundle event for {}", bundle); primaryTracker.removedBundle(bundle, event, object.get()); forEachAdditionalBundle(tracker -> tracker.removedBundle(bundle, event, null)); LOG.trace("Removed bundle event for {} finished successfully.", bundle); } catch (final ExecutionException | InterruptedException e) { LOG.error("Failed to remove bundle {}", bundle, e); } }
/** * Implemented from BundleTrackerCustomizer. */ @Override public void modifiedBundle(final Bundle bundle, final BundleEvent event, final Bundle object) { if (shuttingDown) { return; } if (bundle.getState() == Bundle.ACTIVE) { List<Object> paths = findBlueprintPaths(bundle); if (!paths.isEmpty()) { LOG.info("Creating blueprint container for bundle {} with paths {}", bundle, paths); blueprintExtenderService.createContainer(bundle, paths); } } }
BundleImpl(File file) throws Exception { long currentTimeMillis = System.currentTimeMillis(); DataInputStream dataInputStream = new DataInputStream(new FileInputStream(new File(file, "meta"))); this.location = dataInputStream.readUTF(); this.currentStartlevel = dataInputStream.readInt(); this.persistently = dataInputStream.readBoolean(); dataInputStream.close(); this.bundleDir = file; this.state = BundleEvent.STARTED; try { this.archive = new BundleArchive(this.location, file); resolveBundle(false); Framework.bundles.put(this.location, this); Framework.notifyBundleListeners(BundleEvent.INSTALLED, this); if (Framework.DEBUG_BUNDLES && log.isInfoEnabled()) { log.info("Framework: Bundle " + toString() + " loaded. " + (System.currentTimeMillis() - currentTimeMillis) + " ms"); } } catch (Exception e) { throw new BundleException("Could not load bundle " + this.location, e.getCause()); } }
public synchronized void startBundle() throws BundleException { if (this.state == BundleEvent.INSTALLED) { throw new IllegalStateException("Cannot start uninstalled bundle " + toString()); } else if (this.state != BundleEvent.RESOLVED) { if (this.state == BundleEvent.STARTED) { resolveBundle(true); } this.state = BundleEvent.UPDATED; try { isValid = true; this.state = BundleEvent.RESOLVED; Framework.notifyBundleListeners(BundleEvent.STARTED, this); if (Framework.DEBUG_BUNDLES && log.isInfoEnabled()) { log.info("Framework: Bundle " + toString() + " started."); } } catch (Throwable th) { Framework.clearBundleTrace(this); this.state = BundleEvent.STOPPED; String msg = "Error starting bundle " + toString(); log.error(msg,th); } } }
public synchronized void stopBundle() throws BundleException { if (this.state == BundleEvent.INSTALLED) { throw new IllegalStateException("Cannot stop uninstalled bundle " + toString()); } else if (this.state == BundleEvent.RESOLVED) { this.state = BundleEvent.UNINSTALLED; try { if (Framework.DEBUG_BUNDLES && log.isInfoEnabled()) { log.info("Framework: Bundle " + toString() + " stopped."); } Framework.clearBundleTrace(this); this.state = BundleEvent.STOPPED; Framework.notifyBundleListeners(BundleEvent.STOPPED, this); isValid = false; } catch (Throwable th) { Framework.clearBundleTrace(this); this.state = BundleEvent.STOPPED; Framework.notifyBundleListeners(BundleEvent.STOPPED, this); isValid = false; } } }
@Override public synchronized void uninstall() throws BundleException { if (this.state == BundleEvent.INSTALLED) { throw new IllegalStateException("Bundle " + toString() + " is already uninstalled."); } if (this.state == BundleEvent.RESOLVED) { try { stopBundle(); } catch (Throwable th) { Framework.notifyFrameworkListeners(BundleEvent.STARTED, this, th); } } this.state = BundleEvent.INSTALLED; new File(this.bundleDir, "meta").delete(); this.classloader.cleanup(true); this.classloader = null; Framework.bundles.remove(this); Framework.notifyBundleListeners(BundleEvent.UNINSTALLED, this); isValid = false; }
static void shutdown(boolean restart) { System.out.println("---------------------------------------------------------"); System.out.println(" ACDD OSGi shutting down ..."); System.out.println(" Bye !"); System.out.println("---------------------------------------------------------"); systemBundle.state = BundleEvent.UNINSTALLED; systemBundle.setLevel(getBundles().toArray(new Bundle[bundles.size()]), 0, true); bundles.clear(); systemBundle.state = BundleEvent.INSTALLED; if (restart) { try { startup(); } catch (Throwable th) { th.printStackTrace(); } } }
static void notifyBundleListeners(int event, Bundle bundle) { if (!syncBundleListeners.isEmpty() || !bundleListeners.isEmpty()) { BundleEvent bundleEvent = new BundleEvent(event, bundle); BundleListener[] bundleListenerArr = syncBundleListeners.toArray(new BundleListener[syncBundleListeners.size()]); for (BundleListener bundleChanged : bundleListenerArr) { bundleChanged.bundleChanged(bundleEvent); } if (!bundleListeners.isEmpty()) { bundleListenerArr = bundleListeners.toArray(new BundleListener[bundleListeners.size()]); for (BundleListener bundleListener : bundleListenerArr) { bundleListener.bundleChanged(bundleEvent); } } } }
@Override public void bundleChanged(BundleEvent event) { logger.debug("Bundle changed: {}", event); if (stopped) { return; } Bundle bundle = event.getBundle(); if (bundle.getState() != Bundle.ACTIVE && bundle.getState() != Bundle.STARTING) { // The bundle is not in STARTING or ACTIVE state anymore // so destroy the bundleContext. Ignore our own bundle since it // needs to kick the orderly shutdown. if (bundle != this.bundleContext.getBundle()) { destroyExtension(bundle); } } }
@Override public void bundleChanged(BundleEvent event) { Bundle bundle = event.getBundle(); try { PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); if (event.getType() == BundleEvent.STARTED) { addUIPermissionFromBundle(bundle); } } catch (Exception e) { log.error("Error occured when processing component xml in bundle " + bundle.getSymbolicName(), e); } }
@Override public void bundleChanged(BundleEvent bundleEvent) { if (providerBaseClassName == null || objectMapperClassName == null) { return; } if (bundleEvent.getBundle().getState() == Bundle.UNINSTALLED) return; Set<String> classNamesOfCurrentBundle = JacksonManagerService.getClassNames(bundleEvent.getBundle()); if (classNamesOfCurrentBundle.contains(objectMapperClassName) || classNamesOfCurrentBundle.contains(providerBaseClassName)) { if (bundleEvent.getType() == BundleEvent.STARTED && isValid()) { jacksonServiceController = true; } if (bundleEvent.getType() == BundleEvent.STOPPED) { jacksonServiceController = false; } } }
@Override public void bundleChanged(BundleEvent bundleEvent) { if (moduleClassNames == null) { return; } Set<String> classNamesOfCurrentBundle = JacksonManagerService.getClassNames(bundleEvent.getBundle()); boolean found = false; for (String className : moduleClassNames) { if (classNamesOfCurrentBundle.contains(className)) { found = true; break; } } if (found) { if (bundleEvent.getType() == BundleEvent.STARTED && isValid()) { jacksonServiceController = true; } if (bundleEvent.getType() == BundleEvent.STOPPED) { jacksonServiceController = false; } } }
@Override public Collection<ServiceRegistration> addingBundle(Bundle bundle, BundleEvent event) { BundleCommandEventSetProvider bundleCommandEventSetProvider = new BundleCommandEventSetProvider(bundle); ArrayList<ServiceRegistration> registrations = new ArrayList<>(); Hashtable<String, Object> properties = new Hashtable<>(); properties.put("bundle", bundle.getSymbolicName()); if (!bundleCommandEventSetProvider.getCommands().isEmpty()) { properties.put("commands", Joiner.on(", ").join( bundleCommandEventSetProvider.getCommands().stream().map(Class::getName).collect(Collectors.toList()))); log.info("Registering a service for providing commands in {}", bundle.getSymbolicName()); registrations.add(bundleContext.registerService(CommandSetProvider.class, bundleCommandEventSetProvider, properties)); } if (!bundleCommandEventSetProvider.getEvents().isEmpty()) { properties.put("events", Joiner.on(", ").join( bundleCommandEventSetProvider.getEvents().stream().map(Class::getName).collect(Collectors.toList()))); log.info("Registering a service for providing events in {}", bundle.getSymbolicName()); registrations.add(bundleContext.registerService(EventSetProvider.class, bundleCommandEventSetProvider, properties)); } return registrations; }
@Override public void start(BundleContext bundleContext) throws Exception { final String configAdminInit = bundleContext.getBundle().getHeaders().get("X-Aries-Blueprint-ConfigAdmin-Init"); if (configAdminInit != null) { final BundleContext sysContext = bundleContext.getBundle(0).getBundleContext(); // we are started before blueprint.core and felix.configadmin // we are sure that felix.configadmin is started before blueprint.core sysContext.addBundleListener(new SynchronousBundleListener() { @Override public void bundleChanged(BundleEvent event) { if (event.getType() == BundleEvent.STARTED && "org.apache.felix.configadmin".equals(event.getBundle().getSymbolicName())) { // configadmin should have already been started ServiceReference<?> sr = sysContext.getServiceReference("org.osgi.service.cm.ConfigurationAdmin"); if (sr != null && sysContext.getService(sr) != null) { initializeConfigAdmin(sysContext, configAdminInit); } } } }); } }
private String getBundleEventTypeText(int type) { switch (type) { case BundleEvent.INSTALLED: return "Installed"; case BundleEvent.RESOLVED: return "Resolved"; case BundleEvent.LAZY_ACTIVATION: return "Lazy Activation"; case BundleEvent.STARTING: return "Starting"; case BundleEvent.STARTED: return "Started"; case BundleEvent.STOPPING: return "Stopping"; case BundleEvent.STOPPED: return "Stopped"; case BundleEvent.UPDATED: return "Updated"; case BundleEvent.UNRESOLVED: return "Unresolved"; case BundleEvent.UNINSTALLED: return "Uninstalled"; default: return type + " ???"; } }
public Object addingBundle(Bundle bundle, BundleEvent event) { LOG.debug("Bundle started: {}", bundle.getSymbolicName()); if (extenderCapabilityWired(bundle)) { List<BaseService> r = new ArrayList<BaseService>(); registerComponents(bundle, r); registerLanguages(bundle, r); registerDataFormats(bundle, r); registerTypeConverterLoader(bundle, r); for (BaseService service : r) { service.register(); } resolvers.put(bundle.getBundleId(), r); } return bundle; }
@Override public void start(BundleContext bundleContext) throws Exception { final String configAdminInit = bundleContext.getBundle().getHeaders().get("X-Camel-Blueprint-ConfigAdmin-Init"); if (configAdminInit != null) { final BundleContext sysContext = bundleContext.getBundle(0).getBundleContext(); // we are started before blueprint.core and felix.configadmin // we are sure that felix.configadmin is started before blueprint.core sysContext.addBundleListener(new SynchronousBundleListener() { @Override public void bundleChanged(BundleEvent event) { if (event.getType() == BundleEvent.STARTED && "org.apache.felix.configadmin".equals(event.getBundle().getSymbolicName())) { // configadmin should have already been started ServiceReference<?> sr = sysContext.getServiceReference("org.osgi.service.cm.ConfigurationAdmin"); if (sr != null && sysContext.getService(sr) != null) { initializeConfigAdmin(sysContext, configAdminInit); } } } }); } }
@Override public Bundle addingBundle(final Bundle bundle, final BundleEvent event) { Collection<BundleRequirement> wiredRequirements = resolveWiredRequirements(bundle); if (wiredRequirements.size() == 0) { return null; } List<ComponentContainerInstance<?>> containers; try { containers = addBundleRequirements(bundle, wiredRequirements); } catch (RuntimeException e) { logService.log(LogService.LOG_ERROR, "Error during processing requirements of bundle: " + bundle.getSymbolicName() + ":" + bundle.getVersion(), e); return null; } activeComponentContainers.put(bundle, containers); return bundle; }
@Override public JspBundle addingBundle ( final Bundle bundle, final BundleEvent event ) { final Enumeration<String> result = bundle.getEntryPaths ( "/WEB-INF" ); if ( result != null && result.hasMoreElements () ) { try { return new JspBundle ( bundle, this.service, this.context ); } catch ( ServletException | NamespaceException e ) { logger.warn ( "Failed to register JSP bundle: " + bundle.getSymbolicName (), e ); return null; } } return null; }
public Object addingBundle(Bundle bundle, BundleEvent event) { if (event == null) { // existing bundles first added to the tracker with no event change checkInitialBundle(bundle); } else { bundleChanged(event); } List<BundleScriptEngineResolver> r = new ArrayList<BundleScriptEngineResolver>(); registerScriptEngines(bundle, r); for (BundleScriptEngineResolver service : r) { service.register(); } resolvers.put(bundle.getBundleId(), r); return bundle; }
@Override public Object addingBundle(Bundle bundle, BundleEvent event) { ArrayList<String> aliases = new ArrayList<String>(); String[] resources = findResources(bundle); if ( resources != null ) { HttpContext ctx = new ProxyHttpContext(bundle); for ( String p : resources ) { String[] split = p.split("\\s*=\\s*"); String alias = split[0]; String file = split.length == 1 ? split[0] : split[1]; try { System.out.println( "Registering " + alias + "->" + file ); http.registerResources(alias, file, ctx); aliases.add( alias ); } catch (NamespaceException e) { e.printStackTrace(); } } } return aliases.isEmpty() ? null : aliases.toArray(new String[aliases.size()]); }
private void registerBundleLoaderExecutor() { /* bundle loader extensions will be registered so that custom loaders like JSPBundle loader can watch for other bundles and run extension service*/ new BundleTracker(osgiFramework.getBundleContext(), Bundle.STARTING, null) { @Override public Object addingBundle(Bundle bundle, BundleEvent event) { // custom bundle loaders if (bundleLoaders != null) { for (BundleLoader loader : bundleLoaders) { try { loader.loadBundle(bundle); } catch (BundleLoadingException e) { LOGGER.error("Error while running custom bundle loader " + loader.getClass().getName() + " Error: " + e.getMessage()); } } } return super.addingBundle(bundle, event); } }.open(); }
static void notifyBundleListeners(int i, Bundle bundle) { int i2 = 0; if (!syncBundleListeners.isEmpty() || !bundleListeners.isEmpty()) { BundleEvent bundleEvent = new BundleEvent(i, bundle); BundleListener[] bundleListenerArr = (BundleListener[]) syncBundleListeners.toArray(new BundleListener[syncBundleListeners.size()]); for (BundleListener bundleChanged : bundleListenerArr) { bundleChanged.bundleChanged(bundleEvent); } if (!bundleListeners.isEmpty()) { bundleListenerArr = (BundleListener[]) bundleListeners.toArray(new BundleListener[bundleListeners.size()]); while (i2 < bundleListenerArr.length) { bundleListenerArr[i2].bundleChanged(bundleEvent); i2++; } } } }
@Override public Object addingBundle(Bundle bundle, BundleEvent event) { // Get the wiring of the bundle. BundleWiring wiring = Helper.getWiring(bundle); // See it is wired to us as extender. List<BundleWire> requirements = wiring.getRequiredWires("osgi.extender"); Context context = null; if (requirements != null && requirements.stream().anyMatch((w) -> w.getProviderWiring().getBundle().equals(me))) { // Create the stuff. WeldContainer container = new WeldContainer(bundle); Hashtable<String, Object> dict = new Hashtable<>(); dict.put(Constants.BUNDLE_SYMBOLICNAME, bundle.getSymbolicName()); String cat = bundle.getHeaders().get(Constants.BUNDLE_CATEGORY); if (cat != null) { dict.put(Constants.BUNDLE_CATEGORY, cat); } ServiceRegistration<BeanManager> reg = bundle.getBundleContext().registerService(BeanManager.class, container.getManager(), dict); context = new Context(container, reg); } return context; }
@Before public void setup() { bundleEvent = mock( BundleEvent.class ); bundle = mock( Bundle.class ); bundleContext = mock( BundleContext.class ); when( bundleEvent.getBundle() ).thenReturn( bundle ); when( bundleContext.getBundle() ).thenReturn( bundle ); bundleStateManager = new BundleStateManager(); platformDeployerBundleListener = new PlatformDeployerBundleListener(); platformDeployerBundleListener.setBundleStateManager( bundleStateManager ); platformDeployerBundleListener.setBundleContext( bundleContext ); when( bundleEvent.getBundle().getSymbolicName() ).thenReturn( "common-ui" ); Dictionary<String, String> headers = new Hashtable<String, String>(); headers.put( "Bundle-Name", "common-ui" ); headers.put( "Bundle-Version", "100" ); headers.put( "Bundle-PlatformPluginName", "common-ui" ); when( bundleEvent.getBundle().getHeaders() ).thenReturn( headers ); }
public void init() { bundleTracker = new BundleTracker<Bundle>(context, Bundle.ACTIVE, null) { @Override public Bundle addingBundle(Bundle bundle, BundleEvent event) { onBundleAdded(bundle); return bundle; } @Override public void removedBundle(Bundle bundle, BundleEvent event, Bundle object) { onBundleRemoved(bundle); } }; bundleTracker.open(); }
@Override public void init(ConfigurationProvider configurationProvider) { LOG.debug("Initializing observer configuration"); tracker = new ServiceTracker<SessionFactoryObserver, SessionFactoryObserver>(bundleContext, SessionFactoryObserver.class, null); tracker.open(); bundleContext.addBundleListener(new SynchronousBundleListener() { @Override public void bundleChanged(BundleEvent event) { if (event.getBundle().equals(bundleContext.getBundle()) && event.getType() == BundleEvent.STOPPING) { tracker.close(); tracker = null; } } }); configurationProvider.getConfiguration().setSessionFactoryObserver(this); configurationProvider.invalidate(); }
public FileAssociationChecker() { mEditorRegistry = PlatformUI.getWorkbench().getEditorRegistry(); mJobName = EclipseNSISStartup.getResourceString("job.name"); //$NON-NLS-1$ mDialogTitleFormat = new MessageFormat(EclipseNSISStartup.getResourceString("dialog.title.format")); //$NON-NLS-1$ mDialogMessageFormat = new MessageFormat(EclipseNSISStartup.getResourceString("dialog.message.format")); //$NON-NLS-1$ mDialogToggleMessageFormat = new MessageFormat(EclipseNSISStartup.getResourceString("dialog.toggle.message.format")); //$NON-NLS-1$ final IExtensionTracker tracker = PlatformUI.getWorkbench().getExtensionTracker(); loadExtensions(tracker); tracker.registerHandler(this, ExtensionTracker.createExtensionPointFilter(getExtensionPointFilter())); final BundleContext bundleContext = EclipseNSISStartup.getDefault().getBundleContext(); bundleContext.addBundleListener(new BundleListener() { public void bundleChanged(BundleEvent event) { if(event.getType() == BundleEvent.STOPPED ) { bundleContext.removeBundleListener(this); } tracker.unregisterHandler(FileAssociationChecker.this); Job.getJobManager().cancel(JOB_FAMILY); } }); }
@Override public List<MustacheTemplate> addingBundle(Bundle bundle, BundleEvent bundleEvent) { List<MustacheTemplate> list = new ArrayList<>(); Enumeration<URL> urls = bundle.findEntries(TEMPLATE_DIRECTORY_IN_BUNDLES, "*.mst*", true); if (urls == null) { // No match, but it may come later, so return an empty list // to still be notified of the other events. return list; } while (urls.hasMoreElements()) { URL url = urls.nextElement(); // Check it's the mustache template. if (MustacheTemplate.isMustacheTemplate(url.toExternalForm())) { MustacheTemplate template = engine.addTemplate(url); list.add(template); } } return list; }