public static Storage createStorage(EquinoxContainer container) throws IOException, BundleException { Storage storage = new Storage(container); // Do some operations that need to happen on the fully constructed Storage before returning it storage.checkSystemBundle(); storage.discardBundlesOnLoad(); storage.installExtensions(); // TODO hack to make sure all bundles are in UNINSTALLED state before system bundle init is called storage.getModuleContainer().setInitialModuleStates(); return storage; }
long getTimeStamp() { synchronized (this.monitor) { return equinoxContainer.getStorage().getModuleDatabase().getRevisionsTimestamp(); } }
void close() { StorageSaver currentSaver; Storage currentStorage; ScheduledExecutorService currentExecutor; synchronized (this.monitor) { serviceRegistry = null; currentSaver = storageSaver; currentStorage = storage; currentExecutor = executor; } // do this outside of the lock to avoid deadlock currentSaver.close(); currentStorage.close(); // Must be done last since it will result in termination of the // framework active thread. currentExecutor.shutdown(); }
public static Storage createStorage(EquinoxContainer container) throws IOException, BundleException { Storage storage = new Storage(container); // Do some operations that need to happen on the fully constructed Storage before returning it storage.checkSystemBundle(); storage.refreshStaleBundles(); storage.installExtensions(); // TODO hack to make sure all bundles are in UNINSTALLED state before system bundle init is called storage.getModuleContainer().setInitialModuleStates(); return storage; }
private static List<BundleFile> getMRBundleFiles(BundleFile bundlefile, Generation generation) { Storage storage = generation.getBundleInfo().getStorage(); if (storage.getRuntimeVersion().getMajor() < 9) { return Collections.emptyList(); } List<BundleFile> mrBundleFiles = new ArrayList<>(); for (int i = storage.getRuntimeVersion().getMajor(); i > 8; i--) { String versionPath = BundleInfo.MULTI_RELEASE_VERSIONS + i + '/'; BundleEntry versionEntry = bundlefile.getEntry(versionPath); if (versionEntry != null) { mrBundleFiles.add(storage.createNestedBundleFile(versionPath, bundlefile, generation, BundleInfo.MULTI_RELEASE_FILTER_PREFIXES)); } } return Collections.unmodifiableList(mrBundleFiles); }
private Storage(EquinoxContainer container) throws IOException, BundleException { mruList = new MRUBundleFileList(getBundleFileLimit(container.getConfiguration())); equinoxContainer = container; extensionInstaller = new FrameworkExtensionInstaller(container.getConfiguration()); cleanOSGiStorage(osgiLocation, childRoot); parentRoot = parent == null ? null : new File(parent.getURL().getFile()); InputStream info = getInfoInputStream(); DataInputStream data = info == null ? null : new DataInputStream(new BufferedInputStream(info)); try { Map<Long, Generation> generations; try { generations = loadGenerations(data); } catch (IllegalArgumentException e) { equinoxContainer.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.WARNING, "The persistent format for the framework data has changed. The framework will be reinitialized: " + e.getMessage(), null); //$NON-NLS-1$ generations = new HashMap<Long, Generation>(0); data = null; cleanOSGiStorage(osgiLocation, childRoot); this.permissionData = loadPermissionData(data); this.securityAdmin = new SecurityAdmin(null, this.permissionData); this.adaptor = new EquinoxContainerAdaptor(equinoxContainer, this, generations); cleanOSGiStorage(osgiLocation, childRoot);
@Override public void invalidateWiring(ModuleWiring moduleWiring, ModuleLoader current) { if (current instanceof BundleLoader) { BundleLoader bundleLoader = (BundleLoader) current; bundleLoader.close(); } long updatedTimestamp = storage.getModuleDatabase().getRevisionsTimestamp(); if (System.getSecurityManager() != null && updatedTimestamp != lastSecurityAdminFlush.getAndSet(updatedTimestamp)) { storage.getSecurityAdmin().clearCaches(); List<Module> modules = storage.getModuleContainer().getModules(); for (Module module : modules) { for (ModuleRevision revision : module.getRevisions().getModuleRevisions()) { Generation generation = (Generation) revision.getRevisionInfo(); if (generation != null) { ProtectionDomain domain = generation.getDomain(); if (domain != null) { ((BundlePermissions) domain.getPermissions()).clearPermissionCache(); } } } } } clearManifestCache(moduleWiring); }
@Override public void uninstall() throws BundleException { Storage storage = equinoxContainer.getStorage(); storage.getModuleContainer().uninstall(module); }
String findLibrary(String libname) { String path = findLibrary0(libname); if (path != null) { synchronized (loadedNativeCode) { if (loadedNativeCode.contains(path) || generation.getBundleInfo().getStorage().getConfiguration().COPY_NATIVES) { // we must copy the library to a temp space to allow another class loader to load the library String temp = generation.getBundleInfo().getStorage().copyToTempLibrary(generation, path); if (temp != null) path = temp; } else { loadedNativeCode.add(path); } } } return path; }
private void compact(File directory) { if (getConfiguration().getDebug().DEBUG_STORAGE) Debug.println("compact(" + directory.getPath() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ String list[] = directory.list(); if (!StorageUtil.rm(target, getConfiguration().getDebug().DEBUG_STORAGE) && !delete.exists()) { try { out.close(); } catch (IOException e) { if (getConfiguration().getDebug().DEBUG_STORAGE) Debug.println("Unable to write " + delete.getPath() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ compact(target); /* descend into directory */
private State createSystemState() { State state = factory.createState(true); StateConverter converter = new StateConverter(state); ModuleDatabase database = equinoxContainer.getStorage().getModuleDatabase(); database.readLock(); try { ModuleContainer container = equinoxContainer.getStorage().getModuleContainer(); List<Module> modules = equinoxContainer.getStorage().getModuleContainer().getModules(); for (Module module : modules) { ModuleRevision current = module.getCurrentRevision(); BundleDescription description = converter.createDescription(current); state.addBundle(description); } state.setPlatformProperties(asDictionary(equinoxContainer.getConfiguration().getInitialConfig())); synchronizer = new PlatformBundleListener(state, converter, database, container); state.setResolverHookFactory(synchronizer); bc.addBundleListener(synchronizer); bc.addFrameworkListener(synchronizer); state.resolve(); state.setTimeStamp(database.getRevisionsTimestamp()); } finally { database.readUnlock(); } return state; }
private static BundleFile createBundleFile(File content, Generation generation) { if (!content.exists()) { return null; } return generation.getBundleInfo().getStorage().createBundleFile(content, generation, content.isDirectory(), false); }
public BundleFile createNestedBundleFile(String nestedDir, BundleFile bundleFile, Generation generation) { return createNestedBundleFile(nestedDir, bundleFile, generation, Collections.<String> emptyList()); }
public void compact() { if (!osgiLocation.isReadOnly()) { compact(childRoot); } }
private Storage(EquinoxContainer container) throws IOException { mruList = new MRUBundleFileList(getBundleFileLimit(container.getConfiguration())); equinoxContainer = container; extensionInstaller = new FrameworkExtensionInstaller(container.getConfiguration()); cleanOSGiStorage(osgiLocation, childRoot); parentRoot = parent == null ? null : new File(parent.getURL().getFile()); InputStream info = getInfoInputStream(); DataInputStream data = info == null ? null : new DataInputStream(new BufferedInputStream(info)); try { Map<Long, Generation> generations; try { generations = loadGenerations(data); } catch (IllegalArgumentException e) { equinoxContainer.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.WARNING, "The persistent format for the framework data has changed. The framework will be reinitialized: " + e.getMessage(), null); //$NON-NLS-1$ generations = new HashMap<Long, Generation>(0); data = null; cleanOSGiStorage(osgiLocation, childRoot); this.permissionData = loadPermissionData(data); this.securityAdmin = new SecurityAdmin(null, this.permissionData); this.adaptor = new EquinoxContainerAdaptor(equinoxContainer, this, generations); cleanOSGiStorage(osgiLocation, childRoot);
@Override public void invalidateWiring(ModuleWiring moduleWiring, ModuleLoader current) { if (current instanceof BundleLoader) { BundleLoader bundleLoader = (BundleLoader) current; bundleLoader.close(); } long updatedTimestamp = storage.getModuleDatabase().getRevisionsTimestamp(); if (System.getSecurityManager() != null && updatedTimestamp != lastSecurityAdminFlush.getAndSet(updatedTimestamp)) { storage.getSecurityAdmin().clearCaches(); List<Module> modules = storage.getModuleContainer().getModules(); for (Module module : modules) { for (ModuleRevision revision : module.getRevisions().getModuleRevisions()) { Generation generation = (Generation) revision.getRevisionInfo(); if (generation != null) { ProtectionDomain domain = generation.getDomain(); if (domain != null) { ((BundlePermissions) domain.getPermissions()).clearPermissionCache(); } } } } } clearManifestCache(moduleWiring); }
public static Storage createStorage(EquinoxContainer container) throws IOException, BundleException { Storage storage = new Storage(container); // Do some operations that need to happen on the fully constructed Storage before returning it storage.checkSystemBundle(); storage.refreshStaleBundles(); storage.installExtensions(); // TODO hack to make sure all bundles are in UNINSTALLED state before system bundle init is called storage.getModuleContainer().setInitialModuleStates(); return storage; }
@Override public Module createModule(String location, long id, EnumSet<Settings> settings, int startlevel) { EquinoxBundle bundle = new EquinoxBundle(id, location, storage.getModuleContainer(), settings, startlevel, container); return bundle.getModule(); }
String findLibrary(String libname) { String path = findLibrary0(libname); if (path != null) { synchronized (loadedNativeCode) { if (loadedNativeCode.contains(path) || generation.getBundleInfo().getStorage().getConfiguration().COPY_NATIVES) { // we must copy the library to a temp space to allow another class loader to load the library String temp = generation.getBundleInfo().getStorage().copyToTempLibrary(generation, path); if (temp != null) path = temp; } else { loadedNativeCode.add(path); } } } return path; }
private void compact(File directory) { if (getConfiguration().getDebug().DEBUG_STORAGE) Debug.println("compact(" + directory.getPath() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ String list[] = directory.list(); if (!StorageUtil.rm(target, getConfiguration().getDebug().DEBUG_STORAGE) && !delete.exists()) { try { out.close(); } catch (IOException e) { if (getConfiguration().getDebug().DEBUG_STORAGE) Debug.println("Unable to write " + delete.getPath() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ compact(target); /* descend into directory */