As shown earlier, a bean can have different alternatives, by introducing one interface and providing different implementations, each with a different qualifier. When injecting a reference to this interface in another bean, you can annotate your injection point with the qualifier for the implementation you desire. One interesting question is, can we specify which implementation to inject according to some runtime parameters, such as a user-specified choice?
For example, suppose a user is engaged in a payment workflow process. The first step is that the user will choose which payment method they prefer and where the next step they will actually perform the payment transaction. Suppose you have a PaymentStrategy interface with different bean implementations for a credit card, PayPal, and check payment strategies. Can we specify which bean implementation to reference...