Java Code Examples for com.zaxxer.hikari.HikariConfig#setDriverClassName()

The following examples show how to use com.zaxxer.hikari.HikariConfig#setDriverClassName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HikariDataSourceHelper.java    From freeacs with MIT License 8 votes vote down vote up
public static DataSource dataSource(Config config) {
  HikariConfig hikariConfig = new HikariConfig();
  hikariConfig.setDriverClassName(config.getString("datasource.driverClassName"));
  hikariConfig.setJdbcUrl(config.getString("datasource.jdbcUrl"));
  hikariConfig.setUsername(config.getString("datasource.username"));
  hikariConfig.setPassword(config.getString("datasource.password"));

  hikariConfig.setMinimumIdle(config.getInt("datasource.minimum-idle"));
  hikariConfig.setMaximumPoolSize(config.getInt("datasource.maximum-pool-size"));
  hikariConfig.setConnectionTestQuery("SELECT 1");
  hikariConfig.setPoolName(config.getString("datasource.poolName"));

  hikariConfig.addDataSourceProperty("dataSource.cachePrepStmts", "true");
  hikariConfig.addDataSourceProperty("dataSource.prepStmtCacheSize", "250");
  hikariConfig.addDataSourceProperty("dataSource.prepStmtCacheSqlLimit", "2048");
  hikariConfig.addDataSourceProperty("dataSource.useServerPrepStmts", "true");

  hikariConfig.setAutoCommit(true);

  return new HikariDataSource(hikariConfig);
}
 
Example 2
Source File: DatabaseConfig.java    From cloudbreak with Apache License 2.0 7 votes vote down vote up
@Bean
public DataSource dataSource() throws SQLException {
    DatabaseUtil.createSchemaIfNeeded("postgresql", databaseAddress, dbName, dbUser, dbPassword, dbSchemaName);
    HikariConfig config = new HikariConfig();
    if (ssl && Files.exists(Paths.get(certFile))) {
        config.addDataSourceProperty("ssl", "true");
        config.addDataSourceProperty("sslfactory", "org.postgresql.ssl.SingleCertValidatingFactory");
        config.addDataSourceProperty("sslfactoryarg", "file://" + certFile);
    }
    if (nodeConfig.isNodeIdSpecified()) {
        config.addDataSourceProperty("ApplicationName", nodeConfig.getId());
    }
    config.setDriverClassName("io.opentracing.contrib.jdbc.TracingDriver");
    config.setJdbcUrl(String.format("jdbc:tracing:postgresql://%s/%s?currentSchema=%s", databaseAddress, dbName, dbSchemaName));
    config.setUsername(dbUser);
    config.setPassword(dbPassword);
    config.setMaximumPoolSize(poolSize);
    config.setMinimumIdle(minimumIdle);
    config.setConnectionTimeout(SECONDS.toMillis(connectionTimeout));
    config.setIdleTimeout(MINUTES.toMillis(idleTimeout));
    return new HikariDataSource(config);
}
 
Example 3
Source File: DatabaseConfiguration.java    From todo-spring-angular with MIT License 6 votes vote down vote up
@Bean(destroyMethod = "close")
public DataSource dataSource() {
    log.debug("Configuring Datasource");
    if (dataSourcePropertyResolver.getProperty("url") == null) {
        log.error("Your database connection pool configuration is incorrect! The application" +
                " cannot start. Please check your Spring profile, current profiles are: {}",
            Arrays.toString(env.getActiveProfiles()));
        throw new ApplicationContextException("Database connection pool is not configured correctly");
    }

    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setDriverClassName(dataSourcePropertyResolver.getProperty("dataSourceClassName"));
    hikariConfig.setJdbcUrl(dataSourcePropertyResolver.getProperty("url"));
    hikariConfig.setUsername(dataSourcePropertyResolver.getProperty("username"));
    hikariConfig.setPassword(dataSourcePropertyResolver.getProperty("password"));
    return new HikariDataSource(hikariConfig);
}
 
