Created
April 22, 2015 08:39
-
-
Save karlkilden/e69282b67c370de92711 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EndUsage { | |
@Inject | |
private MyBean myBean; | |
// Use the dynamic bean | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Alternative // This is not the one we want injected | |
public class MyBean { | |
// Add implementation here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyBeanProducer { | |
private MyBean bean; | |
@Produces | |
public MyBean myBeanProducer() { | |
return bean; | |
} | |
@PostConstruct | |
private void determineBean() { | |
bean = new MyBean(); // This could be any logic you want. MyBean could be the interface and here you could choose the implemtation | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment