Search in sources :

Example 1 with GenericInfo

use of org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo in project rt.equinox.framework by eclipse.

the class ModuleWiring method addDynamicImports.

/**
 * Adds the {@link ModuleRevisionBuilder#getRequirements() requirements} from
 * the specified builder to this wiring.  The new requirements must be in the
 * {@link PackageNamespace}.  These requirements are transient
 * and will not exist when loading up persistent wirings.
 * @param builder the builder that defines the new dynamic imports.
 */
public void addDynamicImports(ModuleRevisionBuilder builder) {
    List<GenericInfo> newImports = builder.getRequirements();
    List<ModuleRequirement> newRequirements = new ArrayList<>();
    for (GenericInfo info : newImports) {
        if (!PackageNamespace.PACKAGE_NAMESPACE.equals(info.getNamespace())) {
            // $NON-NLS-1$
            throw new IllegalArgumentException("Invalid namespace for package imports: " + info.getNamespace());
        }
        Map<String, Object> attributes = new HashMap<>(info.getAttributes());
        Map<String, String> directives = new HashMap<>(info.getDirectives());
        // $NON-NLS-1$
        directives.put(DYNAMICALLY_ADDED_IMPORT_DIRECTIVE, "true");
        directives.put(PackageNamespace.REQUIREMENT_RESOLUTION_DIRECTIVE, PackageNamespace.RESOLUTION_DYNAMIC);
        newRequirements.add(new ModuleRequirement(info.getNamespace(), directives, attributes, revision));
    }
    ModuleDatabase moduleDatabase = revision.getRevisions().getContainer().moduleDatabase;
    moduleDatabase.writeLock();
    try {
        List<ModuleRequirement> updatedRequirements = new ArrayList<>(requirements);
        updatedRequirements.addAll(newRequirements);
        requirements = updatedRequirements;
    } finally {
        moduleDatabase.writeUnlock();
    }
}
Also used : GenericInfo(org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo)

Example 2 with GenericInfo

use of org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo in project rt.equinox.framework by eclipse.

the class ModuleDatabase method getActivationPolicySettings.

private EnumSet<Settings> getActivationPolicySettings(ModuleRevisionBuilder builder) {
    // do not do this for fragment bundles
    if ((builder.getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) {
        return null;
    }
    for (GenericInfo info : builder.getCapabilities()) {
        if (EquinoxModuleDataNamespace.MODULE_DATA_NAMESPACE.equals(info.getNamespace())) {
            if (EquinoxModuleDataNamespace.CAPABILITY_ACTIVATION_POLICY_LAZY.equals(info.getAttributes().get(EquinoxModuleDataNamespace.CAPABILITY_ACTIVATION_POLICY))) {
                String compatibilityStartLazy = adaptor.getProperty(EquinoxConfiguration.PROP_COMPATIBILITY_START_LAZY);
                if (compatibilityStartLazy == null || Boolean.valueOf(compatibilityStartLazy)) {
                    // TODO hack until p2 is fixed (bug 177641)
                    EnumSet<Settings> settings = EnumSet.noneOf(Settings.class);
                    settings.add(Settings.USE_ACTIVATION_POLICY);
                    settings.add(Settings.AUTO_START);
                    return settings;
                }
            }
            return null;
        }
    }
    return null;
}
Also used : GenericInfo(org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo) Settings(org.eclipse.osgi.container.Module.Settings)

Aggregations

GenericInfo (org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo)2 Settings (org.eclipse.osgi.container.Module.Settings)1