示例#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);
  }
示例#2
0
 /**
  * Create a trace of each traceable element in woven aspect.
  *
  * @param base the aspect we are adding tracing information to
  * @param wovenAspect the aspect woven into the base
  * @param currentWeavingInformation contains all the weaving information of the current weaving
  */
 private void createTrace(
     Aspect base, Aspect wovenAspect, WeavingInformation currentWeavingInformation) {
   WovenAspect wovenAspectTracing = RamFactory.eINSTANCE.createWovenAspect();
   // TODO: Might have to be the textual represention of the aspect name...
   wovenAspectTracing.setName(wovenAspect.getName());
   wovenAspectTracing.setComesFrom(wovenAspect);
   // Create tracing hierarchy
   createTracingHierarchy(wovenAspect, wovenAspectTracing);
   base.getWovenAspects().add(wovenAspectTracing);
   // associate the wovenAspects to the Traceable elements
   createTrace(currentWeavingInformation, wovenAspectTracing);
 }