Search in sources :

Example 1 with Generation

use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.

the class EquinoxContainerAdaptor method invalidateWiring.

@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);
}
Also used : ProtectionDomain(java.security.ProtectionDomain) Generation(org.eclipse.osgi.storage.BundleInfo.Generation) BundlePermissions(org.eclipse.osgi.internal.permadmin.BundlePermissions) SystemModule(org.eclipse.osgi.container.SystemModule) Module(org.eclipse.osgi.container.Module) ModuleRevision(org.eclipse.osgi.container.ModuleRevision) SystemBundleLoader(org.eclipse.osgi.internal.loader.SystemBundleLoader) BundleLoader(org.eclipse.osgi.internal.loader.BundleLoader)

Example 2 with Generation

use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.

the class BundleContextImpl method getDataFile.

/**
 * Creates a <code>File</code> object for a file in the
 * persistent storage area provided for the bundle by the framework.
 * If the adaptor does not have file system support, this method will
 * return <code>null</code>.
 *
 * <p>A <code>File</code> object for the base directory of the
 * persistent storage area provided for the context bundle by the framework
 * can be obtained by calling this method with the empty string ("")
 * as the parameter.
 * See {@link #getBundle()} for a definition of context bundle.
 *
 * <p>If the Java runtime environment supports permissions,
 * the framework the will ensure that the bundle has
 * <code>java.io.FilePermission</code> with actions
 * "read","write","execute","delete" for all files (recursively) in the
 * persistent storage area provided for the context bundle by the framework.
 *
 * @param filename A relative name to the file to be accessed.
 * @return A <code>File</code> object that represents the requested file or
 * <code>null</code> if the adaptor does not have file system support.
 * @exception java.lang.IllegalStateException
 * If the bundle context has stopped.
 */
public File getDataFile(String filename) {
    checkValid();
    Generation generation = (Generation) bundle.getModule().getCurrentRevision().getRevisionInfo();
    return generation.getBundleInfo().getDataFile(filename);
}
Also used : Generation(org.eclipse.osgi.storage.BundleInfo.Generation)

Example 3 with Generation

use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.

the class EquinoxBundle method getResource.

@Override
public URL getResource(String name) {
    try {
        equinoxContainer.checkAdminPermission(this, AdminPermission.RESOURCE);
    } catch (SecurityException e) {
        return null;
    }
    checkValid();
    if (isFragment()) {
        return null;
    }
    ModuleClassLoader classLoader = getModuleClassLoader(false);
    if (classLoader != null) {
        return classLoader.getResource(name);
    }
    return new ClasspathManager((Generation) module.getCurrentRevision().getRevisionInfo(), null).findLocalResource(name);
}
Also used : ClasspathManager(org.eclipse.osgi.internal.loader.classpath.ClasspathManager) Generation(org.eclipse.osgi.storage.BundleInfo.Generation) ModuleClassLoader(org.eclipse.osgi.internal.loader.ModuleClassLoader)

Example 4 with Generation

use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.

the class EquinoxBundle method getDataFile.

@Override
public File getDataFile(String filename) {
    checkValid();
    Generation current = (Generation) module.getCurrentRevision().getRevisionInfo();
    return current.getBundleInfo().getDataFile(filename);
}
Also used : Generation(org.eclipse.osgi.storage.BundleInfo.Generation)

Example 5 with Generation

use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.

the class EquinoxBundle method getEntryPaths.

@Override
public Enumeration<String> getEntryPaths(String path) {
    try {
        equinoxContainer.checkAdminPermission(this, AdminPermission.RESOURCE);
    } catch (SecurityException e) {
        return null;
    }
    checkValid();
    Generation current = (Generation) getModule().getCurrentRevision().getRevisionInfo();
    return current.getBundleFile().getEntryPaths(path);
}
Also used : Generation(org.eclipse.osgi.storage.BundleInfo.Generation)

Aggregations

Generation (org.eclipse.osgi.storage.BundleInfo.Generation)34 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)15 ArrayList (java.util.ArrayList)10 Module (org.eclipse.osgi.container.Module)10 IOException (java.io.IOException)8 File (java.io.File)7 BundleFile (org.eclipse.osgi.storage.bundlefile.BundleFile)7 DirBundleFile (org.eclipse.osgi.storage.bundlefile.DirBundleFile)6 NestedDirBundleFile (org.eclipse.osgi.storage.bundlefile.NestedDirBundleFile)6 ZipBundleFile (org.eclipse.osgi.storage.bundlefile.ZipBundleFile)6 BundleException (org.osgi.framework.BundleException)6 ByteArrayInputStream (java.io.ByteArrayInputStream)3 DataInputStream (java.io.DataInputStream)3 URL (java.net.URL)3 ProtectionDomain (java.security.ProtectionDomain)3 ModuleRevisionBuilder (org.eclipse.osgi.container.ModuleRevisionBuilder)3 ModuleWire (org.eclipse.osgi.container.ModuleWire)3 SystemModule (org.eclipse.osgi.container.SystemModule)3 BufferedInputStream (java.io.BufferedInputStream)2 FileInputStream (java.io.FileInputStream)2