Exemple #1
0
  private void loadEntityFromJar(LinkedList<JarEntryEntity> entries, boolean reload)
      throws IOException {
    for (JarEntryEntity item : entries) {
      if (!item.entry.isDirectory() && item.entry.getName().startsWith("entities/")) {
        InputStream in = null;
        try {
          in = item.jar.getInputStream(item.entry);

          String entityType = item.entry.getName();
          entityType = entityType.substring(entityType.lastIndexOf('.') + 1);

          addEntity(item.entry.getName(), in, entityType, reload);
        } catch (JAXBException e1) {
          logger.error(
              "Failed to load entity " + item.entry.getName() + ". Cause: " + e1.getMessage(), e1);
        } finally {
          CloseUtil.close(in);
        }
      }
    }
  }
Exemple #2
0
  private void loadEntityFromDir(final File path, boolean reload) throws IOException {
    if (path.isDirectory()) {
      final String files[] = path.list();
      for (final String file : files) {
        loadEntityFromDir(new File(path, file), reload);
      }
    } else {
      InputStream in = null;
      try {
        in = new FileInputStream(path);

        String entityType = path.getName();
        entityType = entityType.substring(entityType.lastIndexOf('.') + 1);
        String entityName = path.getName().substring(0, path.getName().lastIndexOf('.'));
        entityName = entityName.substring(entityName.lastIndexOf('.') + 1);
        addEntity(entityName, in, entityType, reload);
      } catch (JAXBException e1) {
        logger.error("Failed to load entity " + path.getName() + ". Cause: " + e1.getMessage(), e1);
      } finally {
        CloseUtil.close(in);
      }
    }
  }