protected void initializePhases() throws PlexusContainerException { PlexusConfiguration initializationConfiguration = configuration.getChild("container-initialization"); ContainerInitializationContext initializationContext = new ContainerInitializationContext(this, classWorld, containerRealm, configuration); // PLXAPI: I think we might only ever need one of these so maybe we can create it with a // constructor // and store it. ComponentConfigurator c = new BasicComponentConfigurator(); try { c.configureComponent(this, initializationConfiguration, containerRealm); } catch (ComponentConfigurationException e) { throw new PlexusContainerException( "Error setting container initialization initializationPhases.", e); } for (Iterator iterator = initializationPhases.iterator(); iterator.hasNext(); ) { ContainerInitializationPhase phase = (ContainerInitializationPhase) iterator.next(); try { phase.execute(initializationContext); } catch (ContainerInitializationException e) { throw new PlexusContainerException("Error initializaing container in " + phase + ".", e); } } }
public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) throws PhaseExecutionException { try { ComponentDescriptor<?> descriptor = manager.getComponentDescriptor(); String configuratorId = descriptor.getComponentConfigurator(); if (StringUtils.isEmpty(configuratorId)) { configuratorId = DEFAULT_CONFIGURATOR_ID; } ComponentConfigurator componentConfigurator = manager.getContainer().lookup(ComponentConfigurator.class, configuratorId); PlexusConfiguration configuration = manager.getContainer().getConfigurationSource().getConfiguration(descriptor); if (configuration != null) { ClassRealm realm = manager.getRealm(); componentConfigurator.configureComponent(object, configuration, realm); } } catch (ComponentLookupException e) { throw new PhaseExecutionException( "Unable to auto-configure component as its configurator could not be found", e); } catch (ComponentConfigurationException e) { throw new PhaseExecutionException("Unable to auto-configure component", e); } }
public ServiceConfiguration buildConfiguration( PlexusConfiguration serviceConfiguration, ClassRealm realm) throws ComponentConfigurationException { ServiceConfiguration configuration = new ServiceConfiguration(); configurator.configureComponent(configuration, serviceConfiguration, realm); return configuration; }