Last active
August 29, 2015 14:06
-
-
Save lordofthejars/bb79d12840c8d18d1baf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @ApplicationScoped | |
| public class MongoCollectionProducer { | |
| @Inject | |
| DB mongoDb; | |
| Jongo jongo; | |
| @PostConstruct | |
| public void initialize() throws UnknownHostException { | |
| jongo = new Jongo(mongoDb); | |
| } | |
| @Produces | |
| @JongoCollection | |
| MongoCollection collection(InjectionPoint injectionPoint) { | |
| JongoCollection jongoCollectionAnnotation = Reflection.annotation(injectionPoint | |
| .getQualifiers(), JongoCollection.class); | |
| if(jongoCollectionAnnotation != null) { | |
| String collectionName = jongoCollectionAnnotation.value(); | |
| return jongo.getCollection(collectionName); | |
| } | |
| throw new IllegalArgumentException(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment