/** * Provide a description of the current {@link Scope}. * * @return a {@link ScopeDescriptor} describing the current {@link Scope} */ public static ScopeDescriptor describeCurrentScope() { return getCurrentScope().describeScope(); }
/** * Schedules a deadline at given {@code triggerDateTime} with given {@code deadlineName}. The returned * {@code scheduleId} and provided {@code deadlineName} combination can be used to cancel the scheduled deadline. * The scope within which this call is made will be retrieved by the DeadlineManager itself. * <p> * The given {@code messageOrPayload} may be any object, as well as a DeadlineMessage. In the latter case, the * instance provided is the donor for the payload and {@link org.axonframework.messaging.MetaData} of the actual * deadline being used. In the former case, the given {@code messageOrPayload} will be wrapped as the payload of a * {@link DeadlineMessage}. * </p> * * @param triggerDateTime A {@link java.time.Instant} denoting the moment to trigger the deadline handling * @param deadlineName A {@link String} representing the name of the deadline to schedule * @param messageOrPayload A {@link org.axonframework.messaging.Message} or payload for a message as an * {@link Object} * @return the {@code scheduleId} as a {@link String} to use when cancelling the schedule */ default String schedule(Instant triggerDateTime, String deadlineName, Object messageOrPayload) { return schedule(triggerDateTime, deadlineName, messageOrPayload, Scope.describeCurrentScope()); }
/** * {@link Scope} instance method to execute given {@code task} of type {@link Callable} in the context of this * Scope. This updates the thread's current scope before executing the task. If a scope is already registered with * the current thread that one will be temporarily replaced with this scope until the task completes. This method * returns the execution result of the task. * * @param task the task to execute of type {@link Callable} * @param <V> the type of execution result of the task * @return the execution result of type {@code V} * * @throws Exception if executing the task results in an exception */ protected <V> V executeWithResult(Callable<V> task) throws Exception { startScope(); try { return task.call(); } finally { endScope(); } }
/** * Get the current {@link AggregateLifecycle} instance for the current thread. If none exists an {@link * IllegalStateException} is thrown. * * @return the thread's current {@link AggregateLifecycle} */ protected static AggregateLifecycle getInstance() { return Scope.getCurrentScope(); }
/** * Get the current {@link SagaLifecycle} instance for the current thread. If none exists an {@link * IllegalStateException} is thrown. * * @return the thread's current {@link SagaLifecycle} */ protected static SagaLifecycle getInstance() { return Scope.getCurrentScope(); }
/** * Provide a description of the current {@link Scope}. * * @return a {@link ScopeDescriptor} describing the current {@link Scope} */ public static ScopeDescriptor describeCurrentScope() { return getCurrentScope().describeScope(); }
/** * Get the current {@link SagaLifecycle} instance for the current thread. If none exists an {@link * IllegalStateException} is thrown. * * @return the thread's current {@link SagaLifecycle} */ protected static SagaLifecycle getInstance() { return Scope.getCurrentScope(); }
/** * {@link Scope} instance method to execute given {@code task} of type {@link Callable} in the context of this * Scope. This updates the thread's current scope before executing the task. If a scope is already registered with * the current thread that one will be temporarily replaced with this scope until the task completes. This method * returns the execution result of the task. * * @param task the task to execute of type {@link Callable} * @param <V> the type of execution result of the task * @return the execution result of type {@code V} * * @throws Exception if executing the task results in an exception */ protected <V> V executeWithResult(Callable<V> task) throws Exception { startScope(); try { return task.call(); } finally { endScope(); } }
/** * Schedules a deadline after the given {@code triggerDuration}. The returned {@code scheduleId} and provided * {@code deadlineName} combination can be used to cancel the scheduled deadline. * The scope within which this call is made will be retrieved by the DeadlineManager * itself. * <p> * The given {@code messageOrPayload} may be any object, as well as a DeadlineMessage. In the latter case, the * instance provided is the donor for the payload and {@link org.axonframework.messaging.MetaData} of the actual * deadline being used. In the former case, the given {@code messageOrPayload} will be wrapped as the payload of a * {@link DeadlineMessage}. * </p> * * @param triggerDuration A {@link java.time.Duration} describing the waiting period before handling the deadline * @param deadlineName A {@link String} representing the name of the deadline to schedule * @param messageOrPayload A {@link org.axonframework.messaging.Message} or payload for a message as an * {@link Object} * @return the {@code scheduleId} as a {@link String} to use when cancelling the schedule */ default String schedule(Duration triggerDuration, String deadlineName, Object messageOrPayload) { return schedule(triggerDuration, deadlineName, messageOrPayload, Scope.describeCurrentScope()); }
/** * Provide a description of the current {@link Scope}. * * @return a {@link ScopeDescriptor} describing the current {@link Scope} */ public static ScopeDescriptor describeCurrentScope() { return getCurrentScope().describeScope(); }
/** * Get the current {@link AggregateLifecycle} instance for the current thread. If none exists an {@link * IllegalStateException} is thrown. * * @return the thread's current {@link AggregateLifecycle} */ protected static AggregateLifecycle getInstance() { return Scope.getCurrentScope(); }
/** * {@link Scope} instance method to execute given {@code task} of type {@link Callable} in the context of this * Scope. This updates the thread's current scope before executing the task. If a scope is already registered with * the current thread that one will be temporarily replaced with this scope until the task completes. This method * returns the execution result of the task. * * @param task the task to execute of type {@link Callable} * @param <V> the type of execution result of the task * @return the execution result of type {@code V} * * @throws Exception if executing the task results in an exception */ protected <V> V executeWithResult(Callable<V> task) throws Exception { startScope(); try { return task.call(); } finally { endScope(); } }
/** * Schedules a deadline after the given {@code triggerDuration}. The returned {@code scheduleId} and provided * {@code deadlineName} combination can be used to cancel the scheduled deadline. * The scope within which this call is made will be retrieved by the DeadlineManager * itself. * <p> * The given {@code messageOrPayload} may be any object, as well as a DeadlineMessage. In the latter case, the * instance provided is the donor for the payload and {@link org.axonframework.messaging.MetaData} of the actual * deadline being used. In the former case, the given {@code messageOrPayload} will be wrapped as the payload of a * {@link DeadlineMessage}. * </p> * * @param triggerDuration A {@link java.time.Duration} describing the waiting period before handling the deadline * @param deadlineName A {@link String} representing the name of the deadline to schedule * @param messageOrPayload A {@link org.axonframework.messaging.Message} or payload for a message as an * {@link Object} * @return the {@code scheduleId} as a {@link String} to use when cancelling the schedule */ default String schedule(Duration triggerDuration, String deadlineName, Object messageOrPayload) { return schedule(triggerDuration, deadlineName, messageOrPayload, Scope.describeCurrentScope()); }
/** * Get the current {@link SagaLifecycle} instance for the current thread. If none exists an {@link * IllegalStateException} is thrown. * * @return the thread's current {@link SagaLifecycle} */ protected static SagaLifecycle getInstance() { return Scope.getCurrentScope(); }
/** * Schedules a deadline at given {@code triggerDateTime} with given {@code deadlineName}. The returned * {@code scheduleId} and provided {@code deadlineName} combination can be used to cancel the scheduled deadline. * The scope within which this call is made will be retrieved by the DeadlineManager itself. * <p> * The given {@code messageOrPayload} may be any object, as well as a DeadlineMessage. In the latter case, the * instance provided is the donor for the payload and {@link org.axonframework.messaging.MetaData} of the actual * deadline being used. In the former case, the given {@code messageOrPayload} will be wrapped as the payload of a * {@link DeadlineMessage}. * </p> * * @param triggerDateTime A {@link java.time.Instant} denoting the moment to trigger the deadline handling * @param deadlineName A {@link String} representing the name of the deadline to schedule * @param messageOrPayload A {@link org.axonframework.messaging.Message} or payload for a message as an * {@link Object} * @return the {@code scheduleId} as a {@link String} to use when cancelling the schedule */ default String schedule(Instant triggerDateTime, String deadlineName, Object messageOrPayload) { return schedule(triggerDateTime, deadlineName, messageOrPayload, Scope.describeCurrentScope()); }
/** * Get the current {@link AggregateLifecycle} instance for the current thread. If none exists an {@link * IllegalStateException} is thrown. * * @return the thread's current {@link AggregateLifecycle} */ protected static AggregateLifecycle getInstance() { return Scope.getCurrentScope(); }
/** * Schedules a deadline at given {@code triggerDateTime} with given {@code deadlineName}. The returned * {@code scheduleId} and provided {@code deadlineName} combination can be used to cancel the scheduled deadline. * The scope within which this call is made will be retrieved by the DeadlineManager itself. * <p> * The given {@code messageOrPayload} may be any object, as well as a DeadlineMessage. In the latter case, the * instance provided is the donor for the payload and {@link org.axonframework.messaging.MetaData} of the actual * deadline being used. In the former case, the given {@code messageOrPayload} will be wrapped as the payload of a * {@link DeadlineMessage}. * </p> * * @param triggerDateTime A {@link java.time.Instant} denoting the moment to trigger the deadline handling * @param deadlineName A {@link String} representing the name of the deadline to schedule * @param messageOrPayload A {@link org.axonframework.messaging.Message} or payload for a message as an * {@link Object} * @return the {@code scheduleId} as a {@link String} to use when cancelling the schedule */ default String schedule(Instant triggerDateTime, String deadlineName, Object messageOrPayload) { return schedule(triggerDateTime, deadlineName, messageOrPayload, Scope.describeCurrentScope()); }
/** * Schedules a deadline after the given {@code triggerDuration}. The returned {@code scheduleId} and provided * {@code deadlineName} combination can be used to cancel the scheduled deadline. * The scope within which this call is made will be retrieved by the DeadlineManager * itself. * <p> * The given {@code messageOrPayload} may be any object, as well as a DeadlineMessage. In the latter case, the * instance provided is the donor for the payload and {@link org.axonframework.messaging.MetaData} of the actual * deadline being used. In the former case, the given {@code messageOrPayload} will be wrapped as the payload of a * {@link DeadlineMessage}. * </p> * * @param triggerDuration A {@link java.time.Duration} describing the waiting period before handling the deadline * @param deadlineName A {@link String} representing the name of the deadline to schedule * @param messageOrPayload A {@link org.axonframework.messaging.Message} or payload for a message as an * {@link Object} * @return the {@code scheduleId} as a {@link String} to use when cancelling the schedule */ default String schedule(Duration triggerDuration, String deadlineName, Object messageOrPayload) { return schedule(triggerDuration, deadlineName, messageOrPayload, Scope.describeCurrentScope()); }