/** * Calls the observer method, passing the given event context. * <p> * The container should always call this method, but the default implementation delegates to {@link #notify(Object)}. * <p> * The implementation of this method for a custom observer method is responsible for deciding whether to call the method if * the {@link #getReception()} returns {@link Reception#IF_EXISTS}. * * @param eventContext {@link EventContext} used to notify observers */ public default void notify(EventContext<T> eventContext) { notify(eventContext.getEvent()); }
/** * Calls the observer method, passing the given event context. * <p> * The container should always call this method, but the default implementation delegates to {@link #notify(Object)}. * <p> * The implementation of this method for a custom observer method is responsible for deciding whether to call the method if * the {@link #getReception()} returns {@link Reception#IF_EXISTS}. * * @param eventContext {@link EventContext} used to notify observers */ public default void notify(EventContext<T> eventContext) { notify(eventContext.getEvent()); }
/** * Calls the observer method, passing the given event context. * <p> * The container should always call this method, but the default implementation delegates to {@link #notify(Object)}. * <p> * The implementation of this method for a custom observer method is responsible for deciding whether to call the method if * the {@link #getReception()} returns {@link Reception#IF_EXISTS}. * * @param eventContext {@link EventContext} used to notify observers */ public default void notify(EventContext<T> eventContext) { notify(eventContext.getEvent()); }
/** * Calls the observer method, passing the given event context. * <p> * The container should always call this method, but the default implementation delegates to {@link #notify(Object)}. * <p> * The implementation of this method for a custom observer method is responsible for deciding whether to call the method if * the {@link #getReception()} returns {@link Reception#IF_EXISTS}. * * @param eventContext {@link EventContext} used to notify observers */ public default void notify(EventContext<T> eventContext) { notify(eventContext.getEvent()); }
/** * Call the observer method with the given eventContext. * @param eventContext */ default void notify(EventContext<T> eventContext) { if (eventContext != null) { notify(eventContext.getEvent()); } }
/** * Call the observer method with the given eventContext. * @param eventContext */ default void notify(EventContext<T> eventContext) { if (eventContext != null) { notify(eventContext.getEvent()); } }
/** * Call the observer method with the given eventContext. * @param eventContext */ default void notify(EventContext<T> eventContext) { if (eventContext != null) { notify(eventContext.getEvent()); } }
/** * Calls the observer method, passing the given event context. * <p> * The container should always call this method, but the default implementation delegates to {@link #notify(Object)}. * <p> * The implementation of this method for a custom observer method is responsible for deciding whether to call the method if * the {@link #getReception()} returns {@link Reception#IF_EXISTS}. * * @param eventContext {@link EventContext} used to notify observers */ public default void notify(EventContext<T> eventContext) { notify(eventContext.getEvent()); }
/** * Calls the observer method, passing the given event context. * <p> * The container should always call this method, but the default implementation delegates to {@link #notify(Object)}. * <p> * The implementation of this method for a custom observer method is responsible for deciding whether to call the method if * the {@link #getReception()} returns {@link Reception#IF_EXISTS}. * * @param eventContext {@link EventContext} used to notify observers */ public default void notify(EventContext<T> eventContext) { notify(eventContext.getEvent()); }
/** * Calls the observer method, passing the given event context. * <p> * The container should always call this method, but the default implementation delegates to {@link #notify(Object)}. * <p> * The implementation of this method for a custom observer method is responsible for deciding whether to call the method if * the {@link #getReception()} returns {@link Reception#IF_EXISTS}. * * @param eventContext {@link EventContext} used to notify observers */ public default void notify(EventContext<T> eventContext) { notify(eventContext.getEvent()); }
@Override public final void accept(final EventContext<T> eventContext) { try { this.kubernetesEventContext.setActive(true); this.priorContext.activate(Objects.requireNonNull(eventContext).getEvent()); // thread-specific this.observerMethod.notify(eventContext); } finally { this.priorContext.deactivate(); // thread-specific this.kubernetesEventContext.setActive(false); } }
@Test(groups = { INTEGRATION, PERSISTENCE }) @SpecAssertions({ @SpecAssertion(section = OBSERVER_NOTIFICATION, id = "fa"), @SpecAssertion(section = OBSERVER_NOTIFICATION, id = "fb") }) public void testCustomTransactionalObserver() throws Exception { ActionSequence.reset(); // GiraffeObserver 2x, GiraffeCustomObserver 1x assertEquals(getCurrentManager().resolveObserverMethods(new Giraffe()).size(), 3); // Transactional invocation giraffeService.feed(); // Test ObserverMethod.notify() was called assertNotNull(extension.getAnyGiraffeObserver().getReceivedPayload()); assertEquals(Giraffe.class, extension.getAnyGiraffeObserver().getReceivedPayload().getEvent().getClass()); assertNotNull(extension.getAnyGiraffeObserver().getReceivedPayload().getMetadata()); // Test ObserverMethod.getTransactionPhase() was called assertTrue(extension.getAnyGiraffeObserver().isTransactionPhaseCalled()); // Test custom observer received notification during the after completion phase (after succesfull commit) // BEFORE_COMPLETION must be fired at the beginning of the commit (after checkpoint) // AFTER_SUCCESS and AFTER_COMPLETION must be fired after BEFORE_COMPLETION // AFTER_FAILURE is not fired ActionSequence.getSequence().beginsWith("checkpoint", TransactionPhase.BEFORE_COMPLETION.toString()); ActionSequence.getSequence().assertDataContainsAll(TransactionPhase.AFTER_SUCCESS.toString(), TransactionPhase.AFTER_COMPLETION.toString()); }
public void notify(EventContext<T> eventContext) T event = eventContext.getEvent(); EventMetadata metadata = eventContext.getMetadata();