private void processCoreComponentConfiguration( String role, BasicComponentConfigurator configurator, PlexusConfiguration c) throws ComponentConfigurationException { String implementation = c.getAttribute("implementation", null); if (implementation == null) { String msg = "Core component: '" + role + "' + which is needed by plexus to function properly cannot " + "be instantiated. Implementation attribute was not specified in plexus.conf." + "This is highly irregular, your plexus JAR is most likely corrupt."; throw new ComponentConfigurationException(msg); } ComponentDescriptor componentDescriptor = new ComponentDescriptor(); componentDescriptor.setRole(role); componentDescriptor.setImplementation(implementation); PlexusConfiguration configuration = new XmlPlexusConfiguration("configuration"); configuration.addChild(c); try { configurator.configureComponent(this, configuration, plexusRealm); } catch (ComponentConfigurationException e) { // TODO: don't like rewrapping the same exception, but better than polluting this all through // the config code String message = "Error configuring component: " + componentDescriptor.getHumanReadableKey(); throw new ComponentConfigurationException(message, e); } }
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; }