public ComponentDescriptor getComponentDescriptor(
      String role, String hint, ClassRealm classRealm) {
    ComponentDescriptor result = componentRepository.getComponentDescriptor(role, hint, classRealm);

    ClassRealm tmpRealm = classRealm.getParentRealm();

    while (result == null && tmpRealm != null) {
      result = componentRepository.getComponentDescriptor(role, hint, classRealm);
      tmpRealm = tmpRealm.getParentRealm();
    }

    if (result == null && parentContainer != null) {
      result = parentContainer.getComponentDescriptor(role, hint, classRealm);
    }

    return result;
  }
Exemple #2
0
  public ComponentDescriptor getComponentDescriptor(String componentKey) {
    ComponentDescriptor result = componentRepository.getComponentDescriptor(componentKey);

    if (result == null && parentContainer != null) {
      result = parentContainer.getComponentDescriptor(componentKey);
    }

    return result;
  }
Exemple #3
0
  public Object lookup(String componentKey) throws ComponentLookupException {
    Object component = null;

    ComponentManager componentManager =
        componentManagerManager.findComponentManagerByComponentKey(componentKey);

    // The first time we lookup a component a component manager will not exist so we ask the
    // component manager manager to create a component manager for us.

    if (componentManager == null) {
      ComponentDescriptor descriptor = componentRepository.getComponentDescriptor(componentKey);

      if (descriptor == null) {
        if (parentContainer != null) {
          return parentContainer.lookup(componentKey);
        }

        getLogger().error("Nonexistent component: " + componentKey);

        String message =
            "Component descriptor cannot be found in the component repository: "
                + componentKey
                + ".";

        throw new ComponentLookupException(message);
      }

      componentManager = createComponentManager(descriptor);
    }

    try {
      component = componentManager.getComponent();
    } catch (ComponentInstantiationException e) {
      throw new ComponentLookupException(
          "Unable to lookup component '" + componentKey + "', it could not be created", e);
    } catch (ComponentLifecycleException e) {
      throw new ComponentLookupException(
          "Unable to lookup component '" + componentKey + "', it could not be started", e);
    }

    componentManagerManager.associateComponentWithComponentManager(component, componentManager);

    return component;
  }