本文整理汇总了Java中org.osgi.framework.wiring.BundleWire类的典型用法代码示例。如果您正苦于以下问题:Java BundleWire类的具体用法?Java BundleWire怎么用?Java BundleWire使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BundleWire类属于org.osgi.framework.wiring包,在下文中一共展示了BundleWire类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: incompatibleExtender
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
private boolean incompatibleExtender(Bundle bundle) {
List<BundleWire> requiredWires = bundle.adapt(BundleWiring.class)
.getRequiredWires(OSGI_EXTENDER_NS);
for(BundleWire bw : requiredWires) {
BundleCapability capability = bw.getCapability();
if(EntityManagerFactoryBuilder.JPA_CAPABILITY_NAME.equals(
capability.getAttributes().get(OSGI_EXTENDER_NS))) {
// If the persistence bundle requires a different revision for the
// JPA extender then we are incompatible, otherwise we are
return !capability.getRevision().equals(wiring.getRevision());
}
}
// If there is no requirement then we must assume that it's safe
return false;
}
示例2: getJPAPackages
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
/**
* Get all the relevant packages that the EclipseLink JPA provider exports or persistence packages it uses itself. These are needed
* so that the woven proxy (for runtime enhancement) can be used later on :)
*
* Note that differently to OpenJPA the relevant classes are actually in more than just one bundle (org.eclipse.persistence.jpa and org.eclipse.persistence.core
* at the time of this writing). Hence, we have to take more than just the packages of the JPA provider bundle into account ...
*
* @param jpaBundle
* @return
*/
private String[] getJPAPackages(Bundle jpaBundle) {
Set<String> result = new HashSet<String>();
for (Bundle b : context.getBundles()) {
BundleWiring bw = b.adapt(BundleWiring.class);
if (bw == null) {
continue;
}
boolean isJpaBundle = b.equals(jpaBundle);
List<BundleWire> wires = bw.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE);
for (BundleWire w : wires) {
String pkgName = (String)w.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE);
boolean add = isJpaBundle || pkgName.startsWith("org.eclipse.persistence");
if (add) {
result.add(getPkg(b, pkgName));
}
}
}
result.add(getPkg(context.getBundle(), "org.apache.aries.jpa.eclipselink.adapter.platform"));
LOG.debug("Found JPA packages {}", result);
return result.toArray(new String[0]);
}
示例3: getInUseBundleWirings
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
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;
}
示例4: extenderCapabilityWired
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
private boolean extenderCapabilityWired(Bundle bundle) {
BundleWiring wiring = bundle.adapt(BundleWiring.class);
if (wiring == null) {
return true;
}
List<BundleWire> requiredWires = wiring.getRequiredWires(EXTENDER_NAMESPACE);
for (BundleWire requiredWire : requiredWires) {
if (CAMEL_EXTENDER.equals(requiredWire.getCapability().getAttributes().get(EXTENDER_NAMESPACE))) {
if (this.bundleId == requiredWire.getProviderWiring().getBundle().getBundleId()) {
LOG.debug("Camel extender requirement of bundle {} correctly wired to this implementation", bundle.getBundleId());
return true;
} else {
LOG.info("Not processing bundle {} as it requires a camel extender but is not wired to the this implementation", bundle.getBundleId());
return false;
}
}
}
return true;
}
示例5: prepareDependencies
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
private void prepareDependencies(final Bundle bundle) {
final BundleWiring wiring = bundle.adapt(BundleWiring.class);
final List<BundleWire> wires = wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
if (wires != null) {
for (final BundleWire wire : wires) {
try {
final Bundle dependency = wire.getProviderWiring().getBundle();
if (visited.add(dependency.getSymbolicName()) && hasComponents(dependency)) {
if (!live(dependency)) {
dependency.start();
}
if (live(dependency)) {
// pseudo-event to trigger bundle activation
addingBundle(dependency, null /* unused */);
}
}
}
catch (final Exception e) {
log.warn("MISSING {}", wire, e);
}
}
}
}
示例6: resolveWiredRequirements
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
private Collection<BundleRequirement> resolveWiredRequirements(final Bundle bundle) {
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
List<BundleRequirement> result = new ArrayList<>();
List<BundleWire> extenderWires =
bundleWiring.getRequiredWires(ExtenderNamespace.EXTENDER_NAMESPACE);
Bundle extenderBundle = context.getBundle();
for (BundleWire bundleWire : extenderWires) {
if (extenderBundle.equals(bundleWire.getProviderWiring().getBundle())) {
Map<String, Object> capabilityAttributes = bundleWire.getCapability().getAttributes();
if (ECMExtenderConstants.EXTENDER_SYMBOLIC_NAME
.equals(capabilityAttributes.get(ExtenderNamespace.EXTENDER_NAMESPACE))) {
BundleRequirement requirement = bundleWire.getRequirement();
result.add(requirement);
}
}
}
return result;
}
示例7: addingBundle
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
@Override
public Object addingBundle(Bundle bundle, BundleEvent event) {
// Get the wiring of the bundle.
BundleWiring wiring = Helper.getWiring(bundle);
// See it is wired to us as extender.
List<BundleWire> requirements = wiring.getRequiredWires("osgi.extender");
Context context = null;
if (requirements != null &&
requirements.stream().anyMatch((w) -> w.getProviderWiring().getBundle().equals(me))) {
// Create the stuff.
WeldContainer container = new WeldContainer(bundle);
Hashtable<String, Object> dict = new Hashtable<>();
dict.put(Constants.BUNDLE_SYMBOLICNAME, bundle.getSymbolicName());
String cat = bundle.getHeaders().get(Constants.BUNDLE_CATEGORY);
if (cat != null) {
dict.put(Constants.BUNDLE_CATEGORY, cat);
}
ServiceRegistration<BeanManager> reg = bundle.getBundleContext().registerService(BeanManager.class,
container.getManager(), dict);
context = new Context(container, reg);
}
return context;
}
示例8: getAncestorBundles
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
/**
* Retrieves the set of bundles from which given bundle depends.
*
* @param bundle
* target bundle
* @return set of ancestor bundles
*/
public static Set<Bundle> getAncestorBundles(Bundle bundle) {
BundleWiring wiring = bundle.adapt(BundleWiring.class);
// the set of bundles from which the bundle imports packages
Set<Bundle> exporters = new HashSet<Bundle>();
if (wiring != null) {
List<BundleWire> bundleWires = wiring.getRequiredWires(null);
if (bundleWires != null) {
for (BundleWire pkg : bundleWires) {
Bundle providerBundle = pkg.getProviderWiring().getBundle();
exporters.add(providerBundle);
}
}
}
return exporters;
}
示例9: calculateImporters
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
private void calculateImporters() {
importers.clear();
synchronized (importers) {
// calculate importers
Bundle bundle = m_bundleCapability.getRevision().getBundle();
if (bundle != null) {
BundleWiring wiring = bundle.adapt(BundleWiring.class);
if (wiring != null) {
List<BundleWire> wires = wiring.getProvidedWires(PACKAGE_NAMESPACE);
if (wires != null) {
for (BundleWire wire : wires) {
if (wire.getCapability().equals(m_bundleCapability)) {
Bundle requirerBundle = wire.getRequirerWiring().getBundle();
importers.add(requirerBundle);
}
}
}
}
}
}
}
示例10: start
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
@Override
public void start(final BundleContext bundleContext) throws Exception {
ProviderUtil.STARTUP_LOCK.lock();
lockingProviderUtil = true;
final BundleWiring self = bundleContext.getBundle().adapt(BundleWiring.class);
final List<BundleWire> required = self.getRequiredWires(LoggerContextFactory.class.getName());
for (final BundleWire wire : required) {
loadProvider(bundleContext, wire.getProviderWiring());
}
bundleContext.addBundleListener(this);
final Bundle[] bundles = bundleContext.getBundles();
for (final Bundle bundle : bundles) {
loadProvider(bundle);
}
unlockIfReady();
}
示例11: updateContext
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
private void updateContext(Bundle currentContext, String className) {
Bundle contextToSet = (currentContext == null) ? bundle : currentContext;
int idx = className.lastIndexOf('.');
String packageName = (idx == -1) ? "" : className.substring(0, idx);
BundleWiring wiring = contextToSet.adapt(BundleWiring.class);
for (BundleWire wire : wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE)) {
if (wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).equals(packageName)) {
contextToSet = wire.getProviderWiring().getBundle();
break;
}
}
currentLoadingBundle.get().push(contextToSet);
}
示例12: BundleWiringLastModified
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
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());
}
}
示例13: canSee
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
/**
* Check if bundle can see the given class
*/
protected boolean canSee(Bundle bundle, Class<?> clazz) {
if (bundle.getBundleId() == bundleId) {
// Need extra handling of camel core as it does not import the api
return true;
}
BundleCapability packageCap = packageCapabilities.get(clazz.getPackage().getName());
if (packageCap != null) {
BundleWiring wiring = bundle.adapt(BundleWiring.class);
List<BundleWire> imports = wiring.getRequiredWires(PACKAGE_NAMESPACE);
for (BundleWire importWire : imports) {
if (packageCap.equals(importWire.getCapability())) {
return true;
}
}
}
// it may be running outside real OSGi container such as when unit testing with camel-test-blueprint
// then we need to use a different canSee algorithm that works outside real OSGi
if (bundle.getBundleId() > 0) {
Bundle root = bundle.getBundleContext().getBundle(0);
if (root != null && "org.apache.felix.connect".equals(root.getSymbolicName())) {
return checkCompat(bundle, clazz);
}
}
return false;
}
示例14: toWiringString
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
public static String toWiringString(Bundle bundle){
String str = "";
BundleWiring bw = bundle.adapt(BundleWiring.class);
if (null != bw) {
for (BundleWire wire : bw.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE)) {
String packagee = (String) wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE);
Bundle b = wire.getProviderWiring().getBundle();
// str = str + "package: " + packagee + " bundle: " + b + "\n";
str = str + "package: " + packagee + " " + BundleDetailFragment.SCHEMA_PLUGIN + "://?id=" + b.getBundleId() + "\n";
}
}
return str;
}
示例15: getDependantBundles
import org.osgi.framework.wiring.BundleWire; //导入依赖的package包/类
private Collection<Bundle> getDependantBundles(Bundle bundle) {
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
List<BundleWire> bundleWires = bundleWiring.getRequiredWires(null);
HashSet<Bundle> bundles = new HashSet<Bundle>();
for (BundleWire bundleWire : bundleWires) {
bundles.add(bundleWire.getProvider().getBundle());
}
return bundles;
}