Esempio n. 1
0
 Set<SModuleReference> getModuleRefs(Iterable<? extends ReloadableModule> modules) {
   Set<SModuleReference> result = new LinkedHashSet<SModuleReference>();
   for (ReloadableModule module : modules) {
     result.add(module.getModuleReference());
   }
   return result;
 }
Esempio n. 2
0
  /** @return message with the problem description or null if the module is valid */
  @Nullable
  @Hack
  private String getModuleProblemMessage(
      SModuleReference mRef,
      Map<ReloadableModule, AbsentDependencyException> modulesWithAbsentDeps) {
    assert !isChanged();
    if (isModuleDisposed(mRef)) {
      return String.format(
          "Module %s is disposed and therefore was marked invalid for class loading",
          mRef.getModuleName());
    }

    ReloadableModule module = (ReloadableModule) mRef.resolve(myRepository);
    assert module != null;

    // FIXME does not work for now, enable in the 3.4
    if (modulesWithAbsentDeps.containsKey(module)) {
      AbsentDependencyException exception = modulesWithAbsentDeps.get(module);
      return String.format(
          "%s has got an absent dependency problem and therefore was marked invalid for class loading: %s",
          module, exception.getMessage());
    }
    for (SDependency dep : module.getDeclaredDependencies()) {
      if (dep.getScope() == SDependencyScope.DESIGN
          || dep.getScope() == SDependencyScope.GENERATES_INTO) {
        continue;
      }
      if (isModuleDisposed(dep.getTargetModule())) {
        return String.format(
            "%s depends on a disposed module %s and therefore was marked invalid for class loading",
            module, dep.getTargetModule());
      }
    }
    return null;
  }
Esempio n. 3
0
 Collection<ReloadableModule> getResolvedDependencies(
     Iterable<? extends ReloadableModule> modules) {
   Collection<SModuleReference> refs = new LinkedHashSet<SModuleReference>();
   for (ReloadableModule module : modules) {
     refs.add(module.getModuleReference());
   }
   Collection<SModuleReference> referencedDeps = getDependencies(refs);
   Collection<ReloadableModule> resolvedDeps = resolveRefs(referencedDeps);
   assert (resolvedDeps.size() == referencedDeps.size());
   return resolvedDeps;
 }
Esempio n. 4
0
 private TemplateModel getTemplateModel(String modelName) {
   ReloadableModule module =
       (ReloadableModule) ModuleRepositoryFacade.getInstance().getModule(getReference());
   Class<TemplateModel> clazz = null;
   if (module != null && module.willLoad()) {
     try {
       clazz = (Class<TemplateModel>) module.getClass(modelName);
     } catch (ClassNotFoundException e) {
       throw new IllegalStateException("Class not found for model " + modelName, e);
     }
   }
   if (clazz == null) {
     throw new IllegalStateException(
         String.format("Failed to obtain generator runtime class for model %s", modelName));
   }
   try {
     return clazz.getConstructor(TemplateModule.class).newInstance(this);
   } catch (RuntimeException ex) {
     throw ex;
   } catch (Exception ex) {
     throw new RuntimeException(ex);
   }
 }
Esempio n. 5
0
 boolean isModuleWatched(ReloadableModule module) {
   return getAllModules().contains(module.getModuleReference());
 }
Esempio n. 6
0
 public Collection<? extends ReloadableModule> getResolvedBackDependencies(
     Iterable<? extends ReloadableModule> modules) {
   Collection<SModuleReference> refs = new LinkedHashSet<SModuleReference>();
   for (ReloadableModule module : modules) refs.add(module.getModuleReference());
   return resolveRefs(getBackDependencies(refs));
 }