本文整理匯總了Java中org.osgi.framework.wiring.BundleWiring.getRequiredWires方法的典型用法代碼示例。如果您正苦於以下問題:Java BundleWiring.getRequiredWires方法的具體用法?Java BundleWiring.getRequiredWires怎麽用?Java BundleWiring.getRequiredWires使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osgi.framework.wiring.BundleWiring
的用法示例。
在下文中一共展示了BundleWiring.getRequiredWires方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: extenderCapabilityWired
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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;
}
示例2: prepareDependencies
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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);
}
}
}
}
示例3: resolveWiredRequirements
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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;
}
示例4: addingBundle
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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;
}
示例5: getAncestorBundles
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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;
}
示例6: start
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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();
}
示例7: updateContext
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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);
}
示例8: canSee
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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;
}
示例9: toWiringString
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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;
}
示例10: getDependantBundles
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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;
}
示例11: getWiredBundles
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
protected Set<Bundle> getWiredBundles(Bundle bundle) {
BundleWiring wiring = bundle.adapt(BundleWiring.class);
// the set of bundles from which the bundle imports packages
Set<Bundle> exporters = new HashSet<Bundle>();
for (BundleWire pkg : wiring.getRequiredWires(null)) {
Bundle providerBundle = pkg.getProviderWiring().getBundle();
exporters.add(providerBundle);
}
return exporters;
}