Ejemplo n.º 1
0
  /**
   * Performs the step of a single weave. The lower-level aspect from the instantiation is woven
   * into the given aspect.
   *
   * @param base the higher-level aspect the lower-level aspect is woven into
   * @param instantiation the lower-level aspect to weave into the base aspect
   */
  public void doWeaveSingle(Aspect base, Instantiation instantiation) {
    System.out.println(
        "Weaving " + instantiation.getSource().getName() + " into " + base.getName());
    StructuralViewWeaver structuralViewWeaver = StructuralViewWeaver.getInstance();
    for (COREModelReuse modelReuse : instantiation.getSource().getModelReuses()) {
      COREModelReuse copy = EcoreUtil.copy(modelReuse);
      base.getModelReuses().add(copy);
    }

    // CHECKSTYLE:IGNORE ParameterAssignment FOR 2 LINES: Needed, because the operation returns the
    // result,
    // however it returns base.
    base = structuralViewWeaver.weave(base, instantiation);

    WeavingInformation currentWeavingInformation = structuralViewWeaver.getWeavingInformation();

    // Update the model reuses.
    ReferenceUpdater.getInstance().update(base.getModelReuses(), currentWeavingInformation);

    createTrace(base, instantiation.getSource(), currentWeavingInformation);

    // Merge weaving information, to be able to look at woven elements later.
    this.weavingInformation.merge(currentWeavingInformation);

    messageViewWeaver.copyMessageViews(base, instantiation.getSource(), currentWeavingInformation);
    StateViewWeaverUtils.copyStateViews(base, instantiation.getSource(), currentWeavingInformation);

    base.getInstantiations().remove(instantiation);
  }
Ejemplo n.º 2
0
  /**
   * Resolves dependencies of the given aspect from the bottom (of the dependency hierarchy) up. For
   * each two aspects, a single weave is performed (only structure is woven, rest is copied over).
   *
   * @param aspect the aspect to resolve dependencies for
   * @see #weaveAllBottomUp(Aspect)
   */
  private void resolveDependenciesBottomUp(Aspect aspect) {
    // Create a copy of the instantiations to evade a concurrent modification,
    // when instantiations are removed in doWeaveSingle.
    List<Instantiation> instantiations = new ArrayList<Instantiation>(aspect.getInstantiations());

    for (Instantiation instantiation : instantiations) {
      // Find the lowest aspect recursively ...
      if (!instantiation.getSource().getInstantiations().isEmpty()) {
        resolveDependenciesBottomUp(instantiation.getSource());
      }

      doWeaveSingle(aspect, instantiation);
    }
  }