@Test
 @Ignore("still working it out")
 public void testCallGetResourcesOnADifferentBundle() throws Exception {
   // find bundles
   Bundle[] bundles = bundleContext.getBundles();
   for (int i = 1; i < bundles.length; i++) {
     Bundle bundle = bundles[i];
     logger.debug(
         "calling #getResources on bundle " + OsgiStringUtils.nullSafeNameAndSymName(bundle));
     Enumeration enm = bundle.getResources(LOCATION);
     if (!OsgiBundleUtils.isFragment(bundle))
       assertNotNull(
           "bundle " + OsgiStringUtils.nullSafeNameAndSymName(bundle) + " contains no META-INF/",
           enm);
   }
 }
  public DelegatedExecutionOsgiBundleApplicationContext createApplicationContext(
      BundleContext bundleContext) throws Exception {
    Bundle bundle = bundleContext.getBundle();
    ApplicationContextConfiguration config = new BlueprintContainerConfig(bundle);
    String bundleName = OsgiStringUtils.nullSafeNameAndSymName(bundle);
    if (log.isTraceEnabled())
      log.trace("Created configuration " + config + " for bundle " + bundleName);

    // it's not a spring bundle, ignore it
    if (!config.isSpringPoweredBundle()) {
      if (log.isDebugEnabled())
        log.debug("No blueprint configuration found in bundle " + bundleName + "; ignoring it...");
      return null;
    }

    log.info(
        "Discovered configurations "
            + ObjectUtils.nullSafeToString(config.getConfigurationLocations())
            + " in bundle ["
            + bundleName
            + "]");

    DelegatedExecutionOsgiBundleApplicationContext sdoac =
        new OsgiBundleXmlApplicationContext(config.getConfigurationLocations());
    sdoac.setBundleContext(bundleContext);
    sdoac.setPublishContextAsService(config.isPublishContextAsService());

    return sdoac;
  }
Esempio n. 3
0
  /**
   * Invoked, when an event about bundle change is received. In case a new bundle gets installed or
   * an existing bundle is updated, we need to scan that bundle for MDS annotations and process
   * them.
   *
   * @param event BundleEvent, generated by the OSGi framework
   */
  @Override
  public void bundleChanged(BundleEvent event) {
    final Bundle bundle = event.getBundle();

    final int eventType = event.getType();

    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug(
          "Bundle event of type {} received from {}: {} -> {}",
          OsgiStringUtils.nullSafeBundleEventToString(event.getType()),
          bundle.getSymbolicName(),
          String.valueOf(eventType),
          String.valueOf(bundle.getState()));
    }

    handleBundleEvent(bundle, eventType);
  }
 private void startDependency(Bundle bundle) throws BundleException, InterruptedException {
   bundle.start();
   waitOnContextCreation(bundle.getSymbolicName());
   System.out.println("started bundle [" + OsgiStringUtils.nullSafeSymbolicName(bundle) + "]");
 }