本文整理汇总了Java中org.osgi.framework.wiring.BundleCapability.getAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java BundleCapability.getAttributes方法的具体用法?Java BundleCapability.getAttributes怎么用?Java BundleCapability.getAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.framework.wiring.BundleCapability
的用法示例。
在下文中一共展示了BundleCapability.getAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PackageResource
import org.osgi.framework.wiring.BundleCapability; //导入方法依赖的package包/类
/**
* Constructor for package resource
*
* @param bundleCapability {@code BundleCapability} that this package is coming from
*/
public PackageResource(BundleCapability bundleCapability) {
super(PackageResourceManager.PACKAGE_PATH.addElements(uniqueCapabilityId(bundleCapability)));
m_bundleCapability = bundleCapability;
m_attributes = bundleCapability.getAttributes();
m_directives = bundleCapability.getDirectives();
m_packageName = (String) m_attributes.get(PACKAGE_NAMESPACE);
m_version = (Version) m_attributes.get(PACKAGE_VERSION_ATTRIBUTE);
calculateImporters();
// provider bundle
Bundle bundle = m_bundleCapability.getRevision().getBundle();
Path bundlePath = BundleResourceManager.getInstance().getPath().addElements(Long.toString(bundle.getBundleId()));
// Set relations
setRelations(
new DefaultRelation(bundlePath, Action.READ, PROVIDER_BUNDLE_NAME)
);
}
示例2: processBundleCapabilities
import org.osgi.framework.wiring.BundleCapability; //导入方法依赖的package包/类
private boolean processBundleCapabilities( Bundle bundle ) {
BundleWiring wiring = bundle.adapt( BundleWiring.class );
boolean foundPentahoWebPackageCapability = false;
if ( wiring != null ) {
List<BundleCapability> capabilities = wiring.getCapabilities( CAPABILITY_NAMESPACE );
if ( capabilities != null ) {
for ( BundleCapability bundleCapability : capabilities ) {
Map<String, Object> attributes = bundleCapability.getAttributes();
String root = (String) attributes.getOrDefault( "root", "" );
while ( root.endsWith( "/" ) ) {
root = root.substring( 0, root.length() - 1 );
}
try {
URL capabilityPackageJsonUrl = bundle.getResource( root + "/package.json" );
if ( capabilityPackageJsonUrl != null ) {
boolean didParsePackageJson = this.parsePackageInformation( bundle, capabilityPackageJsonUrl );
foundPentahoWebPackageCapability = foundPentahoWebPackageCapability || didParsePackageJson;
} else {
logger.warn( bundle.getSymbolicName() + " [" + bundle.getBundleId() + "]: " + root + "/package.json not found." );
}
} catch ( RuntimeException ignored ) {
logger.error( bundle.getSymbolicName() + " [" + bundle.getBundleId() + "]: Error parsing " + root + "/package.json." );
// throwing here would make everything fail
// what damage control should we do?
// **don't register this capability?** <-- this is what we're doing now
// ignore and use only the capability info?
// don't register all the bundle's capabilities?
}
}
}
}
return foundPentahoWebPackageCapability;
}
示例3: matches
import org.osgi.framework.wiring.BundleCapability; //导入方法依赖的package包/类
@Override
protected boolean matches(final BundleCapability capability, final Filter filter) {
Map<String, Object> attributes = capability.getAttributes();
return filter.matches(attributes);
}