/** DOC ycbai Comment method "initializeSystemLibs". */
 public void initializeSystemLibs() {
   if (!initialized) {
     ILibraryManagerService libManagerService = null;
     if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
       libManagerService =
           (ILibraryManagerService)
               GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
     }
     for (IConfigurationElement current : configurationElements) {
       String bundleName = current.getContributor().getName();
       Bundle bundle = Platform.getBundle(bundleName);
       Enumeration entryPaths = bundle.getEntryPaths(LIB_FOLDER);
       if (entryPaths == null) {
         continue;
       }
       while (entryPaths.hasMoreElements()) {
         Object entryPath = entryPaths.nextElement();
         if (entryPath != null && entryPath instanceof String) {
           String path = (String) entryPath;
           if (path.endsWith(FileExtensions.JAR_FILE_SUFFIX)) {
             URL entry = bundle.getEntry(path);
             if (entry != null && libManagerService != null) {
               try {
                 URL fileUrl = FileLocator.toFileURL(entry);
                 libManagerService.deploy(fileUrl.toURI());
               } catch (Exception e) {
                 log.warn("Cannot deploy: " + bundleName + path);
                 continue;
               }
             }
           }
         }
       }
     }
     initialized = true;
   }
 }
  /**
   * look for all the required modules for a given bundle, and let the user decide to download it.
   * this method is blocked until the dialog box is closed.
   *
   * @param jarMissingEvent, must never be null
   */
  protected void showMissingModuleDialog(final JarMissingEvent jarMissingEvent) {
    if (allModulesNeededExtensionsForPlugin == null) {
      this.allModulesNeededExtensionsForPlugin =
          ModulesNeededProvider.getAllModulesNeededExtensionsForPlugin();
    }
    List<ModuleNeeded> requiredModulesForBundle =
        ModulesNeededProvider.filterRequiredModulesForBundle(
            jarMissingEvent.getBundleSymbolicName(), allModulesNeededExtensionsForPlugin);
    final List<String> requiredJars = new ArrayList<String>(requiredModulesForBundle.size());
    // filter the jar that are already installed
    for (ModuleNeeded module : requiredModulesForBundle) {
      String moduleName = module.getModuleName();
      // if jar does not exist at expected folder then check if it is registered in the Studio
      if (!new File(jarMissingEvent.getExpectedLibFolder(), moduleName).exists()) {
        // check that library is already available and registered but not deployed to lib/java.
        try {
          if (librariesService != null
              && (librariesService.getLibraryStatus(moduleName)
                  == ELibraryInstallStatus.INSTALLED)) {
            // lib exist so deploy it
            List<ModuleNeeded> allModuleNeeded =
                ModulesNeededProvider.getModulesNeededForName(moduleName);
            for (ModuleNeeded sameModule : allModuleNeeded) {
              String moduleLocation = sameModule.getModuleLocaion();
              if (sameModule.getStatus() == ELibraryInstallStatus.INSTALLED
                  && moduleLocation != null
                  && !moduleLocation.isEmpty()) {
                URI uri = new URI(moduleLocation);
                URL url = FileLocator.toFileURL(uri.toURL());
                if ("file".equals(url.getProtocol())) { // $NON-NLS-1$
                  libraryManagerService.deploy(url.toURI(), null);
                } // else not a file so keep going
                break;
              } // else not an installed module or no url so keep so keep looking
            }
          } // else no installed so keep going and ask the user
        } catch (BusinessException e) {
          log.warn("Could not get installade status for library:" + moduleName, e);
        } catch (URISyntaxException e) {
          log.warn("Could not get installade status for library:" + moduleName, e);
        } catch (IOException e) {
          log.warn("Could not get installade status for library:" + moduleName, e);
        }
      }
      if (!new File(jarMissingEvent.getExpectedLibFolder(), moduleName).exists()) {
        requiredJars.add(moduleName);
      } // else jar already installed to filter it by ignoring it.
    }
    if (!requiredJars.isEmpty()) {
      Display.getDefault()
          .syncExec(
              new Runnable() {

                @Override
                public void run() {
                  ExternalModulesInstallDialogWithProgress dialog =
                      new ExternalModulesInstallDialogWithProgress(
                          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                          Messages.getString(
                              "ExternalModulesInstallDialog_Title_Missing_jars_for_plugin"), //$NON-NLS-1$
                          Messages.getString(
                              "ExternalModulesInstallDialog_description_jars_to_be_installed_in"),
                          SWT.APPLICATION_MODAL); //$NON-NLS-1$
                  dialog.showDialog(true, requiredJars.toArray(new String[requiredJars.size()]));
                }
              });
    } // else there is not extension point defining the required bundles so do not ask the user
      // ignor.
  }