예제 #1
0
  /**
   * Expand the temporary extensionNames map of pointid-classname to full pointid-classobject. <br>
   * This has to be done after the fact because when the pointid-classnames are parsed, the module's
   * objects aren't fully realized yet and so not all classes can be loaded. <br>
   * <br>
   *
   * @return a list of full Extension objects
   */
  private List<Extension> expandExtensionNames() {
    ModuleClassLoader moduleClsLoader = ModuleFactory.getModuleClassLoader(this);
    if (moduleClsLoader == null) {
      log.debug(
          String.format(
              "Module class loader is not available, maybe the module %s is stopped/stopping",
              getName()));
    } else if (extensions.size() != extensionNames.size()) {
      for (Map.Entry<String, String> entry : extensionNames.entrySet()) {
        String point = entry.getKey();
        String className = entry.getValue();
        log.debug("expanding extension names: " + point + " : " + className);
        try {
          Class<?> cls = moduleClsLoader.loadClass(className);
          Extension ext = (Extension) cls.newInstance();
          ext.setPointId(point);
          ext.setModuleId(this.getModuleId());
          extensions.add(ext);
          log.debug("Added extension: " + ext.getExtensionId() + " : " + ext.getClass());
        } catch (NoClassDefFoundError e) {
          log.warn("Unable to find class definition for extension: " + point, e);
        } catch (ClassNotFoundException e) {
          log.warn("Unable to load class for extension: " + point, e);
        } catch (IllegalAccessException e) {
          log.warn("Unable to load class for extension: " + point, e);
        } catch (InstantiationException e) {
          log.warn("Unable to load class for extension: " + point, e);
        }
      }
    }

    return extensions;
  }