@@ -60,13 +60,32 @@ public ComponentRuntime(
60
60
CycleDetector .detect (componentsToAdd );
61
61
62
62
for (Component <?> component : componentsToAdd ) {
63
- register (component );
64
- }
65
- validateDependencies ();
63
+ Lazy <?> lazy =
64
+ new Lazy <>(
65
+ () ->
66
+ component .getFactory ().create (new RestrictedComponentContainer (component , this )));
66
67
68
+ components .put (component , lazy );
69
+ }
70
+ processInstanceComponents ();
67
71
processSetComponents ();
68
72
}
69
73
74
+ private void processInstanceComponents () {
75
+ for (Map .Entry <Component <?>, Lazy <?>> entry : components .entrySet ()) {
76
+ Component <?> component = entry .getKey ();
77
+ if (!component .isValue ()) {
78
+ return ;
79
+ }
80
+
81
+ Lazy <?> lazy = entry .getValue ();
82
+ for (Class <?> anInterface : component .getProvidedInterfaces ()) {
83
+ lazyInstanceMap .put (anInterface , lazy );
84
+ }
85
+ }
86
+ validateDependencies ();
87
+ }
88
+
70
89
/** Populates lazySetMap to make set components available for consumption via set dependencies. */
71
90
private void processSetComponents () {
72
91
Map <Class <?>, Set <Lazy <?>>> setIndex = new HashMap <>();
@@ -140,20 +159,6 @@ public void initializeEagerComponents(boolean isDefaultApp) {
140
159
eventBus .enablePublishingAndFlushPending ();
141
160
}
142
161
143
- private <T > void register (Component <T > component ) {
144
- Lazy <T > lazy =
145
- new Lazy <>(
146
- () -> component .getFactory ().create (new RestrictedComponentContainer (component , this )));
147
-
148
- components .put (component , lazy );
149
- if (!component .isValue ()) {
150
- return ;
151
- }
152
- for (Class <? super T > anInterface : component .getProvidedInterfaces ()) {
153
- lazyInstanceMap .put (anInterface , lazy );
154
- }
155
- }
156
-
157
162
private void validateDependencies () {
158
163
for (Component <?> component : components .keySet ()) {
159
164
for (Dependency dependency : component .getDependencies ()) {
0 commit comments