Example #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);
  }
Example #2
0
  /**
   * Weaves the state machines of the state views. Doesn't apply the CSP composition to the copied
   * state machines.
   *
   * @param aspect the aspect to weave state machines for
   * @param listener to notify when events occur during weaving
   */
  public void weaveAllNoCSPWeavingForStateViews(Aspect aspect, WeaverListener<Aspect> listener) {
    try {
      listener.weavingStarted();

      Aspect result = loadNewInstance(aspect);
      weavingInformation.clear();
      // Do phase 1: Weave all structural views and copy the message and state views
      // from the lower- to the higher-level aspect.
      resolveDependenciesBottomUp(result);

      messageViewWeaver.weaveMessageViews(aspect, weavingInformation);

      listener.weavingFinished(result);
      // CHECKSTYLE:IGNORE IllegalCatch: There could be many different exceptions during
      // initialization.
    } catch (Exception e) {
      // TODO: catch in lower level weaver operations, and throw custom exception.
      listener.weavingFailed(e);
    }
  }
Example #3
0
 /**
  * Performs the final step of weaving. I.e., message views and state views are woven. The actions
  * are performed on the given aspect directly.
  *
  * @param aspect the aspect for which views should be woven
  */
 public void weaveAll(Aspect aspect) {
   messageViewWeaver.weaveMessageViews(aspect, weavingInformation);
   stateViewWeaver.weaveStateViews(aspect);
 }