コード例 #1
0
  private String getErrorMessage(
      ComponentDescriptor descriptor, ComponentRequirement requirement, String causeDescription) {
    StringBuffer msg = new StringBuffer("Component composition failed.");

    msg.append("  Failed to resolve requirement for component of role: '");

    msg.append(descriptor.getRole());

    msg.append("'");

    if (descriptor.getRoleHint() != null) {
      msg.append(" and role-hint: '");

      msg.append(descriptor.getRoleHint());

      msg.append("'. ");
    }

    if (requirement != null) {
      msg.append("Failing requirement: " + requirement.getHumanReadableKey());
    }
    if (causeDescription != null) {
      msg.append(causeDescription);
    }

    return msg.toString();
  }
コード例 #2
0
  private ComponentRequirement getMatchingRequirement(
      ComponentDescriptor componentDescriptor, List requirements) {

    ComponentRequirement retValue = null;

    String role = componentDescriptor.getRole();

    String roleHint = componentDescriptor.getRoleHint();

    if (componentDescriptor.getRoleHint() != null) {
      for (Iterator iterator = requirements.iterator(); iterator.hasNext(); ) {
        ComponentRequirement requirement = (ComponentRequirement) iterator.next();

        if (role.equals(requirement.getRole()) && roleHint.equals(requirement.getRoleHint())) {
          retValue = requirement;

          break;
        }
      }
    } else {
      for (Iterator iterator = requirements.iterator(); iterator.hasNext(); ) {
        ComponentRequirement requirement = (ComponentRequirement) iterator.next();

        if (role.equals(requirement.getRole())) {
          retValue = requirement;

          break;
        }
      }
    }

    return retValue;
  }
コード例 #3
0
  /** @todo Change this to include components looked up from parents as well... */
  public List lookupList(String role) throws ComponentLookupException {
    List components = new ArrayList();

    List componentDescriptors = getComponentDescriptorList(role);

    if (componentDescriptors != null) {
      // Now we have a list of component descriptors.

      for (Iterator i = componentDescriptors.iterator(); i.hasNext(); ) {
        ComponentDescriptor descriptor = (ComponentDescriptor) i.next();

        String roleHint = descriptor.getRoleHint();

        Object component;

        if (roleHint != null) {
          component = lookup(role, roleHint);
        } else {
          component = lookup(role);
        }

        components.add(component);
      }
    }

    return components;
  }