Пример #1
0
  public static ComponentDescriptor buildComponentDescriptor(PlexusConfiguration configuration)
      throws Exception {
    ComponentDescriptor cd = new ComponentDescriptor();

    cd.setRole(configuration.getChild("role").getValue());

    cd.setRoleHint(configuration.getChild("role-hint").getValue());

    cd.setImplementation(configuration.getChild("implementation").getValue());

    cd.setVersion(configuration.getChild("version").getValue());

    cd.setComponentType(configuration.getChild("component-type").getValue());

    cd.setInstantiationStrategy(configuration.getChild("instantiation-strategy").getValue());

    cd.setLifecycleHandler(configuration.getChild("lifecycle-handler").getValue());

    cd.setComponentProfile(configuration.getChild("component-profile").getValue());

    cd.setComponentComposer(configuration.getChild("component-composer").getValue());

    cd.setComponentFactory(configuration.getChild("component-factory").getValue());

    cd.setDescription(configuration.getChild("description").getValue());

    cd.setAlias(configuration.getChild("alias").getValue());

    String s = configuration.getChild("isolated-realm").getValue();

    if (s != null) {
      cd.setIsolatedRealm(s.equals("true") ? true : false);
    }

    // ----------------------------------------------------------------------
    // Here we want to look for directives for inlining external
    // configurations. we probably want to take them from files or URLs.
    // ----------------------------------------------------------------------

    cd.setConfiguration(configuration.getChild("configuration"));

    // ----------------------------------------------------------------------
    // Requirements
    // ----------------------------------------------------------------------

    PlexusConfiguration[] requirements =
        configuration.getChild("requirements").getChildren("requirement");

    for (int i = 0; i < requirements.length; i++) {
      PlexusConfiguration requirement = requirements[i];

      ComponentRequirement cr = new ComponentRequirement();

      cr.setRole(requirement.getChild("role").getValue());

      cr.setRoleHint(requirement.getChild("role-hint").getValue());

      cr.setFieldName(requirement.getChild("field-name").getValue());

      cd.addRequirement(cr);
    }

    return cd;
  }