當前位置: 首頁>>代碼示例>>Java>>正文


Java BundleWiring.getCapabilities方法代碼示例

本文整理匯總了Java中org.osgi.framework.wiring.BundleWiring.getCapabilities方法的典型用法代碼示例。如果您正苦於以下問題:Java BundleWiring.getCapabilities方法的具體用法?Java BundleWiring.getCapabilities怎麽用?Java BundleWiring.getCapabilities使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.osgi.framework.wiring.BundleWiring的用法示例。


在下文中一共展示了BundleWiring.getCapabilities方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cachePackageCapabilities

import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
/**
 * Caches the package capabilities that are needed for a set of interface classes
 */
private void cachePackageCapabilities(BundleContext context) {
    BundleWiring ourWiring = context.getBundle().adapt(BundleWiring.class);
    List<BundleCapability> ourExports = ourWiring.getCapabilities(PACKAGE_NAMESPACE);
    for (BundleCapability ourExport : ourExports) {
        String ourPkgName = (String) ourExport.getAttributes().get(PACKAGE_NAMESPACE);
        packageCapabilities.put(ourPkgName, ourExport);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:12,代碼來源:Activator.java

示例2: addingBundle

import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
@Override
public Bundle addingBundle(final Bundle bundle, final BundleEvent event) {
  BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
  List<BundleCapability> capabilities = bundleWiring.getCapabilities(namespace);
  for (BundleCapability bundleCapability : capabilities) {
    addingCapablility(bundleCapability);
  }

  Lock writeLock = readWriteLock.writeLock();
  writeLock.lock();
  availableCapabilities.addAll(capabilities);
  writeLock.unlock();

  return bundle;
}
 
開發者ID:everit-org,項目名稱:osgi-capability-collector,代碼行數:16,代碼來源:BundleCapabilityCollector.java

示例3: removedBundle

import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
@Override
public void removedBundle(final Bundle bundle, final BundleEvent event, final Bundle object) {
  BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
  List<BundleCapability> capabilities = bundleWiring.getCapabilities(namespace);

  Lock writeLock = readWriteLock.writeLock();
  writeLock.lock();
  availableCapabilities.removeAll(capabilities);
  writeLock.unlock();

  for (BundleCapability bundleCapability : capabilities) {
    removedCapability(bundleCapability);
  }
}
 
開發者ID:everit-org,項目名稱:osgi-capability-collector,代碼行數:15,代碼來源:BundleCapabilityCollector.java

示例4: getCapability

import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
private BundleCapability getCapability(BundleWiring wiring, String ns, String name) {
	List<BundleCapability> capabilities = wiring.getCapabilities(ns);
	for (BundleCapability capability : capabilities) {
		Object object = capability.getAttributes().get(ns);
		if (name.equals(object))
			return capability;
	}
	return null;
}
 
開發者ID:osgi,項目名稱:bundles,代碼行數:10,代碼來源:Guard.java

示例5: init

import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
@Override
  public void init() {
    BundleWiring wiring = this.bundle.adapt( BundleWiring.class );

    if ( wiring != null ) {
      List<BundleCapability> capabilities = wiring.getCapabilities( PentahoWebPackageService.CAPABILITY_NAMESPACE );
      capabilities.forEach( bundleCapability -> {
        Map<String, Object> attributes = bundleCapability.getAttributes();

        // for now using only the package.json information - so only the `root` attribute is mandatory
//        String name = (String) attributes.get( "name" );
//        Version version = (Version) attributes.get( "version" );
        String root = (String) attributes.getOrDefault( "root", "" );
        while ( root.endsWith( "/" ) ) {
          root = root.substring( 0, root.length() - 1 );
        }

        try {
          URL capabilityPackageJsonUrl = this.bundle.getResource( root + "/package.json" );
          if ( capabilityPackageJsonUrl != null ) {
            Map<String, Object> packageJson = parsePackageJson( capabilityPackageJsonUrl );

            String name = (String) packageJson.get( "name" );
            String version = (String) packageJson.get( "version" );

            if ( name != null && version != null ) {
              this.pentahoWebPackages.add( new PentahoWebPackageImpl( this.bundle, name, version, ( root.isEmpty() ? "/" : root ) ) );
            }
          } else {
            logger.warn( this.bundle.getSymbolicName() + " [" + this.bundle.getBundleId() + "]: " + root + "/package.json not found." );
          }
        } catch ( RuntimeException | ParseException | IOException ignored ) {
          logger.error( this.bundle.getSymbolicName() + " [" + this.bundle.getBundleId() + "]: Error parsing " + root + "/package.json." );

          // throwing will 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?
          // this is all post-bundle wiring phase, so only the requirejs configuration is affected
          // the bundle is started and nothing will change that... or should we bundle.stop()?
        }
      } );

      this.pentahoWebPackages.forEach( PentahoWebPackage::init );
    }
  }
 
開發者ID:pentaho,項目名稱:pentaho-osgi-bundles,代碼行數:48,代碼來源:PentahoWebPackageBundleImpl.java

示例6: processBundleCapabilities

import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的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;
}
 
開發者ID:pentaho,項目名稱:pentaho-osgi-bundles,代碼行數:42,代碼來源:RequireJsConfigManager.java


注:本文中的org.osgi.framework.wiring.BundleWiring.getCapabilities方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。