コード例 #1
0
  /**
   * 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]);
  }
コード例 #2
0
 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;
 }