use of com.google.inject.persist.jpa.JpaPersistModule in project che by eclipse.
the class JpaTckModule method configure.
@Override
protected void configure() {
install(new JpaPersistModule("main"));
bind(DBInitializer.class).asEagerSingleton();
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(H2TestHelper.inMemoryDefault(), "che-schema"));
bind(TckResourcesCleaner.class).to(H2JpaCleaner.class);
bind(new TypeLiteral<TckRepository<RecipeImpl>>() {
}).toInstance(new JpaTckRepository<>(RecipeImpl.class));
bind(new TypeLiteral<TckRepository<SnapshotImpl>>() {
}).toInstance(new JpaTckRepository<>(SnapshotImpl.class));
bind(new TypeLiteral<TckRepository<Workspace>>() {
}).toInstance(new TestWorkspacesTckRepository());
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
bind(RecipeDao.class).to(JpaRecipeDao.class);
bind(SnapshotDao.class).to(JpaSnapshotDao.class);
}
use of com.google.inject.persist.jpa.JpaPersistModule in project roboguice by roboguice.
the class EdslTest method testModuleConfigUsingJpa.
public void testModuleConfigUsingJpa() throws Exception {
Logger.getLogger(getClass().getName()).info("Starting EDSL test.");
Guice.createInjector(Stage.PRODUCTION, new AbstractModule() {
@Override
protected void configure() {
install(new JpaPersistModule("myunit"));
binder().requireExplicitBindings();
}
});
Logger.getLogger(getClass().getName()).info("Completed EDSL test.");
}
use of com.google.inject.persist.jpa.JpaPersistModule in project metacat by Netflix.
the class S3ConnectorFactory method init.
private void init() {
//JPA module
final Map<String, Object> props = Maps.newHashMap(configuration);
props.put("hibernate.connection.datasource", DataSourceManager.get().load(name, configuration).get(name));
final Module jpaModule = new JpaPersistModule("s3").properties(props);
final Module s3Module = new S3Module(name, configuration, infoConverter);
final Injector injector = Guice.createInjector(jpaModule, s3Module);
persistService = injector.getInstance(PersistService.class);
persistService.start();
this.databaseService = injector.getInstance(ConnectorDatabaseService.class);
this.tableService = injector.getInstance(ConnectorTableService.class);
this.partitionService = injector.getInstance(ConnectorPartitionService.class);
}
use of com.google.inject.persist.jpa.JpaPersistModule in project guice by google.
the class EdslTest method testModuleConfigUsingJpa.
public void testModuleConfigUsingJpa() throws Exception {
Logger.getLogger(getClass().getName()).info("Starting EDSL test.");
Guice.createInjector(Stage.PRODUCTION, new AbstractModule() {
@Override
protected void configure() {
install(new JpaPersistModule("myunit"));
binder().requireExplicitBindings();
}
});
Logger.getLogger(getClass().getName()).info("Completed EDSL test.");
}
use of com.google.inject.persist.jpa.JpaPersistModule in project ninja by ninjaframework.
the class JpaModule method configure.
@Override
protected void configure() {
///////////////////////////////////////////////////////////////
// only start up Jpa when it is configured in application.conf
///////////////////////////////////////////////////////////////
String persistenceUnitName = ninjaProperties.get(NinjaConstant.PERSISTENCE_UNIT_NAME);
if (persistenceUnitName != null) {
// Get the connection credentials from application.conf
String connectionUrl = ninjaProperties.get(NinjaConstant.DB_CONNECTION_URL);
String connectionUsername = ninjaProperties.get(NinjaConstant.DB_CONNECTION_USERNAME);
String connectionPassword = ninjaProperties.get(NinjaConstant.DB_CONNECTION_PASSWORD);
Properties jpaProperties = new Properties();
// via system properties:
if (connectionUrl != null) {
jpaProperties.put("hibernate.connection.url", connectionUrl);
}
if (connectionUsername != null) {
jpaProperties.put("hibernate.connection.username", connectionUsername);
}
if (connectionPassword != null) {
jpaProperties.put("hibernate.connection.password", connectionPassword);
}
// Now - it may be the case the neither connection.url, connection.username nor
// connection.password is set. But this may be okay e.g. when using JDNI to
// configure your datasources...
install(new JpaPersistModule(persistenceUnitName).properties(jpaProperties));
UnitOfWorkInterceptor unitOfWorkInterceptor = new UnitOfWorkInterceptor();
requestInjection(unitOfWorkInterceptor);
// class-level @UnitOfWork
bindInterceptor(annotatedWith(UnitOfWork.class), any(), unitOfWorkInterceptor);
// method-level @UnitOfWork
bindInterceptor(any(), annotatedWith(UnitOfWork.class), unitOfWorkInterceptor);
bind(JpaInitializer.class).asEagerSingleton();
}
}
Aggregations