org.osgi.framework.wiring.BundleRequirement Java Examples
The following examples show how to use
org.osgi.framework.wiring.BundleRequirement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override String getReqName(final BundleRequirement requirement) { final StringBuffer sb = new StringBuffer(50); final String filter = requirement.getDirectives().get("filter"); final String eeName = getFilterValue(filter, ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE); if (eeName != null) { sb.append(eeName); appendVersion(sb, requirement); } else { // Filter too complex to extract info from... sb.append(filter); } final BundleWiring reqWiring = requirement.getRevision().getWiring(); appendPendingRemovalOnRefresh(sb, reqWiring); return sb.toString(); }
Example #2
Source File: NPEfix8_eigth_t.java From coming with MIT License | 6 votes |
public List<BundleRequirement> getDeclaredRequirements(String namespace) { List<BundleRequirement> result = m_declaredReqs; if (namespace != null) { result = new ArrayList<BundleRequirement>(); for (BundleRequirement req : m_declaredReqs) { if (req.getNamespace().equals(namespace)) { result.add(req); } } } return result; }
Example #3
Source File: NPEfix8_eigth_s.java From coming with MIT License | 6 votes |
public List<BundleRequirement> getDeclaredRequirements(String namespace) { List<BundleRequirement> result = m_declaredReqs; if (namespace != null) { result = new ArrayList<BundleRequirement>(); for (BundleRequirement req : m_declaredReqs) { if (req.getNamespace().equals(namespace)) { result.add(req); } } } return result; }
Example #4
Source File: ResolverHooks.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
void filterMatches(BundleRequirement requirement , Collection<? extends BundleCapability> candidates) throws BundleException { if (hasHooks()) { @SuppressWarnings("unchecked") Collection<BundleCapability> c = new RemoveOnlyCollection<BundleCapability>((Collection<BundleCapability>) candidates); blockResolveForHooks(); try { for (TrackedResolverHookFactory rhf : active) { final ResolverHook rh = checkActiveRemoved(rhf); try { rh.filterMatches(requirement, c); } catch (RuntimeException re) { throw new BundleException("Resolver hook throw an exception, bid=" + rhf.bundle.getBundleId(), BundleException.REJECTED_BY_HOOK, re); } } } finally { unblockResolveForHooks(); } } }
Example #5
Source File: BundleRevisionImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
BundleRevisionDTO getDTO() { BundleRevisionDTO res = new BundleRevisionDTO(); res.symbolicName = gen.symbolicName; res.type = getTypes(); res.version = gen.version.toString(); res.bundle = gen.bundle.id; res.id = dtoId; res.capabilities = new ArrayList<CapabilityDTO>(); for (BundleCapability bc : getDeclaredCapabilities(null)) { res.capabilities.add(BundleCapabilityImpl.getDTO(bc, this)); } res.requirements = new ArrayList<RequirementDTO>(); for (BundleRequirement br : getDeclaredRequirements(null)) { res.requirements.add(BundleRequirementImpl.getDTO(br, this)); } return res; }
Example #6
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override String getReqName(final BundleRequirement requirement) { final StringBuffer sb = new StringBuffer(50); final String filter = requirement.getDirectives().get("filter"); final String pkgName = getFilterValue(filter, BundleRevision.PACKAGE_NAMESPACE); if (pkgName != null) { sb.append(pkgName); appendVersionAndResolutionDirective(sb, requirement); } else { sb.append(filter); } final BundleWiring reqWiring = requirement.getRevision().getWiring(); appendPendingRemovalOnRefresh(sb, reqWiring); return sb.toString(); }
Example #7
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void appendVersionAndResolutionDirective(final StringBuffer sb, final BundleRequirement requirement) { final String filter = requirement.getDirectives().get(Constants.FILTER_DIRECTIVE); try { final VersionRange vr = new VersionRange(filter, Constants.VERSION_ATTRIBUTE, true); sb.append(" "); sb.append(vr.toHtmlString()); } catch (final IllegalArgumentException iae) { System.err.println(iae.getMessage()); } final String resolution = requirement.getDirectives().get(Constants.RESOLUTION_DIRECTIVE); if (resolution != null && resolution.length() > 0) { if (resolution.equals(Constants.RESOLUTION_MANDATORY)) { // Default, don't print } else { sb.append(" "); sb.append(resolution); } } }
Example #8
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override String getReqName(final BundleRequirement requirement) { final StringBuffer sb = new StringBuffer(50); final String filter = requirement.getDirectives().get("filter"); final String bundleName = getFilterValue(filter, BundleRevision.BUNDLE_NAMESPACE); if (bundleName != null) { sb.append(bundleName); appendVersion(sb, requirement); } else { // Filter too complex to extract info from... sb.append(filter); } final BundleWiring reqWiring = requirement.getRevision().getWiring(); appendPendingRemovalOnRefresh(sb, reqWiring); return sb.toString(); }
Example #9
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override String getReqName(final BundleRequirement requirement) { final StringBuffer sb = new StringBuffer(50); final String filter = requirement.getDirectives().get("filter"); final String idName = getFilterValue(filter, IdentityNamespace.IDENTITY_NAMESPACE); if (idName != null) { sb.append(idName); appendVersionAndType(sb, requirement); } else { // Filter too complex to extract info from... sb.append(filter); } final BundleWiring reqWiring = requirement.getRevision().getWiring(); appendPendingRemovalOnRefresh(sb, reqWiring); return sb.toString(); }
Example #10
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void appendVersionAndType(final StringBuffer sb, final BundleRequirement requirement) { final String filter = requirement.getDirectives().get(Constants.FILTER_DIRECTIVE); try { final VersionRange vr = new VersionRange(filter, Constants.VERSION_ATTRIBUTE, false); sb.append(" "); sb.append(vr.toHtmlString()); } catch (final IllegalArgumentException iae) { } final String type = getFilterValue(filter, "type"); if (type != null) { sb.append(" "); sb.append(type); } }
Example #11
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override String getReqName(final BundleRequirement requirement) { final StringBuffer sb = new StringBuffer(50); final String filter = requirement.getDirectives().get("filter"); final String hostName = getFilterValue(filter, BundleRevision.HOST_NAMESPACE); if (hostName != null) { sb.append(hostName); appendVersion(sb, requirement); } else { // Filter too complex to extract info from... sb.append(filter); } final BundleWiring reqWiring = requirement.getRevision().getWiring(); appendPendingRemovalOnRefresh(sb, reqWiring); return sb.toString(); }
Example #12
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Present a generic requirement by showing its filter. * * @param requirement The requirement to present. * @return string presentation of the requirement. */ String getReqName(BundleRequirement requirement) { final StringBuffer sb = new StringBuffer(50); final String filter = requirement.getDirectives().get("filter"); if (filter != null) { sb.append(filter); } else { sb.append(" &emdash; "); } final BundleWiring reqWiring = requirement.getRevision().getWiring(); appendPendingRemovalOnRefresh(sb, reqWiring); return sb.toString(); }
Example #13
Source File: BundleImpl.java From concierge with Eclipse Public License 1.0 | 6 votes |
private MultiMap<String, BundleRequirement> parseRequirements( final String str) throws BundleException { final MultiMap<String, BundleRequirement> result = new MultiMap<String, BundleRequirement>(); if (str == null) { return result; } final String[] reqStrs = Utils.splitString(str, ','); for (int i = 0; i < reqStrs.length; i++) { final BundleRequirementImpl req = new BundleRequirementImpl( this, reqStrs[i]); final String namespace = req.getNamespace(); result.insert(namespace, req); } return result; }
Example #14
Source File: BundleImpl.java From concierge with Eclipse Public License 1.0 | 5 votes |
String getFragmentHost() { final List<BundleRequirement> hostReqs = requirements .get(HostNamespace.HOST_NAMESPACE); if (hostReqs == null) { return null; } return hostReqs.get(0).getDirectives() .get(HostNamespace.HOST_NAMESPACE); }
Example #15
Source File: ResolverHooks.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
boolean filterMatches(BundleRequirement requirement , BundleCapability candidate) throws BundleException { if (hasHooks()) { Collection<BundleCapability> c = new ShrinkableSingletonCollection<BundleCapability>(candidate); filterMatches(requirement, c); return !c.isEmpty(); } return true; }
Example #16
Source File: BundlePackages.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Get the list bundle requirements derived from the Require-Bundle header. * The bundle requirement objects for required bundles in the list has the * same order as the bundles in the Require-Bundle header. * * @return all defined require bundle requirements for this bundle revision. */ List<BundleRequirement> getDeclaredBundleRequirements() { final List<BundleRequirement> res = new ArrayList<BundleRequirement>(); if (require!=null) { final TreeSet<RequireBundle> rbCreationOrder = new TreeSet<RequireBundle>(require); res.addAll(rbCreationOrder); } return res; }
Example #17
Source File: BundleWireImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
BundleWireImpl(BundleCapability capability, BundleGeneration provider, BundleRequirement requirement, BundleGeneration requirer) { this.capability = capability; this.providerGen = provider; this.requirement = requirement; this.requirerGen = requirer; }
Example #18
Source File: BundleRequirementImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
static RequirementDTO getDTO(BundleRequirement br, BundleRevisionImpl bri) { RequirementDTO res = new RequirementDTO(); res.id = ((DTOId)br).dtoId; res.namespace = br.getNamespace(); res.directives = new HashMap<String, String>(br.getDirectives()); res.attributes = Util.safeDTOMap(br.getAttributes()); res.resource = bri.dtoId; return res; }
Example #19
Source File: BundleRequirementImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public String toString() { final StringBuffer sb = new StringBuffer(40); sb.append("[") .append(BundleRequirement.class.getName()) .append(": ") .append(namespace) .append(" directives: ") .append(directives.toString()) .append("]"); return sb.toString(); }
Example #20
Source File: BundleRevisionImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
List<RequirementRefDTO> getRequirementRefDTOs() { List<RequirementRefDTO> res = new ArrayList<RequirementRefDTO>(); for (BundleRequirement br : getDeclaredRequirements(null)) { res.add(BundleRequirementImpl.getRefDTO(br, this)); } return res; }
Example #21
Source File: Resources.java From concierge with Eclipse Public License 1.0 | 5 votes |
public List<BundleRequirement> getRequirements(final String namespace) { if (!isInUse()) { return null; } return namespace == null ? requirements.getAllValues() : requirements.lookup(namespace); }
Example #22
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void appendVersion(final StringBuffer sb, final BundleRequirement requirement) { final String filter = requirement.getDirectives().get(Constants.FILTER_DIRECTIVE); try { final VersionRange vr = new VersionRange(filter, Constants.BUNDLE_VERSION_ATTRIBUTE, true); sb.append(" "); sb.append(vr.toHtmlString()); } catch (final IllegalArgumentException iae) { System.err.println(iae.getMessage()); } }
Example #23
Source File: BundleImpl.java From concierge with Eclipse Public License 1.0 | 5 votes |
void refresh() { // iterate over old and current revisions for (final BundleRevision brev : revisions) { final Revision rev = (Revision) brev; if (rev.wiring != null) { rev.wiring.cleanup(); rev.wiring = null; } } revisions.clear(); if (currentRevision != null) { revisions.add(currentRevision); // detach fragments (if any) and reset classloader currentRevision.refresh(); // remove from framework wirings framework.wirings.remove(currentRevision); // clear and restore dynamic imports currentRevision.dynamicImports.clear(); for (final BundleRequirement req : currentRevision.requirements .lookup(PackageNamespace.PACKAGE_NAMESPACE)) { if (PackageNamespace.RESOLUTION_DYNAMIC .equals(req.getDirectives().get( Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE))) { currentRevision.dynamicImports.add(req); } } } }
Example #24
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void appendVersion(final StringBuffer sb, final BundleRequirement requirement) { final String filter = requirement.getDirectives().get(Constants.FILTER_DIRECTIVE); try { final VersionRange vr = new VersionRange(filter, Constants.VERSION_ATTRIBUTE, true); sb.append(" "); sb.append(vr.toHtmlString()); } catch (final IllegalArgumentException iae) { System.err.println(iae.getMessage()); } }
Example #25
Source File: WiringHTMLDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void appendVersion(final StringBuffer sb, final BundleRequirement requirement) { final String filter = requirement.getDirectives().get(Constants.FILTER_DIRECTIVE); try { final VersionRange vr = new VersionRange(filter, Constants.BUNDLE_VERSION_ATTRIBUTE, true); sb.append(" "); sb.append(vr.toHtmlString()); } catch (final IllegalArgumentException iae) { System.err.println(iae.getMessage()); } }
Example #26
Source File: Concierge.java From concierge with Eclipse Public License 1.0 | 4 votes |
List<BundleCapability> resolveDynamic(final BundleRevision trigger, final String pkg, final String dynImportPackage, final BundleRequirement dynImport, final boolean multiple) { Collection<Capability> candidates = null; try { if (resolver.hooks == null) { resolver.hooks = getResolverHooks(Arrays.asList(trigger)); } final String filterStr = dynImport.getDirectives() .get(Namespace.REQUIREMENT_FILTER_DIRECTIVE); if (multiple) { // we have a wildcard, this means scanning candidates = capabilityRegistry .getAll(PackageNamespace.PACKAGE_NAMESPACE); } else { // we don't have a wildcard, use the index if (filterStr == null) { candidates = capabilityRegistry.getByValue( PackageNamespace.PACKAGE_NAMESPACE, dynImportPackage); } else { try { candidates = RFC1960Filter.filterWithIndex(dynImport, filterStr, capabilityRegistry); } catch (final InvalidSyntaxException e) { e.printStackTrace(); } } } if (candidates == null || candidates.isEmpty()) { endResolverHooks(resolver.hooks); return null; } filterCandidates(resolver.hooks.keySet(), dynImport, candidates); final ArrayList<BundleCapability> matches = new ArrayList<BundleCapability>(); for (final Capability cap : candidates) { final String candidatePackage = (String) cap.getAttributes() .get(PackageNamespace.PACKAGE_NAMESPACE); assert candidatePackage != null; if (multiple && RFC1960Filter.stringCompare(pkg.toCharArray(), 0, candidatePackage.toCharArray(), 0) != 0) { continue; } if (cap instanceof BundleCapability && Concierge.matches0( PackageNamespace.PACKAGE_NAMESPACE, dynImport, cap, filterStr)) { // we have a match // FIXME: cleanup... if (((BundleCapability) cap).getRevision().getBundle() .getState() == Bundle.INSTALLED) { // need to resolve first if (!resolve( Collections.singletonList( ((BundleCapability) cap).getRevision()), false)) { continue; } } matches.add((BundleCapability) cap); } } endResolverHooks(resolver.hooks); Collections.sort(matches, EXPORT_ORDER); return matches; } catch (final Throwable t) { // TODO: handle return null; } finally { resolver.hooks = null; } }
Example #27
Source File: ClassLoaderOsgiFramework.java From vespa with Apache License 2.0 | 4 votes |
@Override public List<BundleRequirement> getDeclaredRequirements(String p1) { throw new UnsupportedOperationException(); }
Example #28
Source File: ClassLoaderOsgiFramework.java From vespa with Apache License 2.0 | 4 votes |
@Override public List<BundleRequirement> getRequirements(String p1) { throw new UnsupportedOperationException(); }
Example #29
Source File: BundleImpl.java From concierge with Eclipse Public License 1.0 | 4 votes |
/** * @see org.osgi.framework.wiring.BundleRevision#getDeclaredRequirements(java.lang.String) * @category BundleRevision */ public List<BundleRequirement> getDeclaredRequirements( final String namespace) { return namespace == null ? requirements.getAllValues() : requirements.lookup(namespace); }
Example #30
Source File: MockBundle.java From vespa with Apache License 2.0 | 4 votes |
@Override public List<BundleRequirement> getRequirements(String p1) { throw new UnsupportedOperationException(); }