Generation createGeneration() throws BundleException { synchronized (this.infoMonitor) { if (generationLocks == null) { generationLocks = new LockSet<Long>(); } boolean lockedID; try { lockedID = generationLocks.tryLock(nextGenerationId, 5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR, e); //$NON-NLS-1$ } if (!lockedID) { throw new BundleException("Failed to obtain id locks for generation.", BundleException.STATECHANGE_ERROR); //$NON-NLS-1$ } Generation newGeneration = new Generation(nextGenerationId++); return newGeneration; } }
private void refreshStaleBundles() throws BundleException { Collection<Module> needsRefresh = new ArrayList<>(0); // First uninstall any modules that had their content changed or deleted for (Module module : moduleContainer.getModules()) { if (module.getId() == Constants.SYSTEM_BUNDLE_ID) continue; ModuleRevision revision = module.getCurrentRevision(); Generation generation = (Generation) revision.getRevisionInfo(); if (needsDiscarding(generation)) { needsRefresh.add(module); moduleContainer.uninstall(module); generation.delete(); } } // Next check if we need to refresh Multi-Release Jar bundles // because the runtime version changed. if (refreshMRBundles.get()) { needsRefresh.addAll(refreshMRJarBundles()); } // refresh the modules that got deleted or are Multi-Release bundles if (!needsRefresh.isEmpty()) { moduleContainer.refresh(needsRefresh); } }
public URL getEntry(String path) { BundleEntry entry = getBundleFile().getEntry(path); if (entry == null) return null; path = BundleFile.fixTrailingSlash(path, entry); try { //use the constant string for the protocol to prevent duplication return Storage.secureAction.getURL(BundleResourceHandler.OSGI_ENTRY_URL_PROTOCOL, Long.toString(getBundleId()) + BundleResourceHandler.BID_FWKID_SEPARATOR + Integer.toString(getStorage().getModuleContainer().hashCode()), 0, path, new Handler(getStorage().getModuleContainer(), entry)); } catch (MalformedURLException e) { return null; } }
BundleInfo bundleInfo = generation.getBundleInfo(); out.writeLong(bundleInfo.getBundleId()); out.writeUTF(bundleInfo.getLocation()); out.writeLong(bundleInfo.getNextGenerationId()); out.writeLong(generation.getGenerationId()); out.writeBoolean(generation.isDirectory()); out.writeBoolean(generation.isReference()); out.writeBoolean(generation.hasPackageInfo()); if (bundleInfo.getBundleId() == 0) { if (generation.isReference()) { out.writeUTF(new FilePath(installPath).makeRelative(new FilePath(generation.getContent().getAbsolutePath()))); } else { out.writeUTF(Storage.getBundleFilePath(bundleInfo.getBundleId(), generation.getGenerationId())); out.writeLong(generation.getLastModified()); Dictionary<String, String> headers = generation.getHeaders(); for (String headerKey : cachedHeaderKeys) { String value = headers.get(headerKey);
BundleInfo bundleInfo = generation.getBundleInfo(); out.writeLong(bundleInfo.getBundleId()); out.writeUTF(bundleInfo.getLocation()); out.writeLong(bundleInfo.getNextGenerationId()); out.writeLong(generation.getGenerationId()); out.writeBoolean(generation.isDirectory()); out.writeBoolean(generation.isReference()); out.writeBoolean(generation.hasPackageInfo()); if (bundleInfo.getBundleId() == 0) { if (generation.isReference()) { out.writeUTF(new FilePath(installPath).makeRelative(new FilePath(generation.getContent().getAbsolutePath()))); } else { out.writeUTF(Storage.getBundleFilePath(bundleInfo.getBundleId(), generation.getGenerationId())); out.writeLong(generation.getLastModified()); Dictionary<String, String> headers = generation.getHeaders(); for (String headerKey : cachedHeaderKeys) { String value = headers.get(headerKey);
BundleInfo bundleInfo = generation.getBundleInfo(); out.writeLong(bundleInfo.getBundleId()); out.writeUTF(bundleInfo.getLocation()); out.writeLong(bundleInfo.getNextGenerationId()); out.writeLong(generation.getGenerationId()); out.writeBoolean(generation.isDirectory()); out.writeBoolean(generation.isReference()); out.writeBoolean(generation.hasPackageInfo()); if (bundleInfo.getBundleId() == 0) { if (generation.isReference()) { out.writeUTF(new FilePath(installPath).makeRelative(new FilePath(generation.getContent().getAbsolutePath()))); } else { out.writeUTF(Storage.getBundleFilePath(bundleInfo.getBundleId(), generation.getGenerationId())); out.writeLong(generation.getLastModified()); Dictionary<String, String> headers = generation.getHeaders(); for (String headerKey : cachedHeaderKeys) { String value = headers.get(headerKey);
result = generation.findLibrary(libname); if (result != null) { return result; result = fragment.getGeneration().findLibrary(libname); if (result != null) { return result;
result = generation.findLibrary(libname); if (result != null) { return result; result = fragment.getGeneration().findLibrary(libname); if (result != null) { return result;
result = generation.findLibrary(libname); if (result != null) { return result; result = fragment.getGeneration().findLibrary(libname); if (result != null) { return result;
result = generation.findLibrary(libname); if (result != null) { return result; result = fragment.getGeneration().findLibrary(libname); if (result != null) { return result;
result = generation.findLibrary(libname); if (result != null) { return result; result = fragment.getGeneration().findLibrary(libname); if (result != null) { return result;
result = generation.findLibrary(libname); if (result != null) { return result; result = fragment.getGeneration().findLibrary(libname); if (result != null) { return result;
public void close() { try { save(); } catch (IOException e) { getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error saving on shutdown", e); //$NON-NLS-1$ } // close all the generations List<Module> modules = moduleContainer.getModules(); for (Module module : modules) { for (ModuleRevision revision : module.getRevisions().getModuleRevisions()) { Generation generation = (Generation) revision.getRevisionInfo(); if (generation != null) { generation.close(); } } } for (ModuleRevision removalPending : moduleContainer.getRemovalPending()) { Generation generation = (Generation) removalPending.getRevisionInfo(); if (generation != null) { generation.close(); } } mruList.shutdown(); adaptor.shutdownResolverExecutor(); }
public void close() { try { save(); } catch (IOException e) { getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error saving on shutdown", e); //$NON-NLS-1$ } // close all the generations List<Module> modules = moduleContainer.getModules(); for (Module module : modules) { for (ModuleRevision revision : module.getRevisions().getModuleRevisions()) { Generation generation = (Generation) revision.getRevisionInfo(); if (generation != null) { generation.close(); } } } for (ModuleRevision removalPending : moduleContainer.getRemovalPending()) { Generation generation = (Generation) removalPending.getRevisionInfo(); if (generation != null) { generation.close(); } } mruList.shutdown(); adaptor.shutdownResolverExecutor(); }
public void close() { try { save(); } catch (IOException e) { getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error saving on shutdown", e); //$NON-NLS-1$ } // close all the generations List<Module> modules = moduleContainer.getModules(); for (Module module : modules) { for (ModuleRevision revision : module.getRevisions().getModuleRevisions()) { Generation generation = (Generation) revision.getRevisionInfo(); if (generation != null) { generation.close(); } } } for (ModuleRevision removalPending : moduleContainer.getRemovalPending()) { Generation generation = (Generation) removalPending.getRevisionInfo(); if (generation != null) { generation.close(); } } mruList.shutdown(); adaptor.shutdownResolverExecutor(); }
private void refreshStaleBundles() throws BundleException { Collection<Module> needsRefresh = new ArrayList<>(0); // First uninstall any modules that had their content changed or deleted for (Module module : moduleContainer.getModules()) { if (module.getId() == Constants.SYSTEM_BUNDLE_ID) continue; ModuleRevision revision = module.getCurrentRevision(); Generation generation = (Generation) revision.getRevisionInfo(); if (needsDiscarding(generation)) { needsRefresh.add(module); moduleContainer.uninstall(module); generation.delete(); } } // Next check if we need to refresh Multi-Release Jar bundles // because the runtime version changed. if (refreshMRBundles.get()) { needsRefresh.addAll(refreshMRJarBundles()); } // refresh the modules that got deleted or are Multi-Release bundles if (!needsRefresh.isEmpty()) { moduleContainer.refresh(needsRefresh); } }
public void close() { try { save(); } catch (IOException e) { getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error saving on shutdown", e); //$NON-NLS-1$ } // close all the generations List<Module> modules = moduleContainer.getModules(); for (Module module : modules) { for (ModuleRevision revision : module.getRevisions().getModuleRevisions()) { Generation generation = (Generation) revision.getRevisionInfo(); if (generation != null) { generation.close(); } } } for (ModuleRevision removalPending : moduleContainer.getRemovalPending()) { Generation generation = (Generation) removalPending.getRevisionInfo(); if (generation != null) { generation.close(); } } mruList.shutdown(); adaptor.shutdownResolverExecutor(); }
private boolean needsDiscarding(Generation generation) { for (StorageHook<?, ?> hook : generation.getStorageHooks()) { try { hook.validate(); } catch (IllegalStateException e) { // TODO Logging? return true; } } File content = generation.getContent(); if (getConfiguration().inCheckConfigurationMode()) { if (generation.isDirectory()) { content = new File(content, "META-INF/MANIFEST.MF"); //$NON-NLS-1$ } return generation.getLastModified() != secureAction.lastModified(content); } if (!content.exists()) { // the content got deleted since last time! return true; } return false; }
private boolean needsDiscarding(Generation generation) { for (StorageHook<?, ?> hook : generation.getStorageHooks()) { try { hook.validate(); } catch (IllegalStateException e) { // TODO Logging? return true; } } File content = generation.getContent(); if (!content.exists()) { // the content got deleted since last time! return true; } if (getConfiguration().inCheckConfigurationMode()) { if (generation.isDirectory()) content = new File(content, "META-INF/MANIFEST.MF"); //$NON-NLS-1$ return generation.getLastModified() != secureAction.lastModified(content); } return false; }
private boolean needsDiscarding(Generation generation) { for (StorageHook<?, ?> hook : generation.getStorageHooks()) { try { hook.validate(); } catch (IllegalStateException e) { // TODO Logging? return true; } } File content = generation.getContent(); if (getConfiguration().inCheckConfigurationMode()) { if (generation.isDirectory()) { content = new File(content, "META-INF/MANIFEST.MF"); //$NON-NLS-1$ } return generation.getLastModified() != secureAction.lastModified(content); } if (!content.exists()) { // the content got deleted since last time! return true; } return false; }