Package fr.imag.adele.apam

Examples of fr.imag.adele.apam.Component


    } else overrides = Collections.emptySet() ;

    Set<RelationDeclaration> localRelations = new HashSet<RelationDeclaration>();
    Set<String> processed = new HashSet<String>();

    Component group = this;
    while (group != null) {

      for (RelationDeclaration relationDeclaration : group.getDeclaration().getRelations()) {

        /*
         * Ignore relations already processed at a lower level
         */
        if (processed.contains(relationDeclaration.getIdentifier())) {
          continue;
        }

        /*
         * Check overridden relations
         */
        boolean matchOverride = false;
        for (RelationDeclaration override : overrides) {
          //          for (RelationDeclaration override : overrides != null ? overrides
          //              : Collections.<RelationDeclaration> emptySet()) {
          if (matchOverride(relationDeclaration, override)) {
            relationDeclaration = relationDeclaration.overriddenBy(override);
            matchOverride = true;
          }
        }

        /*
         * Process locally declared and inherited overridden relations
         */
        if (group == this || matchOverride) {
          localRelations.add(relationDeclaration);
          processed.add(relationDeclaration.getIdentifier());
        }
      }
      group = group.getGroup();
    }

    /*
     * Define all the local relations definition of this component
     */
 
View Full Code Here


    // Check if override source matches this component or one of its
    // ancestors

    match       = false;
    Component group = this;
    while (group != null && !match) {
      match = override.refines(group.getDeclaration().getReference(), relation);
      group = group.getGroup();
    }

    return match;
  }
View Full Code Here

   * on the current owner.
   */
  private void initializeProperties(Map<String, String> initialProperties) {


    Component group = getGroup();

    /*
     * Currently the instance declaration may include invalid properties.
     *
     * For declared instances this should not happen as the declaration is validated at build-time. For dynamically
     * created instances (using the APAM API or the apform API directly) this should be validated by this method.
     *
     * However, there are many properties added by the iPOJO apform layer that need to be ignored, so we simply
     * silently ignore all invalid properties.
     *
     * TODO We should be able to distinguish properties specified by the user that must be validated, from properties
     * used internally by the iPOJO apform.
     */
    Set<String> invalidDeclaredProperties = new HashSet<String>();
    for (String property : getDeclaration().getProperties().keySet()) {

      boolean isDefined =  getDeclaration().isDefined(property) ||
                (group != null && group.getPropertyDefinition(property) != null);
     
      if (!isDefined) {
        invalidDeclaredProperties.add(property);
      }
     
      if (group != null && group.getProperty(property) != null) {
        invalidDeclaredProperties.add(property);
      }
    }
     
    getDeclaration().getProperties().keySet().removeAll(invalidDeclaredProperties);
   
    /*
     * Merge initial and declared properties.
     * 
     */
    Map<String, String> fullInitialProperties = new HashMap<String, String>(getDeclaration().getProperties());
    if (initialProperties != null) {
      fullInitialProperties.putAll(initialProperties);
      fullInitialProperties.remove("instance.name");
    }

    /*
     * NOTE  In the case of change owner, the initial properties include inherited values from the group,
     * we ignore them to avoid false error messages, they will be added later by the normal inheritance
     * mechanism
     *
     * TODO Distinguish the case of change owner from a real initialization
     */
    if (initialProperties != null && group !=null) {
      for (Map.Entry<String, String> initialProperty : initialProperties.entrySet()) {
        if (group.getProperty(initialProperty.getKey()) != null && group.getProperty(initialProperty.getKey()).equals(initialProperty.getValue())) {
          fullInitialProperties.remove(initialProperty.getKey());
        }
      }
    }

    // start cleaning the properties (normally empty)
    clear ();

    /*
     *  First add the valid attributes.
     */
    for (Map.Entry<String, String> initialProperty : fullInitialProperties.entrySet()) {
     
      PropertyDefinition def = validDef(initialProperty.getKey(), true);
      if (def != null) {
        Object val = Attribute.checkAttrType(initialProperty.getKey(), initialProperty.getValue(), def.getType());
        if (val != null) {
          put(initialProperty.getKey(), val);
        }
      }
    }

    /*
     *  then add those coming from its group, avoiding overloads.
     */
    if (group != null) {
      for (String attr : group.getAllProperties().keySet()) {
        if (get(attr) == null) {
          put(attr, ((ComponentImpl)group).get(attr));
        }
      }
    }

    /*
     * Add the default values specified in the group for properties not explicitly specified
     */
    if (group != null) {
      for (PropertyDefinition definition : group.getDeclaration().getPropertyDefinitions()) {
        if (definition.hasDefaultValue() && get(definition.getName()) == null && definition.getInjected() != InjectedPropertyPolicy.INTERNAL) {
          Object val = Attribute.checkAttrType(definition.getName(),definition.getDefaultValue(), definition.getType());
          if (val != null) {
            put(definition.getName(), val);
          }
View Full Code Here

  @Override
  public boolean isAncestorOf(Component member) {

    assert member != null;

    Component ancestor = member.getGroup();
    while (ancestor != null && !ancestor.equals(this)) {
      ancestor = ancestor.getGroup();
    }

    return ancestor != null;
  }
View Full Code Here

  public Component install(OBRManager context) {

    /*
     * If the component exists, maybe arrived in the mean time, or from another bundle or in another version, do nothing
     */
    Component result = CST.componentBroker.getComponent(component.getName());
    if (result != null)
      return result;
   
    /*
     * Check if the bundle is already existing in the platform
View Full Code Here

     * TODO currently we only install a single candidate, irrespective of the multiplicity of the relationship.
     * This is a trade-off between comprehensiveness and laziness (in the worst case scenario, when there is no
     * constraints, we would install all possible providers) we should have an explicit strategy.
     */
   
    Component selected = candidates.iterator().next().install(this);
   
    return !instantiableCandidates ? new Resolved<Component>(selected) : new Resolved<Implementation>((Implementation)selected,true);
  }
View Full Code Here

              
            }

        }
        text+=("\n< Searching " + componentName + " in " + target + " repositories> ");
        Component c= CST.apamResolver.findComponentByName(target, componentName);
        return text+="\n"+c.getName()+" deployed";
    }
View Full Code Here

 
    /*
     * For scalar dependencies return any of the target objects wired
     */
    if (!isCollection) {
        Component target = targetServices.iterator().next();
        return injectComponent ? target : ((Instance) target).getServiceObject();
    }
 
    /*
     * For arrays, we need to reflectively build a type conforming array
View Full Code Here

     * 2) finding a component by name : in this case either the specified source is an
     * instance (and the component must be visible in its enclosing composite type), or
     * directly the composite type that must be used as context.
     *
     */
    Component source    = relation.getLinkSource();
    CompositeType context   = null;
   
    if (relation.isRelation()) {
     
      switch (relation.getRelationDefinition().getSourceKind()) {
View Full Code Here

     * specified in the source kind
     */

    RelationDefinition relDef = getApform().getApamComponent().getRelation(injection.getRelation().getIdentifier());

    Component source = null;
    switch (relDef.getSourceKind()) {
    case INSTANCE:
    case COMPONENT:
      source = getApform().getApamComponent();
      break;
View Full Code Here

TOP

Related Classes of fr.imag.adele.apam.Component

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.