Java 类org.osgi.framework.namespace.HostNamespace 实例源码

项目:osgi-jpms-layer    文件:LayerFactoryImpl.java   
private Set<BundleWiring> getInUseBundleWirings() {
    Set<BundleWiring> wirings = new HashSet<>();
    Collection<BundleCapability> bundles = fwkWiring.findProviders(ALL_BUNDLES_REQUIREMENT);
    for (BundleCapability bundleCap : bundles) {
        // Only pay attention to non JPMS boot modules.
        // NOTE this means we will not create a real JPMS Module or Layer for this bundle
        if (bundleCap.getAttributes().get(BOOT_JPMS_MODULE) == null) {
            BundleRevision revision = bundleCap.getRevision();
            BundleWiring wiring = revision.getWiring();
            if (wiring != null && wiring.isInUse()) {
                wirings.add(wiring);
            }
            if (revision.getBundle().getBundleId() == 0) {
                // also store the system.bundle fragments because they may have exports unknown to JPMS
                List<BundleWire> hostWires = wiring.getProvidedWires(HostNamespace.HOST_NAMESPACE);
                for (BundleWire hostWire : hostWires) {
                    wirings.add(hostWire.getRequirerWiring());
                }
            }
        }
    }
    return wirings;
}
项目:osgi-jpms-layer    文件:BundleWiringLastModified.java   
public BundleWiringLastModified(BundleWiring hostWiring) {
    // get the host last modified
    if (hostWiring.isCurrent()) {
        // use the current bundle id and last modified
        lastModifieds.put(hostWiring.getBundle().getBundleId(), hostWiring.getBundle().getLastModified());
    } else {
        // use a unique negative id to indicate not current
        lastModifieds.put(nextNotCurrentID.getAndDecrement(), hostWiring.getBundle().getLastModified());
    }
    for (BundleWire hostWire : hostWiring.getProvidedWires(HostNamespace.HOST_NAMESPACE)) {
        // Always use the fragment id and last modified.
        // It makes no difference if it is current or not because the host wiring indicates that. 
        lastModifieds.put(hostWire.getRequirer().getBundle().getBundleId(), hostWire.getRequirer().getBundle().getLastModified());
    }
}