Search in sources :

Example 1 with WorldResource

use of com.example.helloworld.resources.WorldResource in project FrameworkBenchmarks by TechEmpower.

the class HelloJDBIService method run.

@Override
public void run(HelloWorldConfiguration config, Environment environment) {
    final JdbiFactory factory = new JdbiFactory();
    final Jdbi jdbi = factory.build(environment, config.getDatabaseConfiguration(), "RDBMS");
    // Test type 1: JSON serialization and Test type 6: Plaintext are tested against HelloWorldService class
    // Test types 2, 3 & 5: Single database query, Multiple database queries & Database updates
    environment.jersey().register(new WorldResource(new WorldRepository(jdbi)));
    // Test type 4: Fortunes
    environment.jersey().register(new FortuneResource(new FortuneRepository(jdbi)));
}
Also used : Jdbi(org.jdbi.v3.core.Jdbi) WorldResource(com.example.helloworld.resources.WorldResource) JdbiFactory(io.dropwizard.jdbi3.JdbiFactory) FortuneResource(com.example.helloworld.resources.FortuneResource) WorldRepository(com.example.helloworld.db.jdbi.WorldRepository) FortuneRepository(com.example.helloworld.db.jdbi.FortuneRepository)

Example 2 with WorldResource

use of com.example.helloworld.resources.WorldResource 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)));
}
Also used : WorldResource(com.example.helloworld.resources.WorldResource) World(com.example.helloworld.db.model.World) FortuneMongoImpl(com.example.helloworld.db.mongo.FortuneMongoImpl) MongoClient(com.mongodb.MongoClient) FortuneResource(com.example.helloworld.resources.FortuneResource) MongoManaged(com.example.helloworld.db.mongo.MongoManaged) Fortune(com.example.helloworld.db.model.Fortune) WorldMongoImpl(com.example.helloworld.db.mongo.WorldMongoImpl) DB(com.mongodb.DB) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with WorldResource

use of com.example.helloworld.resources.WorldResource in project FrameworkBenchmarks by TechEmpower.

the class HelloWorldService method run.

@Override
public void run(HelloWorldConfiguration config, Environment environment) throws UnknownHostException {
    if ("com.mysql.cj.jdbc.Driver".equals(config.getDatabaseConfiguration().getDriverClass())) {
        // register below for default dropwizard test only
        // Test type 1: JSON serialization
        environment.jersey().register(new JsonResource());
        // Test type 6: Plaintext
        environment.jersey().register(new TextResource());
    }
    // Test types 2, 3 & 5: Single database query, Multiple database queries & Database updates
    environment.jersey().register(new WorldResource(new WorldHibernateImpl(hibernate.getSessionFactory())));
    // Test type 4: Fortunes
    environment.jersey().register(new FortuneResource(new FortuneHibernateImpl(hibernate.getSessionFactory())));
}
Also used : TextResource(com.example.helloworld.resources.TextResource) WorldResource(com.example.helloworld.resources.WorldResource) FortuneResource(com.example.helloworld.resources.FortuneResource) JsonResource(com.example.helloworld.resources.JsonResource) FortuneHibernateImpl(com.example.helloworld.db.hibernate.FortuneHibernateImpl) WorldHibernateImpl(com.example.helloworld.db.hibernate.WorldHibernateImpl)

Aggregations

FortuneResource (com.example.helloworld.resources.FortuneResource)3 WorldResource (com.example.helloworld.resources.WorldResource)3 FortuneHibernateImpl (com.example.helloworld.db.hibernate.FortuneHibernateImpl)1 WorldHibernateImpl (com.example.helloworld.db.hibernate.WorldHibernateImpl)1 FortuneRepository (com.example.helloworld.db.jdbi.FortuneRepository)1 WorldRepository (com.example.helloworld.db.jdbi.WorldRepository)1 Fortune (com.example.helloworld.db.model.Fortune)1 World (com.example.helloworld.db.model.World)1 FortuneMongoImpl (com.example.helloworld.db.mongo.FortuneMongoImpl)1 MongoManaged (com.example.helloworld.db.mongo.MongoManaged)1 WorldMongoImpl (com.example.helloworld.db.mongo.WorldMongoImpl)1 JsonResource (com.example.helloworld.resources.JsonResource)1 TextResource (com.example.helloworld.resources.TextResource)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DB (com.mongodb.DB)1 MongoClient (com.mongodb.MongoClient)1 JdbiFactory (io.dropwizard.jdbi3.JdbiFactory)1 Jdbi (org.jdbi.v3.core.Jdbi)1