public EbeanManaged(final Config config, final ServerConfig conf) { ebean = Suppliers.memoize(() -> { EbeanServer ebean = EbeanServerFactory.create(conf); // move .sql file to tmp directory... didn't find any other way of dealing with this if (conf.isDdlGenerate()) { String tmpdir = config.getString("application.tmpdir"); move(conf.getName() + "-drop-all.sql", tmpdir); move(conf.getName() + "-create-all.sql", tmpdir); } return ebean; }); }
@Override public void configure(final Env env, final Config conf, final Binder binder) { ServerConfig config = new ServerConfig(); config.setName(name); ContainerConfig container = new ContainerConfig(); container.loadFromProperties(props); .orElseThrow(() -> new NoSuchElementException("DataSource missing: " + dskey)); config.setDataSource(ds); config.setContainerConfig(container); config.loadFromProperties(props); config.setDefaultServer(cprops.getBoolean("defaultServer")); config.setRegister(cprops.getBoolean("register")); List<String> packages = config.getPackages(); if (packages == null || packages.size() == 0) { packages = ImmutableList.of(conf.getString("application.ns")); config.setPackages(packages); if (PKG.get() != null) { PKG.get().addAll(packages);
/** * Load the settings from the given properties */ private void configureFromProperties() { List<AutoConfigure> autoConfigures = autoConfiguration(); loadSettings(new PropertiesWrapper("ebean", name, properties, classLoadConfig)); for (AutoConfigure autoConfigure : autoConfigures) { autoConfigure.postConfigure(this); } }
/** * Set the naming convention to underscore if it has not already been set. */ private void setNamingConvention(ServerConfig config) { if (config.getNamingConvention() == null) { config.setNamingConvention(new UnderscoreNamingConvention()); } }
public HanaTableDdl(ServerConfig serverConfig, PlatformDdl platformDdl) { super(serverConfig, platformDdl); this.historyDdl = (HanaHistoryDdl) platformDdl.historyDdl; if (serverConfig.getProperties() != null) { PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "hana", serverConfig.getProperties(), serverConfig.getClassLoadConfig()); this.generateUniqueDdl = wrapper.getBoolean("generateUniqueDdl", false); } else { this.generateUniqueDdl = false; } }
/** * Load setting from properties. */ public void loadSettings(PropertiesWrapper p, String name) { enabled = p.getBoolean("profiling", enabled); verbose = p.getBoolean("profiling.verbose", verbose); directory = p.get("profiling.directory", directory); profilesPerFile = p.getLong("profiling.profilesPerFile", profilesPerFile); minimumMicros = p.getLong("profiling.minimumMicros", minimumMicros); String includeIds = p.get("profiling.includeProfileIds"); if (includeIds != null) { includeProfileIds = parseIds(includeIds); } }
/** * Run the DB migration against the DataSource. */ public DataSource runDbMigration(DataSource dataSource) { if (migrationConfig.isRunMigration()) { MigrationRunner runner = migrationConfig.createRunner(getClassLoadConfig().getClassLoader(), properties); runner.run(dataSource); } return dataSource; }
/** * Set to true if all DB column and table names should use quoted identifiers. */ public void setAllQuotedIdentifiers(boolean allQuotedIdentifiers) { platformConfig.setAllQuotedIdentifiers(allQuotedIdentifiers); if (allQuotedIdentifiers) { adjustNamingConventionForAllQuoted(); } }
private DocStoreMode getDocStoreIndexEvent(DocStoreMode mostSpecific) { if (!docStoreMapped) { return DocStoreMode.IGNORE; } if (mostSpecific != DocStoreMode.DEFAULT) return mostSpecific; if (docStorePersist != DocStoreMode.DEFAULT) return docStorePersist; return serverConfig.getDocStoreConfig().getPersist(); }
public byte[] decrypt(byte[] data) { EncryptKey key = encryptKeyManager.getEncryptKey(table, column); return encryptor.decrypt(data, key); }
public byte[] encrypt(byte[] data) { EncryptKey key = encryptKeyManager.getEncryptKey(table, column); return encryptor.encrypt(data, key); }
public String decryptObject(byte[] data) { EncryptKey key = encryptKeyManager.getEncryptKey(table, column); return encryptor.decryptString(data, key); }
@Override public DataSource getDataSource() { return dataSourceProvider.dataSource(tenantProvider.currentId()); }
public byte[] encryptObject(String formattedValue) { EncryptKey key = encryptKeyManager.getEncryptKey(table, column); return encryptor.encryptString(formattedValue, key); }
/** * Return the check constraint name. */ public String checkConstraintName(String tableName, String columnName) { return ckPrefix + normaliseTable(tableName) + "_" + normaliseColumn(columnName) + ckSuffix; }
/** * Specify the classLoader to use for class detection and new instance creation. */ public ClassLoadConfig(ClassLoader classLoader) { this.context = new ClassLoaderContext(classLoader); }
/** * Return the index name for a general index (not associated with a foreign key). */ public String indexName(String tableName, String column) { String colPart = normaliseTable(column); return indexPrefix + normaliseTable(tableName) + indexMiddle + colPart + indexSuffix; }
/** * Return the DB username to use for running DB migrations. */ public String getDbUsername() { // environment properties take precedence String user = readEnvironment("ddl.migration.user"); if (user != null) { return user; } return dbUsername; }