/**
   * Whether or not a component (either an application or a module) should be enabled is defined by
   * the "enable" attribute on both the application/module element and the application-ref element.
   *
   * @param config The dynamic ConfigContext
   * @param moduleName The name of the component
   * @return boolean
   */
  protected boolean isEnabled(ConfigContext config, String moduleName) {
    try {
      if (config == null) {
        config = AdminService.getAdminService().getAdminContext().getAdminConfigContext();
      }
      ConfigBean app = ApplicationHelper.findApplication(config, moduleName);
      Server server = ServerBeansFactory.getServerBean(config);
      ApplicationRef appRef = server.getApplicationRefByRef(moduleName);

      return ((app != null && app.isEnabled()) && (appRef != null && appRef.isEnabled()));
    } catch (ConfigException e) {
      _logger.log(Level.FINE, "Error in finding " + moduleName, e);

      // If there is anything wrong, do not enable the module
      return false;
    }
  }