Package fr.imag.adele.apam.declarations

Examples of fr.imag.adele.apam.declarations.ComponentDeclaration


      Element metadata = ManifestMetadataParser.parseHeaderMetadata(componentHeader);
      store.setManifest(bundle.getManifest());

     
      ComponentDeclaration template = getVersionedComponentTemplate(artifact);
      EnrichElementsHelper.addPropertiesToChildrenApAMComponents(metadata, template.getPropertyDefinitions(), template.getProperties());

      DefaultManifestBuilder builder = new DefaultManifestBuilder();
      builder.setMetadataRenderer(new MetadataRenderer());
     
      builder.addMetada(Arrays.asList(metadata.getElements()));
View Full Code Here


    super.validateProvides();
   
    /*
     *  Validate the instrumented provided resources are actually declared as provided 
     */
    ComponentDeclaration effective = getGroup() != null ? getComponent().getEffectiveDeclaration(getGroup()) : getComponent();
    for (ProviderInstrumentation instrumentation : getComponent().getProviderInstrumentation()) {
     
      ResourceReference instrumented = instrumentation.getProvidedResource();
     
      checkResourceExists(instrumented);
     
      if ( instrumented != null && ! (instrumented instanceof UnknownReference) && !effective.getProvidedResources().contains(instrumented)) {
        error("the return type of the specified method "+quoted(instrumentation.getName())+ " is not one of the provided resources");
      }
    }
  }
View Full Code Here

    }

    /*
     *  Concrete composites must have a main component that provides everything provided by the composite
     */
    ComponentDeclaration main   = getComponent(getComposite().getMainComponent(),true);
    if (main == null) {
      error(" main component "+getComposite().getMainComponent().getName()+" could not be found");
      return;
    }
   
    if (getComposite().getGroupVersioned() != null && main.getGroupVersioned() != null && !getComposite().getGroupVersioned().equals(main.getGroupVersioned()) ) {
      error("main component "+ main.getName() + " must implement specification " + getComposite().getGroupVersioned().getName());
    }

    validateMainProvides(main,InterfaceReference.class);
    validateMainProvides(main,MessageReference.class);
  }
View Full Code Here

     */
    Set<ComponentReference<?>> ownedComponents = new HashSet<ComponentReference<?>>();
   
    for (OwnedComponentDeclaration ownDeclaration : getComposite().getOwnedComponents()) {
     
      ComponentDeclaration owned = getComponent(ownDeclaration.getComponent(),true);
      if (owned == null) {
        error("invalid own expression, unknown component " + ownDeclaration.getComponent().getName());
        continue;
      }


      /*
       * Verify the property used to optionally filter owned components is declared, and is an enumeration
       * that contains the specified values
       */
      if (ownDeclaration.getProperty() != null) {

        String propertyName      = ownDeclaration.getProperty().getIdentifier();
        PropertyDefinition property = owned.getPropertyDefinition(propertyName);
       
        if (property == null) {
          error("invalid own expression, undefined property "+ quoted(propertyName) +" in component "+ owned.getName());
          continue;
        }
       
        Type propertyType = getType(property);
        if (propertyType == null || !(propertyType instanceof EnumerationType)) {
          error("invalid own expression, property "+ quoted(propertyName) + " of component " + owned.getName() + " is not an enumeration");
          continue;
        }

        if (ownDeclaration.getValues().isEmpty()) {
          error("invalid own expression, values not specified for property "+ quoted(propertyName) + " of component " + owned.getName());
          continue;
        }

        for (String value : ownDeclaration.getValues()) {
          if (propertyType.value(value) == null) {
            error("invalid own expression, value "+quoted(value)+" is not valid for property "+ quoted(propertyName) + " of component " + owned.getName());
          }
        }
      }

      /*
       * Check that a single own clause applies for the same component and its members. At execution, it must also
       * be checked that if there are other grant clauses in other composites for the same component, they must
       * specify the same property and different values.
       */
      if (ownedComponents.contains(owned.getReference())) {
        error("invalid own expression, another own  clause exists for "+ owned.getName()+ " in this composite declaration");
        continue;
      }
     
      ownedComponents.add(owned.getReference());
      if (owned.getGroup() != null) {
        ownedComponents.add(owned.getGroup());
      }

      validateGrant(owned,ownDeclaration,stateType);
    }
  }
View Full Code Here

       
        grantedStates.add(grantState);
      }

      // Check that the granted component exists
      ComponentDeclaration granted  = getComponent(grantDeclaration.getRelation().getDeclaringComponent(),true);

      if (granted == null) {
        error("invalid grant expression, unknown component "+grantDeclaration.getRelation().getDeclaringComponent().getName()+ " in grant expression "+grantDeclaration);
        continue;
      }
     
      // Check that the component is a singleton
      if (granted.isDefinedSingleton()  && ! granted.isSingleton()) {
        warning("invalid grant expression, component "+grantDeclaration.getRelation().getDeclaringComponent().getName()+ " is not a singleton "+grantDeclaration);
      }
     
      // Check that the relation exists and has as target the OWN resource
      // OWN is a specification or an implem but the granted relation can be anything
     
      RelationDeclaration  grantedRelation = granted.getRelation(grantDeclaration.getRelation().getIdentifier());

      if (grantedRelation == null) {
        error("invalid grant expression, the relation "+ quoted(grantDeclaration.getRelation().getIdentifier()) +" is not defined in component " + granted.getName());
      }
      else if (!isCandidateTarget(grantedRelation,owned)) {
        error("invalid grant expression, the relation "+ quoted(grantDeclaration.getRelation().getIdentifier()) +" does not refer to the owned component " + owned.getName());
      }
     
View Full Code Here

   
    if (state == null) {
      return null;
    }

    ComponentDeclaration declaring = getComponent(state.getDeclaringComponent(),true);
    if (declaring == null) {
      error("invalid state property "+quoted(state.getIdentifier())+", declaring component "+state.getDeclaringComponent().getName()+" is unavailable");
      return null;
    }
   
    if (! declaring.getKind().equals(ComponentKind.IMPLEMENTATION)) {
      error("invalid state property "+quoted(state.getIdentifier())+", declaring component "+state.getDeclaringComponent().getName()+" is not an implementation");
      return null;
    }
   
    // Attribute state must be defined on the implementation.
    PropertyDefinition property = declaring.getPropertyDefinition(state.getIdentifier());
    if (property == null) {
      error("invalid state property "+quoted(state.getIdentifier())+", not declared in component "+state.getDeclaringComponent().getName());
      return null;
    }
View Full Code Here

   */
  private void validatePromotions() {

    for (RelationPromotion promotion : getComposite().getPromotions()) {
     
      ComponentDeclaration source = getComponent(promotion.getContentRelation().getDeclaringComponent(),true);
      if (source == null) {
        error("invalid promotion, the source component "+ promotion.getContentRelation().getDeclaringComponent() +" is unknown");
      }
     
      RelationDeclaration promotedRelation = source != null ? source.getRelation(promotion.getContentRelation().getIdentifier()) : null;
      // Check if the dependencies are compatible
      if (source != null && promotedRelation == null) {
        error("invalid promotion, the promoted relation "+ quoted(promotion.getContentRelation().getIdentifier()) +" is not defined in component "+source.getName());
        continue;
      }

      RelationDeclaration compositeRelation = getComposite().getRelation(promotion.getCompositeRelation());
      if (compositeRelation == null) {
View Full Code Here

  // Copy paste of the Util class ! too bad, this one uses ApamCapability
  private boolean matchPromotion(RelationDeclaration promotedRelation, RelationDeclaration compositeRelation) {

    boolean match = false;
   
    ComponentDeclaration compositeTarget = getComponent(compositeRelation.getTarget().as(ComponentReference.class),true);
    if (compositeTarget != null) {
      /*
       * If the target of the composite relation is a component, it must satisfy the promoted relation
       */
      match = isCandidateTarget(promotedRelation, compositeTarget);
View Full Code Here

   *
   * TODO should we change the signature of the method to throw an exception in case of mismatching kind
   */
  private static ComponentDeclaration select(ConcurrentNavigableMap<Version,WeakReference<ComponentDeclaration>> revisions, ComponentKind kind) {
   
    ComponentDeclaration selected = null;
   
    for (Map.Entry<Version,WeakReference<ComponentDeclaration>> revisionEntry : revisions.entrySet()) {
     
      ComponentDeclaration revision = revisionEntry.getValue().get();
     
      if (revision == null) {
        revisions.remove(revisionEntry.getKey());
      }
      else if (revision.getKind() == kind || ComponentKind.COMPONENT == kind) {
        selected = revision;
      }
     
    }
   
View Full Code Here

            for(Capability capability : resource.getCapabilities()) {
             
              if (!CapabilityParser.isComponent(capability))
                continue;

              ComponentDeclaration component = parser.decode(capability,reporter);

            /*
             * Components coming from the ACR have inherited properties and default values added
             * at build time, and the declaration stored in the repository is actually effective.
             *
             * However, we must allow members of a group to define properties that are not valued
             * in the group, sowe remove then automatically the default values
             *
             * TODO We need a way to distinguish default values added at build time, from explicitly
             * defined properties that happen to have the same value
             */
          for (PropertyDefinition property : component.getPropertyDefinitions()) {
           
            String defaultValue = property.getDefaultValue();
            String value    = component.getProperty(property.getName());
           
            if (value != null &&  defaultValue != null && defaultValue.equals(value)) {
              component.getProperties().remove(property.getName());
            }
          }
             
              /*
               * Add version if not specified
View Full Code Here

TOP

Related Classes of fr.imag.adele.apam.declarations.ComponentDeclaration

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.