示例#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
 public void renameModule(IModule module, String newName) {
   ((ExecutionEnvironment) module.getExecutionEnvironment()).checkForDuplicates(newName);
   ((Module) module).setName(newName);
 }