Created
February 14, 2018 22:02
-
-
Save ljnelson/cbcaa74e9726a3c6c1e77b09034b5573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final <T extends HasMetadata, X extends Listable<? extends KubernetesResourceList> & VersionWatchable<? extends Closeable, Watcher<T>>> void startControllers(@Observes @Initialized(ApplicationScoped.class) @Priority(LIBRARY_AFTER) final Object ignored, final BeanManager beanManager) { | |
if (beanManager != null) { | |
for (final Bean<?> bean : this.beans) { | |
assert bean != null; | |
final Set<Annotation> qualifiers = bean.getQualifiers(); | |
final Map<Object, T> knownObjects = new HashMap<>(); | |
final EventDistributor<T> eventDistributor = new EventDistributor<>(knownObjects); | |
eventDistributor.addConsumer(new CDIEventDistributor<T>(qualifiers, null /* no NotificationOptions; TODO */, this.syncNeeded, this.asyncNeeded)); | |
@SuppressWarnings("unchecked") // we know an Operation is of type X | |
final X contextualReference = (X)beanManager.getReference(bean, getOperationType(bean), beanManager.createCreationalContext(bean)); | |
final Controller<T> controller = new Controller<>(contextualReference, knownObjects, eventDistributor); | |
controller.start(); | |
this.controllers.add(controller); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment