当前位置: 首页>>代码示例>>Java>>正文


Java BundleCapability类代码示例

本文整理汇总了Java中org.osgi.framework.wiring.BundleCapability的典型用法代码示例。如果您正苦于以下问题:Java BundleCapability类的具体用法?Java BundleCapability怎么用?Java BundleCapability使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BundleCapability类属于org.osgi.framework.wiring包,在下文中一共展示了BundleCapability类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: incompatibleExtender

import org.osgi.framework.wiring.BundleCapability; //导入依赖的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;
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:20,代码来源:PersistenceBundleTracker.java

示例2: WrappingTransformer

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
public WrappingTransformer(ClassTransformer delegate, ServiceReference<?> persistenceProvider) {
    validate(delegate, persistenceProvider);
    this.delegate = delegate;

    Object packages = persistenceProvider.getProperty("org.apache.aries.jpa.container.weaving.packages");
    if (packages instanceof String[]) {
        for (String s : (String[])packages) {
            packageImportsToAdd.add(s);
        }
    } else {
        Bundle provider = persistenceProvider.getBundle();
        String suffix = ";" + Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" + provider.getSymbolicName()
                        + ";" + Constants.BUNDLE_VERSION_ATTRIBUTE + "=" + provider.getVersion();

        BundleRevision br = provider.adapt(BundleWiring.class).getRevision();
        for (BundleCapability bc : br.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE)) {
            packageImportsToAdd.add(bc.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE) + suffix);
        }
    }
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:21,代码来源:WrappingTransformer.java

示例3: createExportPackage

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
static BundlePackage createExportPackage(BundleCapability packageCap) {
	String name = (String) packageCap.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
	if (name == null) {
		return null;
	}
	Set<String> friendsSet = Collections.emptySet();
	String friendsDir = packageCap.getDirectives().get("x-friends");
	if (friendsDir != null) {
		String[] friends = friendsDir == null ? new String[0] : friendsDir.split(",");
		for (int i = 0; i < friends.length; i++) {
			friends[i] = friends[i].trim();
		}
		// did not use Set.of(E...) because of bad meta-data that can have duplicate friends
		friendsSet = new HashSet<>(Arrays.asList(friends));
	}
	return new BundlePackage(name, friendsSet);
}
 
开发者ID:tjwatson,项目名称:osgi-jpms-layer,代码行数:18,代码来源:BundlePackage.java

示例4: getInUseBundleWirings

import org.osgi.framework.wiring.BundleCapability; //导入依赖的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;
}
 
开发者ID:tjwatson,项目名称:osgi-jpms-layer,代码行数:24,代码来源:LayerFactoryImpl.java

