From 7da45de9847dcbb29eabe6f710da1ac49b66895b Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Wed, 22 Sep 2021 12:25:32 +0200 Subject: [PATCH] add BeanConfigurator.priority This is to allow setting a priority for synthetic beans created using `BeanConfigurator`. I briefly considered if `priority` should be added to `BeanAttributesConfigurator` as well, but that would have a ripple effect. It also doesn't reflect the present reality. A custom `Bean` implementation can be added a priority by implementing the `Prioritized` interface. Adding only `BeanConfigurator.priority` is a perfect mirror of that in the configurator API. --- .../spi/configurator/BeanConfigurator.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api/src/main/java/jakarta/enterprise/inject/spi/configurator/BeanConfigurator.java b/api/src/main/java/jakarta/enterprise/inject/spi/configurator/BeanConfigurator.java index d2594db0b..de5992298 100644 --- a/api/src/main/java/jakarta/enterprise/inject/spi/configurator/BeanConfigurator.java +++ b/api/src/main/java/jakarta/enterprise/inject/spi/configurator/BeanConfigurator.java @@ -316,4 +316,20 @@ public interface BeanConfigurator { */ BeanConfigurator alternative(boolean value); + /** + * Set the priority of the configured bean. + * By default, the configured bean does not have a priority. + *

+ * This is equivalent to putting the {@link jakarta.annotation.Priority Priority} + * annotation to an actual bean class or making a custom + * {@link jakarta.enterprise.inject.spi.Bean Bean} class implement + * {@link jakarta.enterprise.inject.spi.Prioritized Prioritized}. + *

+ * This method has no effect if the configured bean is not an alternative. + * + * @param priority the priority value + * @return self + */ + BeanConfigurator priority(int priority); + }