Package fr.imag.adele.apam.declarations

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


     * We need to do an special case when the target kind is INSTANCE, as the metadata of instances doesn't contain
     * the provided resources, so we search for corresponding implementations.
     *
     * The caller should decide if it look for instances in the repository or instantiate the found implementations.
     */
    ComponentKind searchedKind     = relation.getTargetKind();
    if (searchedKind == ComponentKind.INSTANCE)
      searchedKind = ComponentKind.IMPLEMENTATION;
   
    ApamFilter requirement = ApamFilter.newInstance(requirementQuery);
   
View Full Code Here


    return ((Instance)argument).getServiceObject();
  }
 
  @Override
  protected boolean isExpectedParameter(Class<?> parameterType) {
      ComponentKind targetKind = relation.getTargetKind();
     
      /*
       * If target kind is not directly specified in the declaration, wee ask APAM to perform
       * the calculation.
       */
 
View Full Code Here

    boolean isMultiple = parseBoolean(component.getName(), element, ATT_MULTIPLE, false, false);

    String sourceName = parseString(component.getName(), element, ATT_SOURCE, isContextual && !isOverride);

    ComponentKind sourceKind = parseKind(component.getName(), element, ATT_SOURCE_KIND, isContextual && !isOverride, null);
    ComponentKind targetKind = parseKind(component.getName(), element, ATT_TARGET_KIND, false, null);

    /*
     * For atomic components, dependency declarations may optionally have a number of nested instrumentation declarations.
     *
     * These are parsed first, as a number of attributes of the relation that are not explicitly declared can be inferred
     * from the instrumentation metadata.
     */

    List<RequirerInstrumentation> instrumentations = new ArrayList<RequirerInstrumentation>();
    if (component instanceof AtomicImplementationDeclaration) {

      AtomicImplementationDeclaration atomic = (AtomicImplementationDeclaration) component;

      /*
       * Optionally, as a shortcut, a single injection may be specified
       * directly as an attribute of the relation
       */
      RequirerInstrumentation directInstrumentation = parseRelationInstrumentation(element, atomic, false);
      if (directInstrumentation != null) {
        instrumentations.add(directInstrumentation);
      }

      for (Element instrumentation : optional(element.getElements())) {

        /*
         * ignore elements that are not from APAM
         */
        if (!isApamDefinition(instrumentation)) {
          continue;
        }

        /*
         * Accept only resource references
         */
        String resourceKind = instrumentation.getName();
        if (!(INTERFACE.equals(resourceKind) || MESSAGE.equals(resourceKind)
            || PACKAGE.equals(resourceKind))) {
          continue;
        }

        instrumentations.add(parseRelationInstrumentation(instrumentation, atomic, true));

      }

    }


    /*
     * If no ID was explicitly specified, but a single instrumentation was declared the the name of the field or
     * method becomes the ID of the relation.
     */
    if (id == null && instrumentations.size() == 1) {
      id = instrumentations.get(0).getName();
    }

    /*
     * If no target was explicitly specified, sometimes we can infer it from the instrumentation metadata.
     */
    if (!instrumentations.isEmpty() && (targetDef == null || targetKind == null)) {

      ComponentKind inferredKind = null;
      ResolvableReference inferredTarget = null;

      for (RequirerInstrumentation instrumentation : instrumentations) {

        String javaType = instrumentation.getRequiredResource().getJavaType();
        ComponentKind candidateKind = null;
        ResolvableReference candidateTarget = null;

        if (ComponentKind.COMPONENT.isAssignableTo(javaType)) {
          candidateKind = null;
          candidateTarget = null;
View Full Code Here

  public static ComponentReference<?> getComponent(Capability capability) {
   
    if (! isComponent(capability))
      return null;

    ComponentKind kind  = kind((String) capability.getPropertiesAsMap().get(CST.COMPONENT_TYPE));
      return kind != null ? kind.createReference((String) capability.getPropertiesAsMap().get(CST.NAME)) : null;
  }
View Full Code Here

        else {
          /*
           * For relations that navigate the abstraction levels, we can navigate to more abstract levels, and
           * for more concrete levels we continue validating in the same context
           */
          ComponentKind targetLevel = source.getKind();

          if (relationName.equals(CST.REL_SPEC)) {
            targetLevel = ComponentKind.SPECIFICATION;
          }
          else if (relationName.equals(CST.REL_IMPL) || relationName.equals(CST.REL_IMPLS)) {
View Full Code Here

  /**
   * The effective target kind
   */
  protected ComponentKind getTargetKind() {
    ComponentKind effectiveTargetKind   = getEffectiveRelation().getTargetKind();
    return effectiveTargetKind != null ? effectiveTargetKind : ComponentKind.INSTANCE;
  }
View Full Code Here

TOP

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

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.