示例5: addWebPackageBundle

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
@Test
public void addWebPackageBundle() {
  List<BundleCapability> capabilities = new ArrayList<>();
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1a" ) );
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1b" ) );
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1c" ) );
  Bundle bundle = this.createMockWebPackageBundle( capabilities, "pentaho-webpackage-1", "1.0", Bundle.ACTIVE );

  ArgumentCaptor<ResourceMapping> resourceMappingCaptor = ArgumentCaptor.forClass( ResourceMapping.class );

  this.service.addBundle( bundle );

  verify( bundle.getBundleContext(), times( 3 ) ).registerService( eq( ResourceMapping.class.getName() ), resourceMappingCaptor.capture(), any() );

  List<ResourceMapping> capturedResourceMappings = resourceMappingCaptor.getAllValues();

  assertResourceMappingExists( capturedResourceMappings, "/pentaho-webpackage-1a", "/package-name-1a/1.0" );
  assertResourceMappingExists( capturedResourceMappings, "/pentaho-webpackage-1b", "/package-name-1b/1.1" );
  assertResourceMappingExists( capturedResourceMappings, "/pentaho-webpackage-1c", "/package-name-1c/1.2" );
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:21,代码来源:PentahoWebPackageServiceImplTest.java

示例6: addSameWebPackageBundle

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
@Test
public void addSameWebPackageBundle() {
  List<BundleCapability> capabilities = new ArrayList<>();
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1a" ) );
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1b" ) );
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1c" ) );
  Bundle bundle = this.createMockWebPackageBundle( capabilities, "pentaho-webpackage-1", "1.0", Bundle.ACTIVE );

  ArgumentCaptor<ResourceMapping> resourceMappingCaptor = ArgumentCaptor.forClass( ResourceMapping.class );

  this.service.addBundle( bundle );

  reset( bundle.getBundleContext() );

  this.service.addBundle( bundle );

  verify( bundle.getBundleContext(), times( 0 ) ).registerService( eq( ResourceMapping.class.getName() ), resourceMappingCaptor.capture(), any() );
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:19,代码来源:PentahoWebPackageServiceImplTest.java

示例7: addWebPackageBundleWithMissingPackageJson

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
@Test
public void addWebPackageBundleWithMissingPackageJson() {
  List<BundleCapability> capabilities = new ArrayList<>();
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1a" ) );
  capabilities.add( createMockWebPackageCapability( "/missing-package-json" ) );
  Bundle bundle = this.createMockWebPackageBundle( capabilities, "pentaho-webpackage-1", "1.0", Bundle.ACTIVE );

  ArgumentCaptor<ResourceMapping> resourceMappingCaptor = ArgumentCaptor.forClass( ResourceMapping.class );

  this.service.addBundle( bundle );

  verify( bundle.getBundleContext(), times( 1 ) ).registerService( eq( ResourceMapping.class.getName() ), resourceMappingCaptor.capture(), any() );

  List<ResourceMapping> capturedResourceMappings = resourceMappingCaptor.getAllValues();

  assertResourceMappingExists( capturedResourceMappings, "/pentaho-webpackage-1a", "/package-name-1a/1.0" );
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:18,代码来源:PentahoWebPackageServiceImplTest.java

示例8: addWebPackageBundleWithInvalidPackageJson

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
@Test
public void addWebPackageBundleWithInvalidPackageJson() {
  List<BundleCapability> capabilities = new ArrayList<>();
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1a" ) );
  capabilities.add( createMockWebPackageCapability( "/invalid" ) );
  Bundle bundle = this.createMockWebPackageBundle( capabilities, "pentaho-webpackage-1", "1.0", Bundle.ACTIVE );

  ArgumentCaptor<ResourceMapping> resourceMappingCaptor = ArgumentCaptor.forClass( ResourceMapping.class );

  this.service.addBundle( bundle );

  verify( bundle.getBundleContext(), times( 1 ) ).registerService( eq( ResourceMapping.class.getName() ), resourceMappingCaptor.capture(), any() );

  List<ResourceMapping> capturedResourceMappings = resourceMappingCaptor.getAllValues();

  assertResourceMappingExists( capturedResourceMappings, "/pentaho-webpackage-1a", "/package-name-1a/1.0" );
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:18,代码来源:PentahoWebPackageServiceImplTest.java

示例9: removeWebPackageBundle

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
@Test
public void removeWebPackageBundle() {
  List<BundleCapability> capabilities = new ArrayList<>();
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1a" ) );
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1b" ) );
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-1c" ) );
  Bundle bundle = this.createMockWebPackageBundle( capabilities, "pentaho-webpackage-1", "1.0", Bundle.ACTIVE );

  this.service.addBundle( bundle );

  this.service.removeBundle( bundle );

  verify( this.serviceRegistrationMap.get( "/pentaho-webpackage-1a" ), times( 1 ) ).unregister();
  verify( this.serviceRegistrationMap.get( "/pentaho-webpackage-1b" ), times( 1 ) ).unregister();
  verify( this.serviceRegistrationMap.get( "/pentaho-webpackage-1c" ), times( 1 ) ).unregister();
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:17,代码来源:PentahoWebPackageServiceImplTest.java

示例10: testBundleChangedNewWebPackageBundle

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
@Test
public void testBundleChangedNewWebPackageBundle() throws IOException, ParseException {
  List<BundleCapability> capabilities = new ArrayList<>();
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-2a" ) );
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-2b" ) );
  capabilities.add( createMockWebPackageCapability( "/pentaho-webpackage-2c" ) );
  Bundle mockBundle = this.createMockWebPackageBundle( capabilities, "pentaho-webpackage-2", "1.0", Bundle.ACTIVE );

  this.requireJsConfigManager.bundleChanged( mockBundle );

  // check that invalidateCachedConfigurations is called
  verify( this.requireJsConfigManager, times( 1 ) ).invalidateCachedConfigurations();

  String config = this.requireJsConfigManager.getRequireJsConfig( this.baseUrl );
  // dirty quick check if the lib is in the require configuration
  // proper testing is done on the pentaho-requirejs-utils module
  assertTrue( config.contains( "pentaho-webpackage-2a_1.0" ) );
  assertTrue( config.contains( "pentaho-webpackage-2b_1.1" ) );
  assertTrue( config.contains( "pentaho-webpackage-2c_1.2" ) );
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:21,代码来源:RequireJsConfigManagerTest.java

示例11: createMockWebPackageBundle

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
private Bundle createMockWebPackageBundle( List<BundleCapability> capabilities, String bundleName, String bundleVersion, int bundleState ) {
  final Bundle mockBundle = this.createMockBundle( bundleName, bundleVersion, bundleState );

  BundleWiring wiring = mock( BundleWiring.class );

  List<BundleCapability> bundleCapabilities = new ArrayList<>();

  capabilities.forEach( bundleCapability -> {
    bundleCapabilities.add( bundleCapability );

    String root = bundleCapability.getAttributes().get( "root" ).toString();
    while ( root.endsWith( "/" ) ) {
      root = root.substring( 0, root.length() - 1 );
    }
    when( mockBundle.getResource( root + "/package.json" ) ).thenReturn( this.getClass().getClassLoader().getResource( "org/pentaho/js/require/" + root + "-package.json" ) );
  } );

  when( wiring.getCapabilities( RequireJsConfigManager.CAPABILITY_NAMESPACE ) ).thenReturn( bundleCapabilities );

  when( mockBundle.adapt( BundleWiring.class ) ).thenReturn( wiring );

  return mockBundle;
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:24,代码来源:RequireJsConfigManagerTest.java

示例12: testStateMaskCheck

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
@Test
public void testStateMaskCheck() {
  new BundleCapabilityCollector(context, TEST_NAMESPACE, EMPTY_REQUIREMENTS,
      new TestCapabilityConsumer<BundleCapability>(), Bundle.RESOLVED);
  new BundleCapabilityCollector(context, TEST_NAMESPACE, EMPTY_REQUIREMENTS,
      new TestCapabilityConsumer<BundleCapability>(), Bundle.STARTING);
  new BundleCapabilityCollector(context, TEST_NAMESPACE, EMPTY_REQUIREMENTS,
      new TestCapabilityConsumer<BundleCapability>(), Bundle.ACTIVE);
  new BundleCapabilityCollector(context, TEST_NAMESPACE, EMPTY_REQUIREMENTS,
      new TestCapabilityConsumer<BundleCapability>(), Bundle.STOPPING);
  new BundleCapabilityCollector(context, TEST_NAMESPACE, EMPTY_REQUIREMENTS,
      new TestCapabilityConsumer<BundleCapability>(), Bundle.STOPPING | Bundle.ACTIVE
          | Bundle.STARTING);

  try {
    new BundleCapabilityCollector(context, TEST_NAMESPACE, EMPTY_REQUIREMENTS,
        new TestCapabilityConsumer<BundleCapability>(), Bundle.INSTALLED);
    Assert.fail("Exception should have been thrown");
  } catch (RuntimeException e) {
    // Right behavior
  }
}
 
开发者ID:everit-org,项目名称:osgi-capability-collector,代码行数:23,代码来源:BundleCapabilityCollectorTest.java

示例13: getAPICapabilities

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
/**
 * Returns all capabilities published by the core plugin that are associated with the Hobson API.
 *
 * @return an array of Capability objects (or null if a bundle lookup failure occurred)
 */
protected Capability[] getAPICapabilities() {
    Bundle coreBundle = FrameworkUtil.getBundle(getClass());
    if (coreBundle != null) {
        List<Capability> apiCapabilities = new ArrayList<>();
        BundleRevision revision = coreBundle.adapt(BundleRevision.class);
        List<BundleCapability> caps = revision.getDeclaredCapabilities(null);
        for (BundleCapability bc : caps) {
            Object pkgName = bc.getAttributes().get("osgi.wiring.package");
            Object version = bc.getAttributes().get("bundle-version");
            if (pkgName != null && version != null && pkgName.toString().startsWith("com.whizzosoftware.hobson.api")) {
                apiCapabilities.add(new HobsonApiCapability(pkgName.toString(), version.toString()));
            }
        }
        return apiCapabilities.toArray(new Capability[apiCapabilities.size()]);
    }
    return null;
}
 
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:23,代码来源:OSGIRepoPluginListSource.java

示例14: addPackagesFrom

import org.osgi.framework.wiring.BundleCapability; //导入依赖的package包/类
public void addPackagesFrom(Bundle bundle) {
    synchronized (m_packageResourceByPackageIdMap) {
        BundleRevision revision = bundle.adapt(BundleRevision.class);
        if (revision != null) {
            List<BundleCapability> bundleCapabilities = revision.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
            if (!bundleCapabilities.isEmpty()) {
                for (BundleCapability bc : bundleCapabilities) {
                    PackageResource packageResource = new PackageResource(bc);
                    String uniquePackageId = packageResource.getUniquePackageId();
                    PackageResource oldPackage = m_packageResourceByPackageIdMap.put(uniquePackageId, packageResource);
                    if (oldPackage != null) {
                        Everest.postResource(ResourceEvent.UPDATED, packageResource);
                    } else {
                        Everest.postResource(ResourceEvent.CREATED, packageResource);
                    }
                }
            }
        }
    }
}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:21,代码来源:PackageResourceManager.java

示例15: 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)
    );

}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:25,代码来源:PackageResource.java


注:本文中的org.osgi.framework.wiring.BundleCapability类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。