Ejemplo n.º 1
0
  /**
   * 创建组件库集
   *
   * @return repository目录下组件库集
   */
  public static List<Repository> createRepositories() throws ContainerException {

    // 默认启动顺序 3rd,kernel/ext,sofa,acs
    String res = RepositoryConfig.getInstance().getRepositoryByStartOrder();
    File file = new File(RepositoryConfig.getInstance().getSofaContainerHome(), "repository");
    String[] subReps = file.list();

    String[] rsos = res.split(",");
    ArrayList<String> list = new ArrayList<String>();
    for (String subRes : rsos) {
      list.add(subRes.trim());
    }
    // 添加repository子目录
    for (String subDir : subReps) {
      if (subDir != null && !(list.contains(subDir.trim()) || list.contains("/" + subDir.trim()))) {
        list.add(subDir.trim());
      }
    }
    return createRepositories(list.toArray(new String[list.size()]));
  }
Ejemplo n.º 2
0
  public static List<Repository> createRepositories(String[] rsos) throws ContainerException {

    long b = System.currentTimeMillis();
    String sch = RepositoryConfig.getInstance().getSofaContainerHome(); // 跟目录

    List<Repository> list = new LinkedList<Repository>();
    String res = RepositoryConfig.getInstance().getRepositoryByStartOrder();
    log.info(I18n.getMessage("RF001", res));
    int i = 0;
    for (String rs : rsos) {
      i++;
      if (rs.startsWith("/") && (!rs.startsWith("repository") || !rs.startsWith("/repository"))) {
        rs = "/repository" + rs;
      }
      File file = new File(sch, rs);
      list.add(createRepository(StringUtil.formatPath(rs)));
      // 子目录
      if (!rs.endsWith(Constains.REPOSIRORY_STAGE_NAME)) {
        File[] subDirs =
            file.listFiles(
                new FileFilter() {

                  public boolean accept(File pathname) {

                    return pathname.isDirectory();
                  }
                });

        if (subDirs != null && subDirs.length > 0) {
          // 创建子库
          for (File sub : subDirs) {
            i++;
            createRepository(sub, list, i);
          }
        }
      }
    }
    long t = System.currentTimeMillis() - b;
    log.info(I18n.getMessage("RF002", res, t));
    return list;
  }