/**
   * Return the set of services produced by the model as a array of classes.
   *
   * @return the service classes
   */
  public Class[] getInterfaces() {
    //
    // TODO: add a SoftReference to hold the service class array
    // instad of generating each time
    //

    ClassLoader classLoader = m_context.getClassLoader();
    ArrayList list = new ArrayList();
    ServiceDescriptor[] services = getServices();
    for (int i = 0; i < services.length; i++) {
      final ServiceDescriptor service = services[i];
      final String classname = service.getReference().getClassname();
      list.add(getComponentClass(classLoader, classname));
    }

    //
    // if the component is an extension then add all implemented
    // interfaces
    //

    if (getType().getExtensions().length > 0) {
      Class[] interfaces = getDeploymentClass().getInterfaces();
      for (int i = 0; i < interfaces.length; i++) {
        list.add(interfaces[i]);
      }
    }

    return (Class[]) list.toArray(new Class[0]);
  }
  /**
   * Creation of a new deployment model.
   *
   * @param context the deployment context
   */
  public DefaultComponentModel(ComponentContext context, SecurityModel security)
      throws ModelException {
    super(context, security);

    m_context = context;

    m_activation = getDefaultActivationPolicy();

    setCollectionPolicy(m_context.getComponentProfile().getCollectionPolicy());

    ClassLoader classLoader = m_context.getClassLoader();

    if (isConfigurable()) {
      final Configuration defaults = m_context.getType().getConfiguration();
      final Configuration explicit = m_context.getComponentProfile().getConfiguration();
      final Configuration consolidated = consolidateConfigurations(explicit, defaults);
      if (consolidated != null) {
        m_config = consolidated;
      } else {
        m_config = EMPTY_CONFIGURATION;
      }
    }

    if (isParameterizable()) {
      Parameters staticDefaults = m_context.getType().getParameters();
      final Parameters parameters = m_context.getComponentProfile().getParameters();
      if (parameters != null) {
        if (null == staticDefaults) {
          m_parameters = parameters;
        } else {
          m_parameters = new Parameters();
          m_parameters.merge(staticDefaults);
          m_parameters.merge(parameters);
        }
      } else {
        if (null == staticDefaults) {
          m_parameters = Parameters.EMPTY_PARAMETERS;
        } else {
          m_parameters = staticDefaults;
        }
      }
    }

    final ContextDescriptor contextDescriptor = m_context.getType().getContext();
    final ContextDirective contextDirective = m_context.getComponentProfile().getContext();
    final Logger log = getLogger().getChildLogger("context");
    m_contextModel = new DefaultContextModel(log, contextDescriptor, contextDirective, context);

    //
    // create the dependency models for subsequent assembly
    // management
    //

    DependencyDescriptor[] dependencies = m_context.getType().getDependencies();
    m_dependencies = new DefaultDependencyModel[dependencies.length];

    for (int i = 0; i < dependencies.length; i++) {
      DependencyDescriptor descriptor = dependencies[i];
      DependencyDirective directive =
          context.getComponentProfile().getDependencyDirective(descriptor.getKey());
      m_dependencies[i] =
          new DefaultDependencyModel(
              context.getLogger().getChildLogger("deps"),
              context.getPartitionName(),
              context.getProfile().getName(),
              descriptor,
              directive);
    }

    //
    // create the stage models for subsequent assembly
    // management
    //

    StageDescriptor[] stages = m_context.getType().getStages();
    m_stages = new DefaultStageModel[stages.length];

    for (int i = 0; i < stages.length; i++) {
      StageDescriptor descriptor = stages[i];
      StageDirective directive =
          context.getComponentProfile().getStageDirective(descriptor.getKey());
      m_stages[i] =
          new DefaultStageModel(
              context.getLogger().getChildLogger("stages"),
              context.getPartitionName(),
              descriptor,
              directive);
    }
  }