1 package org.codehaus.plexus.container.initialization;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.codehaus.plexus.PlexusConstants;
20 import org.codehaus.plexus.component.factory.ComponentFactoryManager;
21 import org.codehaus.plexus.context.ContextException;
22 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
23
24
25
26
27 public class InitializeComponentFactoryManagerPhase extends AbstractCoreComponentInitializationPhase {
28 public void initializeCoreComponent(ContainerInitializationContext context)
29 throws ContainerInitializationException {
30 ComponentFactoryManager componentFactoryManager =
31 context.getContainerConfiguration().getComponentFactoryManager();
32
33 if (componentFactoryManager instanceof Contextualizable) {
34
35 context.getContainer().getContext().put(PlexusConstants.PLEXUS_KEY, context.getContainer());
36
37 try {
38 ((Contextualizable) componentFactoryManager)
39 .contextualize(context.getContainer().getContext());
40 } catch (ContextException e) {
41 throw new ContainerInitializationException("Error contextualization component factory manager.", e);
42 }
43 }
44
45 context.getContainer().setComponentFactoryManager(componentFactoryManager);
46 }
47 }