Created
September 23, 2014 19:10
-
-
Save lordofthejars/3180b2ccfbd765b7ac5c 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 MongoDBProducer { | |
| @Resource(name = "mongoUri") | |
| private MongoClientURI mongoClientURI; | |
| private DB db; | |
| @PostConstruct | |
| public void init() throws UnknownHostException { | |
| MongoClient mongoClient = new MongoClient(mongoClientURI); | |
| db = mongoClient.getDB(mongoClientURI.getDatabase()); | |
| } | |
| @Produces | |
| public DB createDB() { | |
| return db; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment