/**
   * 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]);
  }
 /**
  * Return the deployment timeout value for the component.
  *
  * @return the default deployment timeout value
  */
 public long getDeploymentTimeout() {
   String value = m_context.getType().getInfo().getAttribute(DEPLOYMENT_TIMEOUT_KEY, null);
   if (null != value) {
     try {
       return Long.parseLong(value);
     } catch (NumberFormatException nfe) {
       final String error =
           "Invalid timout parameter ["
               + value
               + "] in component type ["
               + m_context.getType()
               + "].";
       throw new ModelRuntimeException(error, nfe);
     }
   } else {
     return super.getDeploymentTimeout();
   }
 }
  /** Get the default activation policy for the model. */
  public boolean getDefaultActivationPolicy() {
    final int activation = m_context.getComponentProfile().getActivationDirective();

    if (activation != DeploymentProfile.DEFAULT) {
      return (activation == DeploymentProfile.ENABLED);
    } else {
      if (m_context.getProfile().getMode() == Mode.EXPLICIT) {
        Type type = m_context.getType();
        if (type.getInfo().getLifestyle().equals(InfoDescriptor.TRANSIENT)) {
          return false;
        } else {
          return true;
        }
      } else {
        return false;
      }
    }
  }
 /**
  * Return the proxy enabled policy for the model. If the system wide proxy enabled is disabled the
  * operation will return false otherwise the value returned is true unless overriden by the
  * "urn:composition:proxy" attribute.
  *
  * @return the proxy policy
  */
 public boolean getProxyPolicy() {
   if (m_context.getSystemContext().isProxyEnabled()) {
     if (getType().getInfo().getAttribute(PROXY_KEY, "true").equals("false")) {
       return false;
     } else {
       return true;
     }
   } else {
     return false;
   }
 }
 /**
  * Return the class for the deployable target.
  *
  * @return the class
  */
 public Class getDeploymentClass() {
   return m_context.getDeploymentClass();
 }
 /**
  * Return the component type descriptor.
  *
  * @return the type descriptor
  */
 public Type getType() {
   return m_context.getType();
 }
 private int getTypeCollectionPolicy() {
   return m_context.getType().getInfo().getCollectionPolicy();
 }
 /**
  * Return TRUE is this model is capable of supporting a supplied service.
  *
  * @param reference the service reference descriptor
  * @return true if this model can fulfill the service
  */
 public boolean isaCandidate(ReferenceDescriptor reference) {
   return m_context.getType().getService(reference) != null;
 }
 /**
  * Return TRUE is this model is capable of supporting a supplied stage dependency.
  *
  * @param stage the stage descriptor
  * @return TRUE if this model can fulfill the stage dependency
  */
 public boolean isaCandidate(StageDescriptor stage) {
   return m_context.getType().getExtension(stage) != null;
 }
 /**
  * Return the set of services produced by the model.
  *
  * @return the service descriptors
  */
 public ServiceDescriptor[] getServices() {
   return m_context.getType().getServices();
 }
  /**
   * 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);
    }
  }