public static final boolean isJBoss4(Environment env) {
   if (env == null) {
     return false;
   }
   String hn = env.getHostApplicationName();
   String hv = env.getHostApplicationVersion();
   if (hn == null || hv == null) {
     return false;
   }
   return "JBoss".equals(hn) && hv.startsWith("4");
 }
  protected void loadConfig() throws Exception {
    Environment env = Environment.getDefault();
    if (env != null) {
      log.info("Configuration: host application: " + env.getHostApplicationName());
    } else {
      log.warn("Configuration: no host application");
    }

    File blacklistFile = new File(env.getConfig(), "blacklist");
    if (blacklistFile.isFile()) {
      List<String> lines = FileUtils.readLines(blacklistFile);
      Set<String> blacklist = new HashSet<String>();
      for (String line : lines) {
        line = line.trim();
        if (line.length() > 0) {
          blacklist.add(line);
        }
      }
      manager.setBlacklist(new HashSet<String>(lines));
    }

    String configDir = bundleContext.getProperty(PROP_CONFIG_DIR);
    if (configDir != null && configDir.contains(":/")) { // an url of a
      // config file
      log.debug("Configuration: " + configDir);
      URL url = new URL(configDir);
      log.debug("Configuration:   loading properties url: " + configDir);
      loadProperties(url);
      return;
    }

    if (env == null) {
      return;
    }

    // TODO: in JBoss there is a deployer that will deploy nuxeo
    // configuration files ..
    boolean isNotJBoss4 = !isJBoss4(env);

    File dir = env.getConfig();
    // File dir = new File(configDir);
    String[] names = dir.list();
    if (names != null) {
      Arrays.sort(
          names,
          new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
              return o1.compareToIgnoreCase(o2);
            }
          });
      for (String name : names) {
        if (name.endsWith("-config.xml") || name.endsWith("-bundle.xml")) {
          // TODO
          // because of some dep bugs (regarding the deployment of
          // demo-ds.xml)
          // we cannot let the runtime deploy config dir at
          // beginning...
          // until fixing this we deploy config dir from
          // NuxeoDeployer
          if (isNotJBoss4) {
            File file = new File(dir, name);
            log.debug("Configuration: deploy config component: " + name);
            context.deploy(file.toURI().toURL());
          }
        } else if (name.endsWith(".config")
            || name.endsWith(".ini")
            || name.endsWith(".properties")) {
          File file = new File(dir, name);
          log.debug("Configuration: loading properties: " + name);
          loadProperties(file);
        } else {
          log.debug("Configuration: ignoring: " + name);
        }
      }
    } else if (dir.isFile()) { // a file - load it
      log.debug("Configuration: loading properties: " + dir);
      loadProperties(dir);
    } else {
      log.debug("Configuration: no configuration file found");
    }

    loadDefaultConfig();
  }