コード例 #1
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();
   }
 }
コード例 #2
0
  /** 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;
      }
    }
  }
コード例 #3
0
 /**
  * Return the component type descriptor.
  *
  * @return the type descriptor
  */
 public Type getType() {
   return m_context.getType();
 }
コード例 #4
0
 private int getTypeCollectionPolicy() {
   return m_context.getType().getInfo().getCollectionPolicy();
 }
コード例 #5
0
 /**
  * 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;
 }
コード例 #6
0
 /**
  * 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;
 }
コード例 #7
0
 /**
  * Return the set of services produced by the model.
  *
  * @return the service descriptors
  */
 public ServiceDescriptor[] getServices() {
   return m_context.getType().getServices();
 }
コード例 #8
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);
    }
  }