Package fr.imag.adele.apam.declarations.encoding.capability

Examples of fr.imag.adele.apam.declarations.encoding.capability.CapabilityEncoder


 
    /*
     *  Add capabilities to represent component metadata
     */
    CapabilityEncoder encoder         = new CapabilityEncoder();
    Set<ComponentReference<?>> processed  = new HashSet<ComponentReference<?>>();
    Set<VersionedReference<?>> referenced      = new HashSet<VersionedReference<?>>();

    for (ComponentDeclaration component : buildRepository.getComponents()) {
     
      if (processed.contains(component.getReference())) {
        reporter.report(Severity.WARNING,"Component " + component.getName() + " already defined in this build, declaration ignored "+component);
        continue;
      }

      /*
       * ACR repository is used at runtime by OBR Manager resolver. It uses direct searches over the
       * properties of the component that ignore the property inheritance mechanisms of APAM.
       *
       * We need to simulate inheritance by copying properties from the ancestor declarations.
       *
       * NOTE notice that we create and modify an effective cloned declaration, we must be careful
       * not to modify the original declaration in the project repository
       *
       */
      ComponentDeclaration group     = context.getComponent(component.getGroupVersioned());
      ComponentDeclaration effective  = component.getEffectiveDeclaration(group);
     
     
      /*
       * Name property is not inherited directly, but renamed at each level
       */
      ComponentDeclaration level = component;
      while (level != null) {


        if (level instanceof SpecificationDeclaration) {
          effective.getProperties().put(CST.SPECNAME, level.getName());
        }

        if (level instanceof ImplementationDeclaration) {
          effective.getProperties().put(CST.IMPLNAME, level.getName());
        }

        if (level instanceof InstanceDeclaration) {
          effective.getProperties().put(CST.INSTNAME, level.getName());
        }
       
        level = context.getComponent(level.getGroupVersioned());
      }
     
      /*
       * For unvalued properties we add default values, this allows filter to be evaluated even if no value
       * is explicitly specified
       */
      for (PropertyDefinition property : effective.getPropertyDefinitions()) {
       
        String defaultValue = property.getDefaultValue();
        String value    = effective.getProperty(property.getName());
       
        if (value == null && defaultValue != null) {
          effective.getProperties().put(property.getName(),defaultValue);
        }
      }
     
      /*
       * Encode the effective declaration
       */
      Capability encodedCapability  = encoder.encode(effective,reporter);
      if (encodedCapability != null) {
        result.append(manager.getHelper().writeCapability(encodedCapability)).append("\n");
        processed.add(component.getReference());
       
        /*
 
View Full Code Here

TOP

Related Classes of fr.imag.adele.apam.declarations.encoding.capability.CapabilityEncoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.