/*
   * (non-Javadoc)
   *
   * @see org.araqne.bundle.BundleManager#uninstallBundle(long)
   */
  @Override
  public boolean uninstallBundle(long bundleId) {
    Bundle bundle = context.getBundle(bundleId);
    if (bundle == null) {
      logger.warn(String.format("bundle %d not found.", bundleId));
      return false;
    }

    try {
      String downloadRoot = getDownloadRoot();

      String prefix = getPrefix();

      File bundleLocation = new File(bundle.getLocation().replace(prefix, ""));

      // prevents destruction out of the download directory.
      // delete cached bundle in download directory for redownloading
      if (bundle.getLocation().startsWith(prefix + downloadRoot)) {
        File bundleDirectory = new File(bundleLocation.getParent());
        bundleLocation.delete();
        deleteDirectory(bundleDirectory);
      }
      bundle.uninstall();
      return true;
    } catch (BundleException e) {
      logger.error(e.getMessage());
      return false;
    }
  }
	public void testInstallAtLocation() throws BundleException, MalformedURLException, IOException {
		// create disconnected test regions
		Region r1 = digraph.createRegion(getName() + ".1");
		Region r2 = digraph.createRegion(getName() + ".2");

		String location = bundleInstaller.getBundleLocation(PP1);
		Bundle b1 = null;
		Bundle b2 = null;
		String l1 = null;
		String l2 = null;
		try {
			URL url = new URL(location);
			b1 = r1.installBundle(location + ".1", url.openStream());
			l1 = b1.getLocation();
			b2 = r2.installBundleAtLocation(location + ".2", url.openStream());
			l2 = b2.getLocation();
		} finally {
			if (b1 != null) {
				try {
					b1.uninstall();
				} catch (BundleException e) {
					// ignore
				}
			}
			if (b2 != null) {
				try {
					b2.uninstall();
				} catch (BundleException e) {
					// ignore
				}
			}
		}
		assertEquals("Wrong location found.", location + ".1#" + r1.getName(), l1);
		assertEquals("Wrong location found.", location + ".2", l2);
	}
Beispiel #3
0
 @Override
 public Object execute() throws Exception {
   List<Exception> exceptions = new ArrayList<Exception>();
   List<Bundle> bundles = new ArrayList<Bundle>();
   for (String url : urls) {
     try {
       bundles.add(bundleContext.installBundle(url, null));
     } catch (Exception e) {
       exceptions.add(new Exception("Unable to install bundle " + url, e));
     }
   }
   if (start) {
     for (Bundle bundle : bundles) {
       try {
         bundle.start();
       } catch (Exception e) {
         exceptions.add(new Exception("Unable to start bundle " + bundle.getLocation(), e));
       }
     }
   }
   if (bundles.size() == 1) {
     System.out.println("Bundle ID: " + bundles.get(0).getBundleId());
   } else {
     StringBuffer sb = new StringBuffer("Bundle IDs: ");
     for (Bundle bundle : bundles) {
       if (sb.length() > 0) {
         sb.append(", ");
       }
       sb.append(bundle.getBundleId());
     }
     System.out.println(sb);
   }
   MultiException.throwIf("Error installing bundles", exceptions);
   return null;
 }
  /*
   * (non-Javadoc)
   *
   * @see org.araqne.bundle.BundleManager#getBundleLocation(long)
   */
  @Override
  public String getBundleLocation(long bundleId) {
    Bundle bundle = context.getBundle(bundleId);
    if (bundle == null) throw new IllegalStateException("bundle not found: " + bundleId);

    return bundle.getLocation();
  }
 private void installBundle(ZipFile zipFile, List<String> bundles, Application application) {
   for (String location : AtlasConfig.DELAY) {
     String mLocation = contains(bundles, location.replace(".", "_"));
     if (mLocation != null && mLocation.length() > 0) {
       installBundle(zipFile, mLocation, application);
       bundles.remove(mLocation);
     }
   }
   for (String location : bundles) {
     installBundle(zipFile, location, application);
   }
   if (isTargetApp) {
     String[] auto = AtlasConfig.AUTO;
     for (String location : auto) {
       Bundle bundle = OpenAtlas.getInstance().getBundle(location);
       if (bundle != null) {
         try {
           bundle.start();
         } catch (Throwable e) {
           Log.e("BundlesInstaller", "Could not auto start bundle: " + bundle.getLocation(), e);
         }
       }
     }
   }
 }
Beispiel #6
0
  @Override
  public File getBundleFile(Bundle bundle) {
    File file;
    String location = bundle.getLocation();
    String vendor = Framework.getProperty(Constants.FRAMEWORK_VENDOR);
    String name = bundle.getSymbolicName();

    if ("Eclipse".equals(vendor)) { // equinox framework
      log.debug("getBundleFile (Eclipse): " + name + "->" + location);
      return getEclipseBundleFileUsingReflection(bundle);
    } else if (location.startsWith("file:")) { // nuxeo osgi adapter
      try {
        file = FileUtils.urlToFile(location);
      } catch (MalformedURLException e) {
        log.error(
            "getBundleFile: Unable to create " + " for bundle: " + name + " as URI: " + location);
        return null;
      }
    } else { // may be a file path - this happens when using
      // JarFileBundle (for ex. in nxshell)
      file = new File(location);
    }
    if (file != null && file.exists()) {
      log.debug("getBundleFile: " + name + " bound to file: " + file);
      return file;
    } else {
      log.debug("getBundleFile: " + name + " cannot bind to nonexistent file: " + file);
      return null;
    }
  }
Beispiel #7
0
  /** {@inheritDoc}. */
  @SuppressWarnings("unchecked")
  @Override
  public List<Map<String, Object>> getServices(String applicationID) {
    List<Map<String, Object>> services =
        configAdminExt.listServices(getDefaultFactoryLdapFilter(), getDefaultLdapFilter());
    List<Map<String, Object>> returnValues = new ArrayList<Map<String, Object>>();
    BundleContext context = getContext();

    if (!services.isEmpty()) {
      Application app = appService.getApplication(applicationID);
      MetaTypeService metatypeService = getMetaTypeService();

      if (app != null) {
        try {
          Set<BundleInfo> bundles = app.getBundles();

          Set<String> bundleLocations = new HashSet<String>();
          Set<MetaTypeInformation> metatypeInformation = new HashSet<MetaTypeInformation>();
          for (BundleInfo info : bundles) {
            bundleLocations.add(info.getLocation());
          }

          for (Bundle bundle : context.getBundles()) {
            for (BundleInfo info : bundles) {
              if (info.getLocation().equals(bundle.getLocation())) {
                metatypeInformation.add(metatypeService.getMetaTypeInformation(bundle));
              }
            }
          }

          for (Map<String, Object> service : services) {
            if (service.containsKey("configurations")) {
              List<Map<String, Object>> configurations =
                  (List<Map<String, Object>>) service.get("configurations");
              for (Map<String, Object> item : configurations) {
                if (item.containsKey("bundle_location")) {
                  String bundleLocation = (String) item.get("bundle_location");
                  if (bundleLocations.contains(bundleLocation)) {
                    returnValues.add(service);
                    break;
                  }
                }
              }
            } else {
              if (checkForMetaTypesForService(metatypeInformation, service)) {
                returnValues.add(service);
              }
            }
          }

        } catch (ApplicationServiceException e) {
          LOGGER.warn("There was an error while trying to access the application", e);
          return new ArrayList<Map<String, Object>>();
        }
      }
    }

    return returnValues;
  }
  private StringBuffer printBundleHeaderLine(Bundle bundle, StringBuffer buffer) {
    buffer.append(Long.toString(bundle.getBundleId())).append(',');
    buffer.append(bundle.getHeaders().get(Constants.BUNDLE_SYMBOLICNAME)).append(',');
    buffer.append(bundle.getLocation()).append(',');
    buffer.append(printBundleState(bundle));

    return buffer;
  }
Beispiel #9
0
  public static String getBundleName(Bundle b) {
    String s = getHeader(b, "Bundle-Name", "");
    if (s == null || "".equals(s) || s.startsWith("%")) {
      s = shortLocation(b.getLocation());
    }

    return s;
  }
