@Override public boolean resolveBundles(Collection<Bundle> bundles) { checkAdminPermission(getBundle(), AdminPermission.RESOLVE); Collection<Module> modules = getModules(bundles); resolve(modules, false); if (modules == null) { modules = ModuleContainer.this.getModules(); } for (Module module : modules) { if (getWiring(module.getCurrentRevision()) == null) return false; } return true; }
static Collection<ModuleRevision> getDependencyClosure(ModuleRevision initial, Map<ModuleRevision, ModuleWiring> wiringCopy) { Set<ModuleRevision> dependencyClosure = new HashSet<ModuleRevision>(); addDependents(initial, wiringCopy, dependencyClosure); return dependencyClosure; }
public RequiredBundle[] getRequiredBundles(String symbolicName) { String filter = "(" + BundleNamespace.BUNDLE_NAMESPACE + "=" + (symbolicName == null ? "*" : symbolicName) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ Map<String, String> directives = Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter); Map<String, Boolean> attributes = Collections.singletonMap(Capabilities.SYNTHETIC_REQUIREMENT, Boolean.TRUE); Requirement bundleReq = ModuleContainer.createRequirement(BundleNamespace.BUNDLE_NAMESPACE, directives, attributes); Collection<BundleCapability> bundleCaps = container.getFrameworkWiring().findProviders(bundleReq); InternalUtils.filterCapabilityPermissions(bundleCaps); Collection<RequiredBundle> result = new ArrayList<RequiredBundle>(); for (BundleCapability capability : bundleCaps) { BundleWiring wiring = capability.getRevision().getWiring(); if (wiring != null) { result.add(new RequiredBundleImpl(capability, wiring)); } } return result.isEmpty() ? null : result.toArray(new RequiredBundle[result.size()]); }
private void discardBundlesOnLoad() throws BundleException { Collection<Module> discarded = new ArrayList<Module>(0); 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)) { discarded.add(module); moduleContainer.uninstall(module); generation.delete(); } } if (!discarded.isEmpty()) { moduleContainer.refresh(discarded); } }
getRevisions().getContainer().checkAdminPermission(getBundle(), AdminPermission.EXECUTE); lockStateChange(ModuleEvent.STARTED); lockedStarted = true; getContainer().getAdaptor().initBegin(); checkValid(); if (ACTIVE_SET.contains(getState())) return; getRevisions().getContainer().open(); if (getState().equals(State.INSTALLED)) { ResolutionReport report; try { report = getRevisions().getContainer().resolve(Arrays.asList((Module) this), true); } finally { lockStateChange(ModuleEvent.STARTED); setState(State.RESOLVED); publishEvent(ModuleEvent.STOPPED); getRevisions().getContainer().close(); if (t instanceof BundleException) { throw (BundleException) t; getContainer().getAdaptor().initEnd(); if (lockedStarted) { unlockStateChange(ModuleEvent.STARTED);
result = findExistingDynamicWire(revision.getWiring(), dynamicPkgName); if (result != null) { return result; dynamicReqs = getDynamicRequirements(dynamicPkgName, revision); if (dynamicReqs.isEmpty()) { result = findExistingDynamicWire(wiring, dynamicPkgName); } while (!applyDelta(deltaWiring, modulesResolved, Collections.<Module> emptyList(), timestamp, false));
moduleDatabase.readLock(); try { checkSystemExtensionRefresh(initial); timestamp = moduleDatabase.getRevisionsTimestamp(); wiringCopy = moduleDatabase.getWiringsCopy(); refreshTriggers = new ArrayList<>(getRefreshClosure(initial, wiringCopy)); toRemoveRevisions = new ArrayList<>(); toRemoveWirings = new ArrayList<>(); refreshSystemModule(); return Collections.emptyList();
void setDebugOptions() { DebugOptions options = getAdaptor().getDebugOptions(); debugStartLevel = options == null ? false : options.getBooleanOption(Debug.OPTION_DEBUG_STARTLEVEL, false); }
@Override public void setInitialBundleStartLevel(int startlevel) { checkAdminPermission(getBundle(), AdminPermission.STARTLEVEL); if (startlevel < 1) { throw new IllegalArgumentException(Msg.ModuleContainer_NegativeStartLevelError + startlevel); } moduleDatabase.setInitialModuleStartLevel(startlevel); }
private Collection<Module> refreshMRJarBundles() throws BundleException { Collection<Module> mrJarBundles = new ArrayList<>(); for (Module m : moduleContainer.getModules()) { Generation generation = (Generation) m.getCurrentRevision().getRevisionInfo(); // Note that we check the raw headers here incase we are working off an old version of the persistent storage if (Boolean.parseBoolean(generation.getRawHeaders().get(BundleInfo.MULTI_RELEASE_HEADER))) { refresh(m); mrJarBundles.add(m); } } return mrJarBundles; }
@Override public Collection<Resource> getOndemandResources(Resource host) { String hostBSN = ((ModuleRevision) host).getSymbolicName(); if (hostBSN == null) { return Collections.emptyList(); } List<ModuleCapability> hostCaps = ((ModuleRevision) host).getModuleCapabilities(HostNamespace.HOST_NAMESPACE); if (hostCaps.isEmpty()) { return Collections.emptyList(); } ModuleCapability hostCap = hostCaps.get(0); String matchFilter = "(" + EquinoxFragmentNamespace.FRAGMENT_NAMESPACE + "=" + hostBSN + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ Requirement fragmentRequirement = ModuleContainer.createRequirement(EquinoxFragmentNamespace.FRAGMENT_NAMESPACE, Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, matchFilter), Collections.<String, Object> emptyMap()); List<ModuleCapability> candidates = moduleDatabase.findCapabilities(fragmentRequirement); // filter out disabled fragments and singletons filterDisabled(candidates.listIterator()); Collection<Resource> ondemandFragments = new ArrayList<Resource>(candidates.size()); for (Iterator<ModuleCapability> iCandidates = candidates.iterator(); iCandidates.hasNext();) { ModuleCapability candidate = iCandidates.next(); ModuleRequirement hostReq = candidate.getRevision().getModuleRequirements(HostNamespace.HOST_NAMESPACE).get(0); if (hostReq.matches(hostCap)) { ondemandFragments.add(candidate.getResource()); } } return ondemandFragments; }
getRevisions().getContainer().close(); } finally { AtomicReference<ContainerEvent> eventReference = forStop;
return applyDelta(deltaWiring, modulesResolved, triggers, timestamp, restartTriggers) ? report : null;
this.adaptor = new EquinoxContainerAdaptor(equinoxContainer, this, generations); this.moduleDatabase = new ModuleDatabase(this.adaptor); this.moduleContainer = new ModuleContainer(this.adaptor, this.moduleDatabase); if (data != null) { try {
getRevisions().getContainer().checkAdminPermission(getBundle(), AdminPermission.EXECUTE); lockStateChange(ModuleEvent.STARTED); lockedStarted = true; getContainer().getAdaptor().initBegin(); checkValid(); if (ACTIVE_SET.contains(getState())) return; getRevisions().getContainer().open(); if (getState().equals(State.INSTALLED)) { ResolutionReport report; try { report = getRevisions().getContainer().resolve(Collections.singletonList((Module) this), true); } finally { lockStateChange(ModuleEvent.STARTED); setState(State.RESOLVED); publishEvent(ModuleEvent.STOPPED); getRevisions().getContainer().close(); if (t instanceof BundleException) { throw (BundleException) t; getContainer().getAdaptor().initEnd(); if (lockedStarted) { unlockStateChange(ModuleEvent.STARTED);
result = findExistingDynamicWire(revision.getWiring(), dynamicPkgName); if (result != null) { return result; dynamicReqs = getDynamicRequirements(dynamicPkgName, revision); if (dynamicReqs.isEmpty()) { result = findExistingDynamicWire(wiring, dynamicPkgName); } while (!applyDelta(deltaWiring, modulesResolved, Collections.<Module> emptyList(), timestamp, false));
moduleDatabase.readLock(); try { checkSystemExtensionRefresh(initial); timestamp = moduleDatabase.getRevisionsTimestamp(); wiringCopy = moduleDatabase.getWiringsCopy(); refreshTriggers = new ArrayList<Module>(getRefreshClosure(initial, wiringCopy)); toRemoveRevisions = new ArrayList<ModuleRevision>(); toRemoveWirings = new ArrayList<ModuleWiring>(); refreshSystemModule(); return Collections.emptyList();
private void discardBundlesOnLoad() throws BundleException { Collection<Module> discarded = new ArrayList<Module>(0); 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)) { discarded.add(module); moduleContainer.uninstall(module); generation.delete(); } } if (!discarded.isEmpty()) { moduleContainer.refresh(discarded); } }
void setDebugOptions() { DebugOptions options = getAdaptor().getDebugOptions(); debugStartLevel = options == null ? false : options.getBooleanOption(Debug.OPTION_DEBUG_STARTLEVEL, false); }
@Override public void setInitialBundleStartLevel(int startlevel) { checkAdminPermission(getBundle(), AdminPermission.STARTLEVEL); if (startlevel < 1) { throw new IllegalArgumentException(Msg.ModuleContainer_NegativeStartLevelError + startlevel); } moduleDatabase.setInitialModuleStartLevel(startlevel); }