Ejemplo n.º 1
0
  public String transferSqlMapTag() {

    Collection<String> tmpPackageNames = refDbZone.getMapperPackages();

    String[] files;
    StringBuilder content = new StringBuilder();
    for (String packageName : tmpPackageNames) {
      files = PackageScaner.scanNamespaceFiles(packageName, SUFFIX, false, true);
      if (files == null) {
        logger.error("Db Mapper path is empty:" + packageName);
      } else {
        for (String file : files) {
          String tmpPackageName = packageName;
          String fileName = null;
          String[] tmp = file.split("\\.");
          if (tmp.length > 2) {
            for (int i = 0; i < tmp.length - 2; i++) {
              String appendPath = tmp[i];
              tmpPackageName += "." + appendPath;
            }
            fileName = tmp[tmp.length - 2];

          } else fileName = file.substring(0, file.indexOf("."));

          refDbZone.regMapperName(tmpPackageName, fileName + SUFFIX);
          String beanPath = tmpPackageName + "." + fileName;

          beanPath = beanPath.replace('.', '/');
          beanPath += SUFFIX;
          content.append("<sqlMap resource=\"");
          content.append(beanPath);
          content.append("\"/>\r\n");
        }
      }
    }
    return content.toString();
  }