Last active
July 12, 2018 14:20
-
-
Save john-nash-rs/eb523c16e439ec0012ad11989276a02a to your computer and use it in GitHub Desktop.
This file contains 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
import io.dropwizard.Application; | |
import io.dropwizard.db.DataSourceFactory; | |
import io.dropwizard.hibernate.HibernateBundle; | |
import io.dropwizard.setup.Bootstrap; | |
import io.dropwizard.setup.Environment; | |
/** | |
* Created by harshvardhan on 12/07/18. | |
*/ | |
public class MyApplication extends Application<MyConfiguration> { | |
public static void main(String[] args) throws Exception { | |
new MyApplication().run(args); | |
} | |
public void run(MyConfiguration myConfiguration, Environment environment) throws Exception { | |
System.out.println("Value from dev.yml is "+myConfiguration.getDataSourceFactory().getUser()); | |
InfoDao infoDao = new InfoDao(hibernate.getSessionFactory()); | |
final MyResource resource = new MyResource(infoDao); | |
environment.jersey().register(resource); | |
} | |
private HibernateBundle<MyConfiguration> hibernate = new HibernateBundle<MyConfiguration>(Info.class) { | |
@Override | |
public DataSourceFactory getDataSourceFactory(MyConfiguration configuration) { | |
return configuration.getDataSourceFactory(); | |
} | |
}; | |
@Override | |
public String getName() { | |
return "dropwizard-hibernate"; | |
} | |
@Override | |
public void initialize(Bootstrap<MyConfiguration> bootstrap) { | |
bootstrap.addBundle(hibernate); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment