Refine search
public void enableDynamicImports(Bundle bundle) { String location = String.format("wrap:%s$" + "Bundle-UpdateLocation=%s&" + "DynamicImport-Package=*&" + "%s=%s&" + "overwrite=merge", bundle.getLocation(), bundle.getLocation(), ORIGINAL_WIRES, explode(getWiredBundles(bundle).keySet())); LOG.debug(format("Updating %s with URL %s", bundle, location)); try { URL url = new URL(location); bundle.update(url.openStream()); bundleContext.getBundle(0).adapt(FrameworkWiring.class).refreshBundles(Collections.singleton(bundle)); } catch (Exception e) { throw new RuntimeException("Error enabling dynamic imports on bundle" + bundle.getBundleId(), e); } }
protected Object doExecute(List<Bundle> bundles) throws Exception { FrameworkWiring wiring = bundleContext.getBundle(0).adapt(FrameworkWiring.class); wiring.resolveBundles(bundles == null || bundles.isEmpty() ? null : bundles); return null; }
/** * @see org.apache.sling.installer.core.impl.util.BundleRefresher#isInstallerBundleAffected(java.util.List) */ public boolean isInstallerBundleAffected(final List<Bundle> bundles) { final long installerId = this.bundleContext.getBundle().getBundleId(); final Collection<Bundle> dependencyClosure = this.frameworkWiring.getDependencyClosure(bundles); for(final Bundle b : dependencyClosure) { if ( b.getBundleId() == installerId ) { return true; } } return false; }
String filter = (range != null ? "(&" : "") + "(" + IdentityNamespace.IDENTITY_NAMESPACE + "=" + symbolicName + ")" + (range != null ? range.toFilterString(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE) + ")" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ Requirement identityReq = ModuleContainer.createRequirement(IdentityNamespace.IDENTITY_NAMESPACE, Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter), Collections.<String, Object> emptyMap()); Collection<BundleCapability> identityCaps = container.getFrameworkWiring().findProviders(identityReq); Bundle b = capability.getRevision().getBundle(); if (symbolicName.equals(b.getSymbolicName()) && !sorted.contains(b)) { sorted.add(b);
private static void _startBundle(Bundle bundle, BundleContext bundleContext) throws Exception { Dictionary<String, String> headers = bundle.getHeaders( StringPool.BLANK); bundle.start(); if (!fragmentHost.equals(installedBundle.getSymbolicName())) { continue; defaultNoticeableFuture = new DefaultNoticeableFuture<>(); frameworkWiring.refreshBundles( Collections.singletonList(installedBundle), new FrameworkListener() {
if (b.getState() == Bundle.ACTIVE) { LOGGER.debug("CELLAR BUNDLE: stopping bundle {}/{} on node", symbolicName, version); stopBundle(symbolicName, version); } else if (b.getState() == Bundle.INSTALLED) { LOGGER.debug("CELLAR BUNDLE: resolving bundle {}/{} on node", symbolicName, version); getBundleContext().getBundle(0).adapt(FrameworkWiring.class).resolveBundles(Collections.singleton(b));
AtomicBoolean refreshFinished = refreshListener.getRefreshFinished(); Condition refreshFinishCondition = refreshListener.getRefreshFinishCondition(); frameworkWiring.refreshBundles(null, new FrameworkListener[] { refreshListener }); refreshFinishLock.unlock(); frameworkWiring.resolveBundles(null); Collection<Bundle> bundlesToStart = frameworkWiring.getDependencyClosure(installedBundlesWithStartFlag); if (bundle.getState() != Bundle.ACTIVE) { String fragmentHostHeader = bundle.getHeaders().get(Constants.FRAGMENT_HOST); if (fragmentHostHeader == null) { bundle.start();
protected Object doExecute(Bundle bundle) throws Exception { if (location != null) { update(bundle, location.toURL()); } else { String loc = bundle.getHeaders().get(Constants.BUNDLE_UPDATELOCATION); if (loc != null && !loc.equals(bundle.getLocation())) { update(bundle, new URL(loc)); } else { bundle.update(); } } if (refresh) { FrameworkWiring wiring = bundleContext.getBundle(0).adapt(FrameworkWiring.class); wiring.refreshBundles(null); } return null; }
Collection<BundleCapability> osgiPackages = moduleContainer.getFrameworkWiring().findProviders(osgiPackageReq); for (BundleCapability packageCapability : osgiPackages) { if (packageCapability.getRevision().getBundle().getBundleId() == 0) { Version v = (Version) packageCapability.getAttributes().get(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE); if (v != null) {
if (b.getState() == Bundle.ACTIVE) { LOGGER.debug("CELLAR BUNDLE: stopping bundle {}/{} on node", event.getSymbolicName(), event.getVersion()); stopBundle(event.getSymbolicName(), event.getVersion()); } else if (b.getState() == Bundle.INSTALLED) { LOGGER.debug("CELLAR BUNDLE: resolving bundle {}/{} on node", event.getSymbolicName(), event.getVersion()); getBundleContext().getBundle(0).adapt(FrameworkWiring.class).resolveBundles(Collections.singleton(b));
protected Object doExecute(List<Bundle> bundles) throws Exception { FrameworkWiring wiring = bundleContext.getBundle(0).adapt(FrameworkWiring.class); if (bundles == null || bundles.isEmpty()) { bundles = null; } wiring.refreshBundles(bundles); return null; }
public void update(String bundleId, String location, boolean refresh) throws MBeanException { try { List<Bundle> bundles = selectBundles(bundleId); if (location == null) { for (Bundle bundle : bundles) { bundle.update(); } return; } if (bundles.size() != 1) { throw new IllegalArgumentException("Provided bundle Id doesn't return any bundle or more than one bundle selected"); } InputStream is = new URL(location).openStream(); bundles.get(0).update(is); if (refresh) { FrameworkWiring wiring = bundleContext.getBundle(0).adapt(FrameworkWiring.class); wiring.refreshBundles(null); } } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
.adapt(FrameworkWiring.class).findProviders(req); Collection<BundleWiring> result = new ArrayList<BundleWiring>(1); // normally
public void refreshPackages(Bundle[] input) { container.getFrameworkWiring().refreshBundles(input == null ? null : Arrays.asList(input)); }
public boolean resolveBundles(Bundle[] bundles) { List<Bundle> list = (bundles == null) ? null : Arrays.asList(bundles); return m_felix.adapt(FrameworkWiring.class).resolveBundles(list); } }
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()]); }
public Collection<Bundle> getDependencyClosure(Collection<Bundle> bundles) { return container.getFrameworkWiring().getDependencyClosure(bundles); }
public Collection<Bundle> getRemovalPendingBundles() { return container.getFrameworkWiring().getRemovalPendingBundles(); }
String filter = (range != null ? "(&" : "") + "(" + IdentityNamespace.IDENTITY_NAMESPACE + "=" + symbolicName + ")" + (range != null ? range.toFilterString(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE) + ")" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ Requirement identityReq = ModuleContainer.createRequirement(IdentityNamespace.IDENTITY_NAMESPACE, Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter), Collections.<String, Object> emptyMap()); Collection<BundleCapability> identityCaps = container.getFrameworkWiring().findProviders(identityReq); Bundle b = capability.getRevision().getBundle(); if (symbolicName.equals(b.getSymbolicName()) && !sorted.contains(b)) { sorted.add(b);
if (b.getState() == Bundle.ACTIVE) { LOGGER.debug("CELLAR BUNDLE: stopping bundle {}/{} on node", symbolicName, version); stopBundle(symbolicName, version); } else if (b.getState() == Bundle.INSTALLED) { LOGGER.debug("CELLAR BUNDLE: resolving bundle {}/{} on node", symbolicName, version); getBundleContext().getBundle(0).adapt(FrameworkWiring.class).resolveBundles(Collections.singleton(b));