예제 #1
0
  public static ExecutionEnvironment instance() {
    if (INSTANCES.size() == 1) {
      return THE_ONE == null ? THE_ONE = INSTANCES.values().iterator().next() : THE_ONE;
    }

    IModule mod = INSTANCES.size() > 0 ? TypeSystem.getCurrentModule() : null;
    if (mod != null) {
      ExecutionEnvironment execEnv = (ExecutionEnvironment) mod.getExecutionEnvironment();
      if (execEnv == null) {
        throw new IllegalStateException(
            "Module, " + mod.getName() + ", has a null execution environment. This is bad.");
      }
      return execEnv;
    }

    if (INSTANCES.size() > 0) {
      // Return first non-default project
      // Yes, this is a guess, but we need to guess for the case where we're running tests
      // and loading classes in lots of threads where the current module is not pushed
      for (ExecutionEnvironment execEnv : INSTANCES.values()) {
        if (execEnv.getProject() != DEFAULT_PROJECT && !execEnv.getProject().isDisposed()) {
          return execEnv;
        }
      }
    }

    return instance(DEFAULT_PROJECT);
  }
예제 #2
0
 @Override
 public void updateAllModules() {
   List<? extends IModule> modules = getModules();
   for (IModule module : modules) {
     module.update();
   }
 }
예제 #3
0
 public void shutdown() {
   for (IModule module : _modules) {
     module.getModuleTypeLoader().shutdown();
   }
   INSTANCES.clear();
   THE_ONE = null;
 }
예제 #4
0
 void checkForDuplicates(String moduleName) {
   for (IModule m : getModules()) {
     if (m.getName().equals(moduleName)) {
       throw new RuntimeException("Module " + moduleName + " allready exists.");
     }
   }
 }
예제 #5
0
  public void initializeMultipleModules(List<? extends IModule> modules) {
    _state = TypeSystemState.STARTING;
    try {
      // noinspection unchecked
      _defaultModule = null;
      _rootModule = null;
      _modules = (List<IModule>) modules;

      for (IModule module : modules) {
        module.update();
      }

      for (IModule module : modules) {
        pushModule(module);
        try {
          ((Module) module).initializeTypeLoaders();
        } finally {
          popModule(module);
        }
      }

      CommonServices.getCoercionManager().init();

      FrequentUsedJavaTypeCache.instance(this).init();
    } finally {
      _state = TypeSystemState.STARTED;
    }
  }
예제 #6
0
 public IModule findRootModule() {
   List<IModule> moduleRoots = new ArrayList<IModule>(_modules);
   for (IModule module : _modules) {
     for (Dependency d : module.getDependencies()) {
       moduleRoots.remove(d.getModule());
     }
   }
   return moduleRoots.size() > 0 ? moduleRoots.get(0) : null;
 }
예제 #7
0
 public IModule getModule(String strModuleName) {
   for (IModule m : _modules) {
     if (m.getName().equals(strModuleName)) {
       return m;
     }
   }
   if (isSingleModuleMode() && GLOBAL_MODULE_NAME.equals(strModuleName)) {
     return getGlobalModule();
   }
   return null;
 }
예제 #8
0
  public void addModule(IModule module) {
    checkForDuplicates(module.getName());
    // noinspection unchecked
    _modules.add(module);
    module.update();

    pushModule(module);
    try {
      ((Module) module).initializeTypeLoaders();
    } finally {
      popModule(module);
    }
  }
예제 #9
0
 private boolean isInModule(IModule module, IResource file) {
   for (IDirectory src : module.getSourcePath()) {
     if (file.equals(src) || file.isDescendantOf(src)) {
       return true;
     }
   }
   return false;
 }
예제 #10
0
 private Map<String, SQLFileInfo> initializeSQLFiles() {
   HashMap<String, SQLFileInfo> results = new HashMap<String, SQLFileInfo>();
   for (Pair<String, IFile> pair : _module.getFileRepository().findAllFilesByExtension(".sql")) {
     String fileName = pair.getFirst();
     IFile sqlFil = pair.getSecond();
     for (DatabaseImpl db : _typeDataByNamespace.get().values()) {
       if (sqlFil.isDescendantOf(db.getDBData().getDdlFile().getParent())) {
         String queryName =
             fileName.substring(0, fileName.length() - ".sql".length()).replace("/", ".");
         results.put(queryName, new SQLFileInfo(queryName, db, sqlFil));
         break;
       }
     }
   }
   return results;
 }
예제 #11
0
 public void renameModule(IModule module, String newName) {
   ((ExecutionEnvironment) module.getExecutionEnvironment()).checkForDuplicates(newName);
   ((Module) module).setName(newName);
 }