Created
March 6, 2016 18:53
-
-
Save derekbassett/712698cd6424e5ff04da to your computer and use it in GitHub Desktop.
Revisions
-
derekbassett created this gist
Mar 6, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ package io.github.derekbassett.exampledropwizard import com.mongodb.MongoClient; import io.dropwizard.Application; import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; import org.glassfish.hk2.utilities.binding.AbstractBinder; public class ExampleDropwizardApplication extends Application<ExampleDropwizardApplicationConfiguration> { public static void main(final String[] args) throws Exception { new ExampleDropwizardApplication().run(args); } @Override public void initialize(final Bootstrap<ExampleDropwizardApplicationConfiguration> bootstrap) { } @Override public void run(final ExampleDropwizardApplicationConfiguration configuration, final Environment environment) throws Exception { final MongoClient mongoClient = configuration.getMongoClientFactory().buildClient(environment, "mongo"); environment.jersey().register(new AbstractBinder() { @Override protected void configure() { bind(configuration).to(ExampleDropwizardApplicationConfiguration.class); bind(mongoClient).to(mongoClient); } }); } }