You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A very common requirement is to be able to group services of the same contract into "buckets" that will determine how they are used. To facilitate this hk2 provides the @Rank annotation that allows an explicit integer-based ordering of services. The use of integers allows for arbitrary ordering but it can also be error-prone and isn't really type-safe. It would be nice-to-have the ability to specify custom annotations that could indicate a numerical rank.
This might work like the following:
@RankIndicator
@Rank(30_000)
@Documented
@Retention(RUNTIME)
public @interface HighPriority {}
@RankIndicator
@Rank(20_000)
@Documented
@Retention(RUNTIME)
public @interface NormalPriority {}
@RankIndicator
@Rank(10_000)
@Documented
@Retention(RUNTIME)
public @interface LowPriority {}
This would define certain annotations as being Rank indicators. Services annotated with these Rank indicators would be given the Rank specified on the Rank indicator annotation eg:
@HighPriority
final class ConsoleNotifier implements Notifier { ... }
The service ConsoleLogger would have the rank of 30_000 and would only be used for sending high-priority notifications.
The text was updated successfully, but these errors were encountered:
A very common requirement is to be able to group services of the same contract into "buckets" that will determine how they are used. To facilitate this hk2 provides the
@Rank
annotation that allows an explicit integer-based ordering of services. The use of integers allows for arbitrary ordering but it can also be error-prone and isn't really type-safe. It would be nice-to-have the ability to specify custom annotations that could indicate a numerical rank.This might work like the following:
This would define certain annotations as being Rank indicators. Services annotated with these Rank indicators would be given the Rank specified on the Rank indicator annotation eg:
The service ConsoleLogger would have the rank of 30_000 and would only be used for sending high-priority notifications.
The text was updated successfully, but these errors were encountered: