void addSecurityHandlerObservers(@Observes final AfterBeanDiscovery afterBeanDiscovery) { final ObserverMethodConfigurator<OnConnection> onConnection = afterBeanDiscovery.addObserverMethod(); onConnection.observedType(OnConnection.class).notifyWith(this::onConnection); final ObserverMethodConfigurator<OnCommand> onCommand = afterBeanDiscovery.addObserverMethod(); onCommand.observedType(OnCommand.class).notifyWith(this::onCommand); }
void observesPearPOM(@Observes ProcessObserverMethod<Pear, FruitObserver> event) { // add @Ripe and @Delicious to the observed type // make observer asynchronous // set priority event.configureObserverMethod() .addQualifiers(Ripe.RipeLiteral.INSTANCE, Delicious.DeliciousLiteral.INSTANCE) .async(true) .priority(ObserverMethod.DEFAULT_PRIORITY + 100); }
void observesOrangePOM(@Observes ProcessObserverMethod<Orange, FruitObserver> event) { // replace qualifiers // set reception to Reception.IF_EXISTS // set transaction phase to TransactionPhase.AFTER_SUCCESS event.configureObserverMethod() .qualifiers(Delicious.DeliciousLiteral.INSTANCE) .reception(Reception.IF_EXISTS) .transactionPhase(TransactionPhase.AFTER_SUCCESS); }
void observesABD(@Observes AfterBeanDiscovery abd) throws NoSuchMethodException { abd.<Fruit>addObserverMethod().read(fruitObserverMethod).beanClass(FruitObserver.class).observedType(Banana.class) .addQualifiers(Ripe.RipeLiteral.INSTANCE, Any.Literal.INSTANCE) .notifyWith((b) -> { newBananaObserverNotified.set(true); }); abd.addObserverMethod().read(melonMethod).observedType(Melon.class).notifyWith(m -> { newMelonObserverNotified.set(true); }); abd.addObserverMethod().read(peachObserver).beanClass(FruitObserver.class).observedType(Peach.class).notifyWith((a) -> { newPeachObserverNotified.set(true); }); abd.addObserverMethod().observedType(Papaya.class).reception(Reception.ALWAYS).notifyWith(eventContext -> newPapayaObserverNotified.set(true));
void observesPineapplePOM(@Observes ProcessObserverMethod<Pineapple, FruitObserver> event) { event.configureObserverMethod() .addQualifier(Delicious.DeliciousLiteral.INSTANCE) .notifyWith((eventConsumer) -> { pineAppleQualifiers = eventConsumer.getMetadata().getQualifiers(); consumerNotified.set(true); }); }
if (kubernetesEventSelectors != null && !kubernetesEventSelectors.isEmpty()) { event.configureObserverMethod() .notifyWith(new Notifier<>(this.priorContext, this.kubernetesEventContext, observerMethod)); if (observerMethod.isAsync()) { if (!this.asyncNeeded) {
void observePOM(@Observes ProcessObserverMethod<Box, Worker> event) { event.configureObserverMethod().async(true); try { event.setObserverMethod(new BoxObserverMethod()); } catch (IllegalStateException e) { // expected should blow up with ISE POM_ISE_CAUGHT = true; } }
void observesFooPOM(@Observes ProcessObserverMethod<Bar, Foo> event){ ObserverMethodConfigurator<Bar> observerMethodConfigurator = event.configureObserverMethod(); observerMethodConfigurator.priority(1000); sameOMConfiguratorReturned.set(observerMethodConfigurator.equals(event.configureObserverMethod())); }
void observePOMReverse(@Observes ProcessObserverMethod<Box, Worker> event) { event.setObserverMethod(new BoxObserverMethod()); try { event.configureObserverMethod().async(true); } catch (IllegalStateException e) { // expected should blow up with ISE POM_REVERSE_ISE_CAUGHT = true; } } }