Beispiel #10
0
  public String getPath() {

    String path = null;
    if (artifact != null) {
      path = artifact.getPath();
    } else {
      path = bundle.getLocation();
    }
    return path;
  }
  /**
   * Retrieves a reference to the Gibberish bundle, stops it and uninstalls it and then reinstalls
   * it in order to make sure that accounts are not reloaded once removed.
   *
   * @throws java.lang.Exception if something goes wrong while manipulating the bundles.
   */
  public void testAccountUninstallationPersistence() throws Exception {
    Bundle providerBundle = GibberishSlickFixture.providerBundle;

    providerBundle.stop();

    assertTrue(
        "Couldn't stop the protocol provider bundle. State was " + providerBundle.getState(),
        Bundle.ACTIVE != providerBundle.getState() && Bundle.STOPPING != providerBundle.getState());

    providerBundle.uninstall();

    assertEquals(
        "Couldn't stop the protocol provider bundle.",
        Bundle.UNINSTALLED,
        providerBundle.getState());

    // Now reinstall the bundle and restart the provider
    providerBundle = GibberishSlickFixture.bc.installBundle(providerBundle.getLocation());

    assertEquals(
        "Couldn't re-install protocol provider bundle.",
        Bundle.INSTALLED,
        providerBundle.getState());

    AccountManagerUtils.startBundleAndWaitStoredAccountsLoaded(
        GibberishSlickFixture.bc, providerBundle, "Gibberish");
    assertEquals(
        "Couldn't re-start protocol provider bundle.", Bundle.ACTIVE, providerBundle.getState());

    // verify that the provider is not reinstalled
    ServiceReference[] gibberishProviderRefs = null;
    try {
      gibberishProviderRefs =
          GibberishSlickFixture.bc.getServiceReferences(
              ProtocolProviderService.class.getName(),
              "(" + ProtocolProviderFactory.PROTOCOL + "=Gibberish)");
    } catch (InvalidSyntaxException ex) {
      fail("We apparently got our filter wrong " + ex.getMessage());
    }

    // make sure we didn't retrieve a service
    assertTrue(
        "A Gibberish Protocol Provider Service was still regged "
            + "as an osgi service after it was explicitly uninstalled",
        gibberishProviderRefs == null || gibberishProviderRefs.length == 0);

    // and a nasty hack at the end - delete the configuration file so that
    // we get a fresh start on next run.
    ServiceReference confReference =
        GibberishSlickFixture.bc.getServiceReference(ConfigurationService.class.getName());
    ConfigurationService configurationService =
        (ConfigurationService) GibberishSlickFixture.bc.getService(confReference);

    configurationService.purgeStoredConfiguration();
  }
Beispiel #12
0
  private boolean skipBundle(Bundle bundle) {
    // we skip the generated entities bundle, MDS bundle and the framework bundle
    if (MdsBundleHelper.isMdsBundle(bundle)
        || MdsBundleHelper.isMdsEntitiesBundle(bundle)
        || MdsBundleHelper.isFrameworkBundle(bundle)) {
      return true;
    }

    // we also skip bundles which locations start with "link:", as these are pax exam bundles, which
    // we
    // encounter only during tests. Maybe in some distant future, support for resolving these
    // locations will be
    // added, but there is no need to do it right now.
    if (startsWith(bundle.getLocation(), "link:") || startsWith(bundle.getLocation(), "local")) {
      return true;
    }

    // finally we skip bundles that don't have an MDS dependency
    return !MdsBundleHelper.isBundleMdsDependent(bundle);
  }
  private boolean isLocalJar(Bundle bundle) {
    File location = new File(bundle.getLocation().replace("file://", ""));
    File araqneDownload = new File(System.getProperty("araqne.download.dir"));

    while (location.getParentFile() != null) {
      if (location.equals(araqneDownload)) return false;
      location = location.getParentFile();
    }

    return true;
  }
 @Test
 public void testInstallBundle() throws Exception {
   // Test symbolic location
   JavaArchive archive = getBundleArchiveA();
   Bundle bundle = installBundle("/symbolic/location", toInputStream(archive));
   try {
     assertBundleState(Bundle.INSTALLED, bundle.getState());
     assertEquals("/symbolic/location", bundle.getLocation());
   } finally {
     bundle.uninstall();
     assertBundleState(Bundle.UNINSTALLED, bundle.getState());
   }
 }
  private void fireEvent(final long bundleId, final int eventType) {
    final Bundle bundle = Mockito.mock(Bundle.class);
    Mockito.when(bundle.getSymbolicName()).thenReturn("some_id");
    Mockito.when(bundle.getLocation()).thenReturn("some_location");
    Mockito.when(bundle.getBundleId()).thenReturn(bundleId);

    final BundleEvent event = Mockito.mock(BundleEvent.class);
    Mockito.when(event.getBundle()).thenReturn(bundle);
    Mockito.when(event.getType()).thenReturn(eventType);

    final BundleEventLogger logger = new BundleEventLogger();
    logger.bundleChanged(event);
  }
  @Override
  public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
    String alias = (String) object;

    log.log(
        LogService.LOG_INFO,
        "Unregistering HTTP servlet under alias "
            + alias
            + " for JAX-RS resources in bundle "
            + bundle.getLocation());

    httpService.unregister(alias);
  }
  @Override
  protected Object doExecute() throws Exception {
    s_logger.info("[Group = {}] , [Name = {}], [Options = {}]", m_group, m_name, m_options);

    Bundle bundle = getBundle(m_group, m_name);

    if (bundle == null) {
      System.err.println(
          "Apollo bundle is not found. [Group = " + m_group + "] , [Name = " + m_name + "]");

    } else {
      System.out.println("---------------------Base---------------------");
      System.out.println("[Location = " + bundle.getLocation() + "]");
      System.out.println("[Bundle ID = " + bundle.getBundleId() + "]");
      System.out.println("[Symbolic Name = " + bundle.getSymbolicName() + "]");

      if (m_options != null) {
        if (m_options.contains("import")) {
          System.out.println("\n---------------------Import-Package---------------------");
          String ips = (String) bundle.getHeaders().get("Import-Package");
          if (ips != null) {
            for (String ip : ips.split("\",")) {
              System.out.println(ip);
            }
          }
        }

        if (m_options.contains("export")) {
          System.out.println("\n---------------------Export-Package---------------------");
          String eps = (String) bundle.getHeaders().get("Export-Package");
          if (eps != null) {
            for (String ep : eps.split("\",")) {
              System.out.println(ep);
            }
          }
        }

        if (m_options.contains("provide")) {
          System.out.println("\n---------------------Provide-Capability---------------------");
          String rcs = (String) bundle.getHeaders().get("Provide-Capability");
          for (String rc : rcs.split(",")) {
            System.out.println(rc);
          }
        }
      }
    }

    System.out.println("");

    return null;
  }
Beispiel #18
0
 /**
  * Check if a bundle object corresponds to a resource.
  *
  * <p>Equality is tested on
  *
  * <ol>
  *   <li>location,
  *   <li>bundle symbolic name and version for resources without location.
  * </ol>
  *
  * @param bundle The bundle to test.
  * @param resource The resource to compare the bundle to.
  */
 static boolean isBundleFromResource(Bundle bundle, Resource resource) {
   final String resourceLoc = Util.getLocation(resource);
   if (bundle.getLocation().equals(resourceLoc)) {
     return true;
   }
   if (resourceLoc == null) {
     final String bsn = getResourceName(resource);
     if (bsn.equals(bundle.getSymbolicName())) {
       final Version version = getResourceVersion(resource);
       return bundle.getVersion().equals(version);
     }
   }
   return false;
 }
Beispiel #19
0
  /*
   * Launches against the agent
   */
  public void testSimpleLauncher() throws Exception {
    Project project = workspace.getProject("p1");
    Run bndrun = new Run(workspace, project.getBase(), project.getFile("one.bndrun"));
    bndrun.setProperty("-runpath", "biz.aQute.remote.launcher");
    bndrun.setProperty("-runbundles", "bsn-1,bsn-2");
    bndrun.setProperty("-runremote", "test");

    final RemoteProjectLauncherPlugin pl =
        (RemoteProjectLauncherPlugin) bndrun.getProjectLauncher();
    pl.prepare();
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicInteger exitCode = new AtomicInteger(-1);

    List<? extends RunSession> sessions = pl.getRunSessions();
    assertEquals(1, sessions.size());

    final RunSession session = sessions.get(0);

    Thread t =
        new Thread("test-launch") {
          public void run() {
            try {
              exitCode.set(session.launch());
            } catch (Exception e) {
              e.printStackTrace();
            } finally {
              latch.countDown();
            }
          }
        };
    t.start();
    Thread.sleep(500);

    for (Bundle b : context.getBundles()) {
      System.out.println(b.getLocation());
    }
    assertEquals(4, context.getBundles().length);
    String p1 = t1.getAbsolutePath();
    System.out.println(p1);

    assertNotNull(context.getBundle(p1));
    assertNotNull(context.getBundle(t2.getAbsolutePath()));

    pl.cancel();
    latch.await();

    assertEquals(-3, exitCode.get());

    bndrun.close();
  }
  @Override
  public void uninstallBundle(long bundleId) throws BundleException {
    Bundle bundle = getBundle(bundleId);
    bundle.uninstall();

    try {
      boolean deleted = bundleDirectoryManager.removeBundle(bundle);
      if (!deleted) {
        LOG.warn("Failed to delete bundle file: " + bundle.getLocation());
      }
    } catch (IOException e) {
      throw new MotechException("Error while removing bundle file", e);
    }
  }
Beispiel #21
0
 @Override
 public void exec(String args, PrintStream out, PrintStream err) throws Exception {
   Bundle[] bundles = m_context.getBundles();
   out.println("  ID      State      Name");
   for (Bundle bundle : bundles) {
     printBundle(
         bundle.getBundleId(),
         getStateString(bundle.getState()),
         bundle.getHeaders().get(Constants.BUNDLE_NAME),
         bundle.getLocation(),
         bundle.getSymbolicName(),
         out);
   }
 }
  private ServletContainer processBundle(Bundle bundle, String applicationName) {
    Application application = null;
    try {
      Class<?> applicationClass = bundle.loadClass(applicationName);
      application = (Application) applicationClass.newInstance();
    } catch (Exception e) {
      log.log(
          LogService.LOG_ERROR,
          "Error loading application class "
              + applicationName
              + " from bundle "
              + bundle.getLocation(),
          e);
    }

    return new ServletContainer(ResourceConfig.forApplication(application));
  }
  private Properties createBundleProperties(Bundle bundle) {
    Properties props = new Properties();

    props.setProperty("id", Long.toString(bundle.getBundleId()));
    props.setProperty("state", printBundleState(bundle));
    props.setProperty("location", bundle.getLocation());
    props.setProperty("lastModified", Long.toString(bundle.getLastModified()));

    Dictionary headers = bundle.getHeaders();
    for (Enumeration keys = headers.keys(); keys.hasMoreElements(); ) {
      String key = (String) keys.nextElement();
      Object value = headers.get(key);
      if (value != null) props.setProperty(key, value.toString());
    }

    return props;
  }
  /*
   * (non-Javadoc)
   *
   * @see org.araqne.bundle.BundleManager#updateBundle(long)
   */
  @Override
  public void updateBundle(long bundleId) {
    Bundle bundle = context.getBundle(bundleId);
    if (bundle == null) {
      logger.warn(String.format("bundle %d not found", bundleId));
      throw new IllegalStateException("bundle " + bundleId + " not found");
    }

    try {
      if (!isLocalJar(bundle)) {
        try {
          File before = new File(bundle.getLocation().replace("file://", ""));
          if (before.exists()) {
            File temp = File.createTempFile(before.getName(), "", before.getParentFile());
            temp.delete();
            if (before.renameTo(temp)) {
              MavenResolver resolver =
                  new MavenResolver(
                      getLocalRepository(), config.getRepositories(), null, getKeyStoreManager());
              MavenArtifact artifact = getArtifact(bundle);
              File after = resolver.resolve(artifact);
              if (after.exists()) temp.delete();
              else temp.renameTo(before);
            }
          } else {
            before.getParentFile().mkdirs();
            MavenResolver resolver =
                new MavenResolver(
                    getLocalRepository(), config.getRepositories(), null, getKeyStoreManager());
            MavenArtifact artifact = getArtifact(bundle);
            resolver.resolve(artifact);
          }
        } catch (MavenResolveException e) {
          logger.error("araqne core: maven resolve failed.", e);
          throw new RuntimeException("maven resolve failed. (" + e.getMessage() + ")");
        } catch (IOException e) {
          logger.error("araqne core: create temp file failed.", e);
          throw new RuntimeException("create temp file failed.");
        }
      }
      bundle.update();
    } catch (BundleException e) {
      logger.error("araqne core: updating bundle failed.", e);
    }
  }
Beispiel #25
0
  private Map<String, Object> marshal(Bundle b) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ");

    Map<String, Object> m = new HashMap<String, Object>();
    m.put("id", b.getBundleId());
    m.put("name", b.getSymbolicName());
    m.put("version", b.getHeaders().get("Bundle-Version"));
    m.put("vendor", b.getHeaders().get("Bundle-Vendor"));
    m.put("last_modified", dateFormat.format(new Date(b.getLastModified())));
    m.put("location", b.getLocation());
    m.put("export_package", b.getHeaders().get("Export-Package"));
    m.put("import_package", b.getHeaders().get("Import-Package"));
    m.put("built_by", b.getHeaders().get("Built-By"));
    m.put("license", b.getHeaders().get("Bundle-License"));
    m.put("url", b.getHeaders().get("Bundle-DocURL"));
    m.put("status", getBundleState(b.getState()));
    return m;
  }
 /*
  * Copy the bundle with the given id to the specified location. (location
  * is parent directory)
  */
 public void copyBundle(String bundlename, File source, File destination) throws IOException {
   if (destination == null) destination = output;
   destination = new File(destination, "eclipse/plugins");
   if (source == null) {
     Bundle bundle = TestActivator.getBundle(bundlename);
     if (bundle == null) {
       throw new IOException("Could not find: " + bundlename);
     }
     String location = bundle.getLocation();
     if (location.startsWith("reference:")) location = location.substring("reference:".length());
     source = new File(FileLocator.toFileURL(new URL(location)).getFile());
   }
   destination = new File(destination, source.getName());
   if (destination.exists()) return;
   FileUtils.copy(source, destination, new File(""), false);
   // if the target of the copy doesn't exist, then signal an error
   assertTrue("Unable to copy " + source + " to " + destination, destination.exists());
 }
  public void processAutoStartBundles(
      ZipFile zipFile, List<String> bundles, Application application) {

    for (String location : bundles) {
      installBundle(zipFile, location, application);
    }
    if (isTargetApp) {
      for (String location : AtlasConfig.AUTO) {
        Bundle bundle = OpenAtlas.getInstance().getBundle(location);
        if (bundle != null) {
          try {
            bundle.start();
          } catch (Throwable e) {
            Log.e("BundlesInstaller", "Could not auto start bundle: " + bundle.getLocation(), e);
          }
        }
      }
    }
  }
  private MavenArtifact getArtifact(Bundle bundle) {
    File location = new File(bundle.getLocation().replace("file://", ""));
    File araqneDownload = new File(System.getProperty("araqne.download.dir"));

    String groupId = null;
    String artifactId = null;
    Version version = null;
    while (location.getParentFile() != null) {
      location = location.getParentFile();
      if (location.equals(araqneDownload)) break;

      String name = location.getName();
      if (version == null) version = new Version(name);
      else if (artifactId == null) artifactId = name;
      else if (groupId == null) groupId = name;
      else groupId = name + "." + groupId;
    }

    return new MavenArtifact(groupId, artifactId, version);
  }
  /*
   Parses a <properties entry="<url>"/>
   and then reads a property specified by <url>
  */
  private static void setProperties(Config compConf, XmlPullParser parser, Bundle declaringBundle)
      throws IllegalXMLException, XmlPullParserException, IOException {
    String entry = null;

    for (int i = 0; i < parser.getAttributeCount(); i++) {
      if (parser.getAttributeName(i).equals("entry")) {
        entry = parser.getAttributeValue(i);
      } else {
        unrecognizedAttr(parser, i); // throws exception
      }
    }

    if (entry == null) {
      missingAttr(parser, "entry"); // throws exception
    }

    // read a property-file and adds it contents to conf's properties.
    Properties dict = new Properties();
    String bundleLocation = declaringBundle.getLocation();

    JarInputStream jis = new JarInputStream(new URL(bundleLocation).openStream());
    ZipEntry zipEntry;

    while ((zipEntry = jis.getNextEntry()) != null && !zipEntry.getName().equals(entry))
      /* skip */ ;

    if (zipEntry == null) {
      throw new IOException("Did not find requested entry " + entry);
    }

    dict.load(jis);

    for (Enumeration e = dict.keys(); e.hasMoreElements(); ) {
      Object key = e.nextElement();
      compConf.setProperty((String) key, dict.get(key));
    }

    // done reading file.

    skip(parser);
  }
Beispiel #30
0
 /**
  * Get short name of specified bundle. First, try to get the BUNDLE-NAME header. If it fails use
  * the location of the bundle with all characters upto and including the last '/' or '\' and any
  * trailing ".jar" stripped off.
  *
  * @param bundle the bundle
  * @return The bundles shortname or null if input was null
  */
 public static String shortName(Bundle bundle) {
   if (bundle == null) {
     return null;
   }
   String n = (String) bundle.getHeaders().get("Bundle-Name");
   if (n == null) {
     n = bundle.getLocation();
     int x = n.lastIndexOf('/');
     int y = n.lastIndexOf('\\');
     if (y > x) {
       x = y;
     }
     if (x != -1) {
       n = n.substring(x + 1);
     }
     if (n.endsWith(".jar")) {
       n = n.substring(0, n.length() - 4);
     }
   }
   return n;
 }