use of com.example.helloworld.db.mongo.MongoManaged in project FrameworkBenchmarks by TechEmpower.
the class HelloMongoService method run.
@Override
public void run(HelloMongoConfiguration config, Environment environment) throws UnknownHostException {
final MongoClient mongoClient = config.getMongo().build();
environment.lifecycle().manage(new MongoManaged(mongoClient));
final DB db = mongoClient.getDB(config.getMongo().getDb());
final ObjectMapper mongoJackMapper = MongoJackModule.configure(Jackson.newObjectMapper());
final JacksonDBCollection<World, Integer> worlds = JacksonDBCollection.wrap(db.getCollection("world"), World.class, Integer.class, mongoJackMapper);
final JacksonDBCollection<Fortune, Integer> fortunes = JacksonDBCollection.wrap(db.getCollection("fortune"), Fortune.class, Integer.class, mongoJackMapper);
// Test types 2, 3 & 5: Single database query, Multiple database queries & Database updates
environment.jersey().register(new WorldResource(new WorldMongoImpl(worlds)));
// Test type 4: Fortunes
environment.jersey().register(new FortuneResource(new FortuneMongoImpl(fortunes)));
}
Aggregations