Example 4
Source File: HikariPool.java    From Java-11-Cookbook-Second-Edition with MIT License 6 votes vote down vote up
private static DataSource createDataSource2() {
    HikariConfig config = new HikariConfig();
    config.setPoolName("cookpool");
    config.setDriverClassName("org.postgresql.Driver");
    config.setJdbcUrl("jdbc:postgresql://localhost/cookbook");
    config.setUsername("cook");
    //conf.setPassword("123Secret");
    config.setMaximumPoolSize(10);
    config.setMinimumIdle(2);
    config.addDataSourceProperty("cachePrepStmts", true);
    config.addDataSourceProperty("prepStmtCacheSize", 256);
    config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
    config.addDataSourceProperty("useServerPrepStmts", true);

    HikariDataSource ds = new HikariDataSource(config);
    return ds;
}
 
Example 5
Source File: HikariDataSourceFactory.java    From super-cloudops with Apache License 2.0 6 votes vote down vote up
/**
 * Create datasource.
 * 
 * @return
 */
protected DataSource createDataSource(String driver, String jdbcUrl, String username, String password, int maxConnections) {
	hasTextOf(driver, "driver");
	hasTextOf(jdbcUrl, "jdbcUrl");
	hasTextOf(username, "username");
	hasTextOf(password, "password");

	// props.put("dataSource.logWriter", new PrintWriter(System.out));
	HikariConfig config = new HikariConfig();
	config.setDriverClassName(driver);
	config.setJdbcUrl(jdbcUrl);
	config.setUsername(username);
	config.setPassword(password);
	config.setMaximumPoolSize(maxConnections);
	config.setMinimumIdle((int) (maxConnections * 0.1f));
	DataSource datasource = new HikariDataSource(config);
	log.info(format("Creating datasource: %s of jdbcUrl: %s", datasource, jdbcUrl));
	return datasource;
}
 
Example 6
Source File: DataSourceConfig.java    From freeacs with MIT License 6 votes vote down vote up
@Bean
public DataSource getDataSource(Environment config) {
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setDriverClassName(config.getProperty("main.datasource.driverClassName"));
    hikariConfig.setJdbcUrl(config.getProperty("main.datasource.jdbcUrl"));
    hikariConfig.setUsername(config.getProperty("main.datasource.username"));
    hikariConfig.setPassword(config.getProperty("main.datasource.password"));

    hikariConfig.setMinimumIdle(config.getProperty("main.datasource.minimum-idle", Integer.class, 1));
    hikariConfig.setMaximumPoolSize(config.getProperty("main.datasource.maximum-pool-size", Integer.class, 10));
    hikariConfig.setConnectionTestQuery("SELECT 1");
    hikariConfig.setPoolName(config.getProperty("main.datasource.poolName"));

    hikariConfig.addDataSourceProperty("dataSource.cachePrepStmts", "true");
    hikariConfig.addDataSourceProperty("dataSource.prepStmtCacheSize", "250");
    hikariConfig.addDataSourceProperty("dataSource.prepStmtCacheSqlLimit", "2048");
    hikariConfig.addDataSourceProperty("dataSource.useServerPrepStmts", "true");

    hikariConfig.setAutoCommit(true);

    return new HikariDataSource(hikariConfig);
}
 
Example 7
Source File: DatabaseConfig.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@Bean
public DataSource dataSource() throws SQLException {
    DatabaseUtil.createSchemaIfNeeded("postgresql", databaseAddress, dbName, dbUser, dbPassword, dbSchemaName);
    HikariConfig config = new HikariConfig();
    if (ssl && Files.exists(Paths.get(certFile))) {
        config.addDataSourceProperty("ssl", "true");
        config.addDataSourceProperty("sslfactory", "org.postgresql.ssl.SingleCertValidatingFactory");
        config.addDataSourceProperty("sslfactoryarg", "file://" + certFile);
    }
    if (nodeConfig.isNodeIdSpecified()) {
        config.addDataSourceProperty("ApplicationName", nodeConfig.getId());
    }
    config.setDriverClassName("io.opentracing.contrib.jdbc.TracingDriver");
    config.setJdbcUrl(String.format("jdbc:tracing:postgresql://%s/%s?currentSchema=%s", databaseAddress, dbName, dbSchemaName));
    config.setUsername(dbUser);
    config.setPassword(dbPassword);
    config.setMaximumPoolSize(poolSize);
    config.setMinimumIdle(minimumIdle);
    config.setConnectionTimeout(SECONDS.toMillis(connectionTimeout));
    config.setIdleTimeout(MINUTES.toMillis(idleTimeout));
    return new HikariDataSource(config);
}
 
Example 8
Source File: DatabaseConfiguration.java    From osiam with MIT License 5 votes vote down vote up
@Primary
@Bean
public DataSource dataSource() {
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setPoolName("osiam-cp");
    hikariConfig.setDriverClassName(driverClassName);
    hikariConfig.setJdbcUrl(databaseUrl);
    hikariConfig.setUsername(databaseUserName);
    hikariConfig.setPassword(databasePassword);
    hikariConfig.setMaximumPoolSize(maximumPoolSize);
    hikariConfig.setConnectionTimeout(connectionTimeoutMs);
    return new HikariDataSource(hikariConfig);
}
 
Example 9
Source File: HikariFactory.java    From rapidoid with Apache License 2.0 5 votes vote down vote up
public static DataSource createDataSourceFor(JdbcClient jdbc) {
	HikariConfig config = new HikariConfig();

	config.setJdbcUrl(jdbc.url());
	config.setUsername(jdbc.username());
	config.setPassword(jdbc.password());
	config.setDriverClassName(jdbc.driver());

	Conf.HIKARI.applyTo(config);

	return new HikariDataSource(config);
}
 
Example 10
Source File: DataSourceConfiguration.java    From Agent-Benchmarks with Apache License 2.0 5 votes vote down vote up
@Bean
@Primary
public DataSource getDataSource() {
    HikariConfig config = new HikariConfig();
    config.setDriverClassName("com.mysql.jdbc.Driver");
    config.setJdbcUrl("jdbc:mysql://localhost:3306/test");
    config.setUsername("root");
    config.setPassword("root");
    config.setMaximumPoolSize(500);
    config.setMinimumIdle(10);
    return new HikariDataSource(config);
}
 
Example 11
Source File: JdbcUtil.java    From datacollector with Apache License 2.0 5 votes vote down vote up
private HikariConfig createDataSourceConfig(
  HikariPoolConfigBean hikariConfigBean,
  boolean autoCommit,
  boolean readOnly
) throws StageException {
  HikariConfig config = new HikariConfig();

  config.setJdbcUrl(hikariConfigBean.getConnectionString());
  if (hikariConfigBean.useCredentials){
    config.setUsername(hikariConfigBean.getUsername().get());
    config.setPassword(hikariConfigBean.getPassword().get());
  }
  config.setAutoCommit(autoCommit);
  config.setReadOnly(readOnly);
  config.setMaximumPoolSize(hikariConfigBean.maximumPoolSize);
  config.setMinimumIdle(hikariConfigBean.minIdle);
  config.setConnectionTimeout(hikariConfigBean.connectionTimeout * MILLISECONDS);
  config.setIdleTimeout(hikariConfigBean.idleTimeout * MILLISECONDS);
  config.setMaxLifetime(hikariConfigBean.maxLifetime * MILLISECONDS);

  if (!StringUtils.isEmpty(hikariConfigBean.driverClassName)) {
    config.setDriverClassName(hikariConfigBean.driverClassName);
  }

  if (!StringUtils.isEmpty(hikariConfigBean.connectionTestQuery)) {
    config.setConnectionTestQuery(hikariConfigBean.connectionTestQuery);
  }

  if(hikariConfigBean.transactionIsolation != TransactionIsolationLevel.DEFAULT) {
    config.setTransactionIsolation(hikariConfigBean.transactionIsolation.name());
  }

  if(StringUtils.isNotEmpty(hikariConfigBean.initialQuery)) {
    config.setConnectionInitSql(hikariConfigBean.initialQuery);
  }

  config.setDataSourceProperties(hikariConfigBean.getDriverProperties());

  return config;
}
 
Example 12
Source File: JpaConfig.java    From thymeleafexamples-layouts with Apache License 2.0 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    HikariConfig config = new HikariConfig();
    config.setDriverClassName(driver);
    config.setJdbcUrl(url);
    config.setUsername(username);
    config.setPassword(password);
    config.addDataSourceProperty("cachePrepStmts", "true");
    config.addDataSourceProperty("prepStmtCacheSize", "250");
    config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
    config.addDataSourceProperty("useServerPrepStmts", "true");

    return new HikariDataSource(config);
}
 
Example 13
Source File: Storage.java    From Kepler with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Storage(String host, int port, String username, String password, String db) {
    try {
        HikariConfig config = new HikariConfig();
        config.setDriverClassName("org.mariadb.jdbc.Driver");
        config.setJdbcUrl("jdbc:mariadb://" + host + ":" + port + "/" + db);
        config.setUsername(username);
        config.setPassword(password);

        config.setPoolName("processing");

        // No martinmine/Leon/other Habbotards, you don't know better.
        // Read up on this first, before commenting dumb shit
        // https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing
        // availableProcessors() already returns thread count on hyper-threaded processors
        // Thus we don't need the * 2 described there
        config.setMaximumPoolSize(Runtime.getRuntime().availableProcessors() + 1);
        config.setMinimumIdle(1);

        config.addDataSourceProperty("cachePrepStmts", "true");
        config.addDataSourceProperty("prepStmtCacheSize", "250");
        config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
        config.addDataSourceProperty("characterEncoding", "utf8");
        config.addDataSourceProperty("useUnicode", "true");
        config.addDataSourceProperty("useSSL", "false");
        config.addDataSourceProperty("serverTimezone", "UTC");
        config.addDataSourceProperty("sessionVariables", "sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'");

        this.ds = new HikariDataSource(config);
        this.isConnected = true;

    } catch (Exception ex) {
        Storage.logError(ex);
    }
}
 
Example 14
Source File: ConnectionPoolingIT.java    From snowflake-jdbc with Apache License 2.0 5 votes vote down vote up
private HikariDataSource initHikariDataSource() throws SQLException
{
  HikariConfig config = new HikariConfig();
  config.setDriverClassName(BaseJDBCTest.DRIVER_CLASS);
  config.setDataSourceProperties(setUpConnectionProperty());
  config.setJdbcUrl(connectStr);
  return new HikariDataSource(config);
}
 
Example 15
Source File: MysqlChannelTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static JdbcTemplate getJdbcTemplate() throws UnknownHostException {
  MysqlConnection connection = new MysqlConnection("192.168.1.204", 3306, System.getenv("MYSQL_USER"), System.getenv("MYSQL_PASS"));

  HikariConfig config = connection.toConfig();
  config.setDriverClassName(Driver.class.getName());
  config.setInitializationFailTimeout(-1);
  HikariDataSource hikariDataSource = new HikariDataSource(config);

  return new JdbcTemplate(hikariDataSource);
}
 
Example 16
Source File: DbUtil.java    From ballerina-message-broker with Apache License 2.0 5 votes vote down vote up
private static DataSource createDataSource() {
    HikariConfig hikariDataSourceConfig = new HikariConfig();
    hikariDataSourceConfig.setJdbcUrl(DATABASE_URL);
    hikariDataSourceConfig.setDriverClassName(DRIVER_CLASS_NAME);
    hikariDataSourceConfig.setAutoCommit(false);
    return new HikariDataSource(hikariDataSourceConfig);
}
 
Example 17
Source File: DataSourceUtil.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
private static DataSource createHikariCP(final DatabaseType databaseType, final String dataSourceName) {
    HikariConfig result = new HikariConfig();
    DatabaseEnvironment databaseEnvironment = IntegrateTestEnvironment.getInstance().getDatabaseEnvironments().get(databaseType);
    result.setDriverClassName(databaseEnvironment.getDriverClassName());
    result.setJdbcUrl(null == dataSourceName ? databaseEnvironment.getURL() : databaseEnvironment.getURL(dataSourceName));
    result.setUsername(databaseEnvironment.getUsername());
    result.setPassword(databaseEnvironment.getPassword());
    result.setMaximumPoolSize(2);
    result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
    result.setConnectionTestQuery("SELECT 1");
    if ("Oracle".equals(databaseType.getName())) {
        result.setConnectionInitSql("ALTER SESSION SET CURRENT_SCHEMA = " + dataSourceName);
    }
    return new HikariDataSource(result);
}
 
Example 18
Source File: MySQLUserDataSource.java    From MCAuthenticator with GNU General Public License v3.0 4 votes vote down vote up
public MySQLUserDataSource(String connectionURL, String username, String password, int queryTimeout) throws SQLException {
    this.queryTimeout = queryTimeout;
    this.updateHook = new UpdateHook() {
        @Override
        public void update(UpdatableFlagData me) {
            toUpdate.add(me);
        }
    };
    HikariConfig cfg = new HikariConfig();
    cfg.setDriverClassName("com.mysql.jdbc.Driver");
    cfg.setJdbcUrl(connectionURL);
    cfg.setUsername(username);
    cfg.setPassword(password);
    cfg.setMaximumPoolSize(2);

    pool = new HikariDataSource(cfg);

    try (Connection c = pool.getConnection()) {
        ResultSet resultSet = c.createStatement().executeQuery("SHOW TABLES;");
        boolean found = false;
        while (resultSet.next()) {
            if (resultSet.getString(1).equalsIgnoreCase("2fa")) {
                found = true;
                break;
            }
        }
        resultSet.close();

        if (found) {
            try (ResultSet rs = c.createStatement().executeQuery("SHOW COLUMNS FROM 2FA;")) {
                // Determine secret field (1.0.2 and before) and add type row
                boolean hasAuthType = false;
                while (rs.next()) {
                    String field = rs.getString("Field");
                    if (!field.equalsIgnoreCase("secret")) {
                        if (field.equalsIgnoreCase("authtype"))
                            hasAuthType = true;
                        continue;
                    }

                    // Secret field
                    if (!rs.getString("Type").equalsIgnoreCase("tinytext")) {
                        c.createStatement().execute("alter table 2FA MODIFY secret TINYTEXT;");
                        break;
                    }
                }
                if (!hasAuthType) {
                    c.createStatement().execute("alter table 2FA add authtype int DEFAULT 0;");
                }
            }
        } else {
            c.createStatement().execute("CREATE TABLE 2FA(" +
                    "uuid CHAR(32) PRIMARY KEY," +
                    "ip VARCHAR(255)," +
                    "secret TINYTEXT," +
                    "authtype INT DEFAULT 0," +
                    "locked BIT(1));");
            c.createStatement().execute("CREATE INDEX uuid_index ON 2FA (uuid);");
        }
    }
}
 
Example 19
Source File: ShardingConfig.java    From java-tutorial with MIT License 4 votes vote down vote up
/**
 * 配置数据源配置
 *
 * @return
 */
private Map<String, DataSource> getDataSourceMap() {
    Map<String, DataSource> dataSourceMap = new HashMap<>(4);
    if (datasource.isEmpty()) {
        new ConfigurationException("Data source configuration error");
    }

    Properties properties = new Properties();
    properties.setProperty("testOnBorrow", "true");
    properties.setProperty("testWhileIdle", "true");
    properties.setProperty("testOnReturn", "false");
    properties.setProperty("validationQuery", "select 'x'");

    for (String ds : datasource.keySet()) {
        LinkedHashMap<String, String> dbConfigList = (LinkedHashMap<String, String>) datasource.get(ds);
        String driverClassName = dbConfigList.get("driverClassName");

        String name = dbConfigList.get("alias");
        String jdbcUrl = dbConfigList.get("url");
        String dbUsername = dbConfigList.get("username");
        String dbPassword = dbConfigList.get("password");

        HikariConfig hikariConfig = new HikariConfig();
        hikariConfig.setDriverClassName(driverClassName);
        hikariConfig.setJdbcUrl(jdbcUrl);
        hikariConfig.setUsername(dbUsername);
        hikariConfig.setPassword(dbPassword);

        //等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQLException, 缺省:30秒
        hikariConfig.setConnectionTimeout(30000);
        //一个连接idle状态的最大时长(毫秒),超时则被释放(retired),缺省:10分钟
        hikariConfig.setIdleTimeout(30000);
        //一个连接的生命时长(毫秒),超时而且没被使用则被释放(retired),缺省:30分钟,建议设置比数据库超时时长少30秒,
        // 参考MySQL wait_timeout参数(show variables like '%timeout%';)
        hikariConfig.setMaxLifetime(1800000);
        //连接池中允许的最大连接数。缺省值:10;推荐的公式:((core_count * 2) + effective_spindle_count)
        hikariConfig.setMaximumPoolSize(60);
        hikariConfig.setMinimumIdle(10);
        hikariConfig.setDataSourceProperties(properties);

        HikariDataSource dataSource = new HikariDataSource(hikariConfig);
        logger.info("-------------------Init HikariDataSource {} ---------------------------", name);
        dataSourceMap.put(ds, dataSource);
    }
    return dataSourceMap;
}
 
