/**
   * Return the set of models assigned as providers.
   *
   * @return the providers consumed by the model
   * @exception IllegalStateException if the model is not in an assembled state
   */
  public DeploymentModel[] getProviders() {
    if (!isAssembled()) {
      final String error = "Model is not assembled " + this;
      throw new IllegalStateException(error);
    }

    final ArrayList list = new ArrayList();
    if (getContextModel().isEnabled()) {
      DeploymentModel provider = getContextModel().getProvider();
      if (provider != null) {
        list.add(provider);
      }
    }

    StageModel[] stages = getStageModels();
    for (int i = 0; i < stages.length; i++) {
      StageModel stage = stages[i];
      list.add(stage.getProvider());
    }

    DependencyModel[] dependencies = getDependencyModels();
    for (int i = 0; i < dependencies.length; i++) {
      DependencyModel dependency = dependencies[i];
      DeploymentModel provider = dependency.getProvider();
      if (provider != null) list.add(provider);
    }

    return (DeploymentModel[]) list.toArray(new DeploymentModel[0]);
  }
 /**
  * Return a dependency model matching the supplied descriptor. If no model matches the supplied
  * descriptor the implementation will return null.
  *
  * @param dependency the dependency descriptor
  * @return the matching stage model
  */
 public DependencyModel getDependencyModel(DependencyDescriptor dependency) {
   DependencyModel[] models = getDependencyModels();
   for (int i = 0; i < models.length; i++) {
     DependencyModel model = models[i];
     if (dependency.equals(model.getDependency())) {
       return model;
     }
   }
   return null;
 }
 private boolean isServiceAssembled() {
   DependencyModel[] dependencies = getDependencyModels();
   for (int i = 0; i < dependencies.length; i++) {
     DependencyModel dep = dependencies[i];
     if (null == dep.getProvider() && dep.getDependency().isRequired()) {
       return false;
     }
   }
   return true;
 }