本文整理汇总了Java中com.google.inject.persist.jpa.JpaPersistModule.properties方法的典型用法代码示例。如果您正苦于以下问题:Java JpaPersistModule.properties方法的具体用法?Java JpaPersistModule.properties怎么用?Java JpaPersistModule.properties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.inject.persist.jpa.JpaPersistModule
的用法示例。
在下文中一共展示了JpaPersistModule.properties方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindJPAPersistModule
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
protected void bindJPAPersistModule() {
JpaPersistModule jpa = new JpaPersistModule("K2IDB");
Config dbConfig = config.getConfig("db");
Properties properties = new Properties();
properties.put("javax.persistence.jdbc.driver", dbConfig.getString("driver"));
properties.put("javax.persistence.jdbc.url", dbConfig.getString("url"));
properties.put("javax.persistence.jdbc.user", dbConfig.getString("user"));
properties.put("javax.persistence.jdbc.password", dbConfig.getString("password"));
dbConfig.getObject("additional").entrySet()
.forEach(e -> properties.put(e.getKey(), (String) e.getValue().unwrapped()));
jpa.properties(properties);
install(jpa);
}
示例2: initialize
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
@Override
public void initialize(Bootstrap<OregamiConfiguration> bootstrap) {
OregamiConfiguration configuration = StartHelper.createConfiguration(StartHelper.getConfigFilename());
Properties jpaProperties = StartHelper.createPropertiesFromConfiguration(configuration);
JpaPersistModule jpaPersistModule = new JpaPersistModule(configuration.getDatabaseConfiguration().getJpaUnit());
jpaPersistModule.properties(jpaProperties);
guiceBundle = GuiceBundle.<OregamiConfiguration>newBuilder()
.addModule(new OregamiGuiceModule())
.addModule(jpaPersistModule)
.enableAutoConfig("org.oregami")
.setConfigClass(OregamiConfiguration.class)
.build();
bootstrap.addBundle(guiceBundle);
SimpleModule module = new SimpleModule();
//module.addSerializer(LocalDateTime.class, new CustomLocalDateTimeSerializer());
//module.addSerializer(LocalDate.class, new CustomLocalDateSerializer());
bootstrap.getObjectMapper().registerModule(module);
}
示例3: configure
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
@Override
protected void configure() {
JpaPersistModule jpa = new JpaPersistModule("manager");
jpa.properties(properties);
jpa.configure(binder());
bind(DALInitializer.class).asEagerSingleton();
bind(ICredentialRepository.class).to(CredentialRepository.class);
bind(IDatabaseSettingsRepository.class).to(DatabaseSettingsRepository.class);
bind(IMediaLibraryRepository.class).to(MediaLibraryRepository.class);
bind(IMediaRepository.class).to(MediaRepository.class);
bind(ITagRepository.class).to(TagRepository.class);
}
示例4: setup
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
final Properties properties = new Properties();
properties.put("javax.persistence.jdbc.driver", postgres.getDriverClass());
properties.put("javax.persistence.jdbc.url", postgres.getConnectionUrl());
properties.put("javax.persistence.jdbc.user", postgres.getUsername());
properties.put("javax.persistence.jdbc.password", postgres.getPassword());
jpaModule = new JpaPersistModule("AdminUsersUnit");
jpaModule.properties(properties);
databaseHelper = new DatabaseTestHelper(new DBI(postgres.getConnectionUrl(), postgres.getUsername(), postgres.getPassword()));
Connection connection = null;
try {
connection = DriverManager.getConnection(postgres.getConnectionUrl(), postgres.getUsername(), postgres.getPassword());
Liquibase migrator = new Liquibase("config/initial-db-state.xml", new ClassLoaderResourceAccessor(), new JdbcConnection(connection));
Liquibase migrator2 = new Liquibase("migrations.xml", new ClassLoaderResourceAccessor(), new JdbcConnection(connection));
migrator.update("");
migrator2.update("");
} finally {
if(connection != null)
connection.close();
}
env = GuicedTestEnvironment.from(jpaModule).start();
}
示例5: createJpaModule
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
private JpaPersistModule createJpaModule(final PostgresDockerRule postgres) {
final Properties properties = new Properties();
properties.put("javax.persistence.jdbc.driver", postgres.getDriverClass());
properties.put("javax.persistence.jdbc.url", postgres.getConnectionUrl());
properties.put("javax.persistence.jdbc.user", postgres.getUsername());
properties.put("javax.persistence.jdbc.password", postgres.getPassword());
final JpaPersistModule jpaModule = new JpaPersistModule(JPA_UNIT);
jpaModule.properties(properties);
return jpaModule;
}
示例6: configure
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
@Override
protected void configure() {
final Map<String, String> properties = new HashMap<>();
properties.put(TRANSACTION_TYPE, PersistenceUnitTransactionType.RESOURCE_LOCAL.name());
final String dbUrl = System.getProperty("jdbc.url");
final String dbUser = System.getProperty("jdbc.user");
final String dbPassword = System.getProperty("jdbc.password");
waitConnectionIsEstablished(dbUrl, dbUser, dbPassword);
properties.put(JDBC_URL, dbUrl);
properties.put(JDBC_USER, dbUser);
properties.put(JDBC_PASSWORD, dbPassword);
properties.put(JDBC_DRIVER, System.getProperty("jdbc.driver"));
JpaPersistModule main = new JpaPersistModule("main");
main.properties(properties);
install(main);
final PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUser(dbUser);
dataSource.setPassword(dbPassword);
dataSource.setUrl(dbUrl);
bind(SchemaInitializer.class)
.toInstance(new FlywaySchemaInitializer(dataSource, "che-schema", "codenvy-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).to(JpaCleaner.class);
bind(new TypeLiteral<TckRepository<InviteImpl>>() {})
.toInstance(new JpaTckRepository<>(InviteImpl.class));
bind(new TypeLiteral<TckRepository<OrganizationImpl>>() {})
.toInstance(new JpaTckRepository<>(OrganizationImpl.class));
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {})
.toInstance(new JpaTckRepository<>(WorkspaceImpl.class));
bind(InviteDao.class).to(JpaInviteDao.class);
}
示例7: configureServlets
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
protected void configureServlets() {
h4Properties = new Properties();
String configFile = System.getProperty(FDC.DASH_H4_CONFIG_FILE);
logger.info("Building Persistence Manager - Servlet Persistence");
JpaPersistModule persistModule = new JpaPersistModule(FDC.H4_MANAGER);
persistModule.properties(ConfigUtil.loadConfig(h4Properties, configFile));
logger.info("Installing Persistence Manager for filter {}", FDC.PERSISTENCE_FILTER);
install(persistModule);
filter(FDC.PERSISTENCE_FILTER).through(PersistFilter.class);
}
示例8: configure
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
@Override
@SneakyThrows
protected void configure() {
final JpaPersistModule jpaModule = new JpaPersistModule(MOODCAT_PERSISTENCE_UNIT);
final Properties properties = getProperties();
setDatabasePassword(properties);
jpaModule.properties(properties);
install(jpaModule);
}
示例9: configure
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
@Override
protected void configure() {
LOG.debug("Installing JPA Module");
bind(DatabaseProperties.class).toInstance(config);
bind(String.class).annotatedWith(Names.named("liquibaseContext")).toInstance(liquibaseContext);
JpaPersistModule jpaModule = new JpaPersistModule(config.getPersistanceUnit());
jpaModule.properties(config.asJpaProperties());
install(jpaModule);
bind(DatabaseStructure.class).asEagerSingleton();
bind(StatisticDao.class).asEagerSingleton();
}
示例10: init
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
public static void init(String localConfigFilename) {
configFilename = localConfigFilename;
OregamiConfiguration configuration = createConfiguration(localConfigFilename);
Properties properties = createPropertiesFromConfiguration(configuration);
jpaUnit = configuration.getDatabaseConfiguration().getJpaUnit();
JpaPersistModule jpaPersistModule = new JpaPersistModule(jpaUnit);
jpaPersistModule.properties(properties);
injector = Guice.createInjector(jpaPersistModule, new OregamiGuiceModule());
try {
injector.getInstance(PersistService.class).start();
} catch (PersistenceException e) {
throw new RuntimeException("Database error", e);
}
}
示例11: configure
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
@Override
public void configure(final Binder binder) {
Binder theBinder = binder;
// [0] - JPA
// The JPA persistence unit name is composed by:
// - The appCode/component
// - The PersistenceUnitType: driverManager (connection) / dataSource
// So the persistence unit name to use at the persistence.xml file is composed like:
// <persistence-unit name="persistenceUnit.{appCode}.{appComponent}.{persistenceUnitType}">
PersistenceUnitType persistenceUnitType = this.propertyAt("persistence/@unitType")
.asEnumElement(PersistenceUnitType.class,
PersistenceUnitType.DRIVER_MANAGER); // use driverManager by default
// Sometimes it's an app component (ie: the urlAlias component for the r01t app)
// On these cases:
// - the persistence properties are going to be looked after as {appCode}.{appComponent}.persistence.properties.xml
// - the persistence unit is going to be looked after as persistenceUnit.{appCode}.{appComponent}
// otherwise (no appComponent is set):
// - the persistence properties are going to be looked after as {appCode}.persistence.properties.xml
// - the persistence unit is going to be looked after as persistenceUnit.{appCode}
String jpaServiceName = this.getAppComponent() == null ? this.getAppCode().asString()
: Strings.customized("{}.{}",
this.getAppCode(),this.getAppComponent());
final String persistenceUnitName = _persistenceUnitName(persistenceUnitType);
// Load properties
Properties props = _persistenceUnitProperties(persistenceUnitType,
persistenceUnitName);
// Create the module
JpaPersistModule jpaModule = new JpaPersistModule(persistenceUnitName); // for an alternative way see http://stackoverflow.com/questions/18101488/does-guice-persist-provide-transaction-scoped-or-application-managed-entitymanag
jpaModule.properties(props);
theBinder.install(jpaModule);
// Service handler used to control (start/stop) the Persistence Service (see ServletContextListenerBase)
theBinder.bind(ServiceHandler.class)
.annotatedWith(Names.named(jpaServiceName))
.to(JPAPersistenceServiceControl.class)
.in(Singleton.class); //.asEagerSingleton();
// expose the JPA's service handler
if (theBinder instanceof PrivateBinder) {
PrivateBinder privateBinder = (PrivateBinder)binder;
privateBinder.expose(ServiceHandler.class)
.annotatedWith(Names.named(jpaServiceName));
}
log.warn("... binded jpa persistence unit {} whose entity manager is handled by ServiceHandler with name {}",persistenceUnitName,jpaServiceName);
}
示例12: buildJpaPersistModule
import com.google.inject.persist.jpa.JpaPersistModule; //导入方法依赖的package包/类
private JpaPersistModule buildJpaPersistModule() {
PersistenceType persistenceType = configuration.getPersistenceType();
JpaPersistModule jpaPersistModule = new JpaPersistModule(Configuration.JDBC_UNIT_NAME);
Properties properties = new Properties();
// custom jdbc properties
Map<String, String> custom = configuration.getDatabaseCustomProperties();
if (0 != custom.size()) {
for (Entry<String, String> entry : custom.entrySet()) {
properties.setProperty("eclipselink.jdbc.property." + entry.getKey(),
entry.getValue());
}
}
switch (persistenceType) {
case IN_MEMORY:
properties.put("javax.persistence.jdbc.url", Configuration.JDBC_IN_MEMORY_URL);
properties.put("javax.persistence.jdbc.driver", Configuration.JDBC_IN_MEMROY_DRIVER);
properties.put("eclipselink.ddl-generation", "drop-and-create-tables");
properties.put("eclipselink.orm.throw.exceptions", "true");
jpaPersistModule.properties(properties);
return jpaPersistModule;
case REMOTE:
properties.put("javax.persistence.jdbc.url", configuration.getDatabaseUrl());
properties.put("javax.persistence.jdbc.driver", configuration.getDatabaseDriver());
break;
case LOCAL:
properties.put("javax.persistence.jdbc.url", configuration.getLocalDatabaseUrl());
properties.put("javax.persistence.jdbc.driver", Configuration.JDBC_LOCAL_DRIVER);
break;
}
properties.setProperty("javax.persistence.jdbc.user", configuration.getDatabaseUser());
properties.setProperty("javax.persistence.jdbc.password", configuration.getDatabasePassword());
switch (configuration.getJPATableGenerationStrategy()) {
case CREATE:
properties.setProperty("eclipselink.ddl-generation", "create-tables");
break;
case DROP_AND_CREATE:
properties.setProperty("eclipselink.ddl-generation", "drop-and-create-tables");
break;
default:
break;
}
properties.setProperty("eclipselink.ddl-generation.output-mode", "both");
properties.setProperty("eclipselink.create-ddl-jdbc-file-name", "DDL-create.jdbc");
properties.setProperty("eclipselink.drop-ddl-jdbc-file-name", "DDL-drop.jdbc");
jpaPersistModule.properties(properties);
return jpaPersistModule;
}