Example 20
Source File: DomainConfFactory.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public void register(final Domain domain) {
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setDriverClassName(domain.getJdbcDriver());
    hikariConfig.setJdbcUrl(domain.getJdbcURL());
    hikariConfig.setUsername(domain.getDbUsername());
    hikariConfig.setPassword(domain.getDbPassword());
    hikariConfig.setSchema(domain.getDbSchema());
    hikariConfig.setTransactionIsolation(domain.getTransactionIsolation().name());
    hikariConfig.setMaximumPoolSize(domain.getPoolMaxActive());
    hikariConfig.setMinimumIdle(domain.getPoolMinIdle());

    // domainDataSource
    registerBeanDefinition(
            domain.getKey() + "DataSource",
            BeanDefinitionBuilder.rootBeanDefinition(JndiObjectFactoryBean.class).
                    addPropertyValue("jndiName", "java:comp/env/jdbc/syncope" + domain.getKey() + "DataSource").
                    addPropertyValue("defaultObject", new HikariDataSource(hikariConfig)).
                    getBeanDefinition());
    DataSource initedDataSource = ApplicationContextProvider.getBeanFactory().
            getBean(domain.getKey() + "DataSource", DataSource.class);

    // domainResourceDatabasePopulator
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setContinueOnError(true);
    databasePopulator.setIgnoreFailedDrops(true);
    databasePopulator.setSqlScriptEncoding(StandardCharsets.UTF_8.name());
    databasePopulator.addScript(new ClassPathResource("/audit/" + domain.getAuditSql()));
    registerSingleton(domain.getKey().toLowerCase() + "ResourceDatabasePopulator", databasePopulator);

    // domainDataSourceInitializer
    DataSourceInitializer dataSourceInitializer = new DataSourceInitializer();
    dataSourceInitializer.setDataSource(initedDataSource);
    dataSourceInitializer.setEnabled(true);
    dataSourceInitializer.setDatabasePopulator(databasePopulator);
    registerSingleton(domain.getKey().toLowerCase() + "DataSourceInitializer", dataSourceInitializer);

    // domainEntityManagerFactory
    OpenJpaVendorAdapter vendorAdapter = new OpenJpaVendorAdapter();
    vendorAdapter.setShowSql(false);
    vendorAdapter.setGenerateDdl(true);
    vendorAdapter.setDatabasePlatform(domain.getDatabasePlatform());

    BeanDefinitionBuilder emf = BeanDefinitionBuilder.rootBeanDefinition(DomainEntityManagerFactoryBean.class).
            addPropertyValue("mappingResources", domain.getOrm()).
            addPropertyValue("persistenceUnitName", domain.getKey()).
            addPropertyReference("dataSource", domain.getKey() + "DataSource").
            addPropertyValue("jpaVendorAdapter", vendorAdapter).
            addPropertyReference("commonEntityManagerFactoryConf", "commonEMFConf");
    if (env.containsProperty("openjpaMetaDataFactory")) {
        emf.addPropertyValue("jpaPropertyMap", Map.of(
                "openjpa.MetaDataFactory",
                Objects.requireNonNull(env.getProperty("openjpaMetaDataFactory")).
                        replace("##orm##", domain.getOrm())));
    }
    registerBeanDefinition(domain.getKey() + "EntityManagerFactory", emf.getBeanDefinition());
    ApplicationContextProvider.getBeanFactory().getBean(domain.getKey() + "EntityManagerFactory");

    // domainTransactionManager
    AbstractBeanDefinition domainTransactionManager =
            BeanDefinitionBuilder.rootBeanDefinition(JpaTransactionManager.class).
                    addPropertyReference("entityManagerFactory", domain.getKey() + "EntityManagerFactory").
                    getBeanDefinition();
    domainTransactionManager.addQualifier(new AutowireCandidateQualifier(Qualifier.class, domain.getKey()));
    registerBeanDefinition(domain.getKey() + "TransactionManager", domainTransactionManager);

    // domainContentXML
    registerBeanDefinition(domain.getKey() + "ContentXML",
            BeanDefinitionBuilder.rootBeanDefinition(ByteArrayInputStream.class).
                    addConstructorArgValue(domain.getContent().getBytes()).
                    getBeanDefinition());

    // domainKeymasterConfParamsJSON
    registerBeanDefinition(domain.getKey() + "KeymasterConfParamsJSON",
            BeanDefinitionBuilder.rootBeanDefinition(ByteArrayInputStream.class).
                    addConstructorArgValue(domain.getKeymasterConfParams().getBytes()).
                    getBeanDefinition());
}