/** * Return a PropertiesWrapper instance with a different prefix but same underlying properties. * <p/> * Used when wanting to use "datasource" as the prefix rather than "ebean". * <p/> * The returning instance should only be used in a read only fashion. */ public PropertiesWrapper withPrefix(String prefix) { return new PropertiesWrapper(prefix, serverName, propertyMap, properties); }
/** * Load settings specified in properties files. */ public void loadSettings(PropertiesWrapper properties) { active = properties.getBoolean("docstore.active", active); url = properties.get("docstore.url", url); persist = properties.getEnum(DocStoreMode.class, "docstore.persist", persist); bulkBatchSize = properties.getInt("docstore.bulkBatchSize", bulkBatchSize); generateMapping = properties.getBoolean("docstore.generateMapping", generateMapping); dropCreate = properties.getBoolean("docstore.dropCreate", dropCreate); create = properties.getBoolean("docstore.create", create); mappingPath = properties.get("docstore.mappingPath", mappingPath); mappingSuffix = properties.get("docstore.mappingSuffix", mappingSuffix); pathToResources = properties.get("docstore.pathToResources", pathToResources); } }
/** * Load settings from properties. */ @Override public void loadFromProperties(PropertiesWrapper properties) { useForeignKeyPrefix = properties.getBoolean("namingConvention.useForeignKeyPrefix", useForeignKeyPrefix); sequenceFormat = properties.get("namingConvention.sequenceFormat", sequenceFormat); schema = properties.get("namingConvention.schema", schema); }
/** * Load the settings from the PropertiesWrapper. */ public void loadSettings(PropertiesWrapper properties, String serverName) { migrationPath = properties.get("migration.migrationPath", migrationPath); modelPath = properties.get("migration.modelPath", modelPath); applyPrefix = properties.get("migration.applyPrefix", applyPrefix); applySuffix = properties.get("migration.applySuffix", applySuffix); modelSuffix = properties.get("migration.modelSuffix", modelSuffix); includeGeneratedFileComment = properties.getBoolean("migration.includeGeneratedFileComment", includeGeneratedFileComment); generatePendingDrop = properties.get("migration.generatePendingDrop", generatePendingDrop); platform = properties.getEnum(Platform.class, "migration.platform", platform); generate = properties.getBoolean("migration.generate", generate); version = properties.get("migration.version", version); name = properties.get("migration.name", name); runMigration = properties.getBoolean("migration.run", runMigration); metaTable = properties.get("migration.metaTable", metaTable); runPlaceholders = properties.get("migration.placeholders", runPlaceholders); String adminUser = properties.get("datasource." + serverName + ".username", dbUsername); adminUser = properties.get("datasource." + serverName + ".adminusername", adminUser); dbUsername = properties.get("migration.dbusername", adminUser); String adminPwd = properties.get("datasource." + serverName + ".password", dbPassword); adminPwd = properties.get("datasource." + serverName + ".adminpassword", adminPwd); dbPassword = properties.get("migration.dbpassword", adminPwd); }
/** * Get a property with no default value. */ public String get(String key) { return get(key, null); }
/** * Return a boolean property value. */ public boolean getBoolean(String key, boolean defaultValue) { String value = get(key, String.valueOf(defaultValue)); return Boolean.parseBoolean(value); }
/** * Load the settings from the properties file. */ public void loadSettings(PropertiesWrapper p) { queryTuning = p.getBoolean("autoTune.queryTuning", queryTuning); queryTuningAddVersion = p.getBoolean("autoTune.queryTuningAddVersion", queryTuningAddVersion); queryTuningFile = p.get("autoTune.queryTuningFile", queryTuningFile); skipGarbageCollectionOnShutdown = p.getBoolean("autoTune.skipGarbageCollectionOnShutdown", skipGarbageCollectionOnShutdown); skipProfileReportingOnShutdown = p.getBoolean("autoTune.skipProfileReportingOnShutdown", skipProfileReportingOnShutdown); mode = p.getEnum(AutoTuneMode.class, "autoTune.mode", mode); profiling = p.getBoolean("autoTune.profiling", profiling); profilingBase = p.getInt("autoTune.profilingBase", profilingBase); profilingRate = p.getDouble("autoTune.profilingRate", profilingRate); profilingFile = p.get("autoTune.profilingFile", profilingFile); profilingUpdateFrequency = p.getInt("autoTune.profilingUpdateFrequency", profilingUpdateFrequency); } }
/** * Return an int property value. */ public int getInt(String key, int defaultValue) { String value = get(key, String.valueOf(defaultValue)); return Integer.parseInt(value); }
/** * Load the settings from the given properties */ public void loadFromProperties(Properties properties) { // keep the properties used for configuration so that these are available for plugins this.properties = properties; PropertiesWrapper p = new PropertiesWrapper("ebean", name, properties); loadSettings(p); }
int srid = p.getInt("geometrySRID", 0); if (srid > 0) { dbTypeConfig.setGeometrySRID(srid); docStoreOnly = p.getBoolean("docStoreOnly", docStoreOnly); disableL2Cache = p.getBoolean("disableL2Cache", disableL2Cache); explicitTransactionBeginMode = p.getBoolean("explicitTransactionBeginMode", explicitTransactionBeginMode); autoCommitMode = p.getBoolean("autoCommitMode", autoCommitMode); useJtaTransactionManager = p.getBoolean("useJtaTransactionManager", useJtaTransactionManager); backgroundExecutorSchedulePoolSize = p.getInt("backgroundExecutorSchedulePoolSize", backgroundExecutorSchedulePoolSize); backgroundExecutorShutdownSecs = p.getInt("backgroundExecutorShutdownSecs", backgroundExecutorShutdownSecs); disableClasspathSearch = p.getBoolean("disableClasspathSearch", disableClasspathSearch); currentUserProvider = createInstance(p, CurrentUserProvider.class, "currentUserProvider", currentUserProvider); databasePlatform = createInstance(p, DatabasePlatform.class, "databasePlatform", databasePlatform); String packagesProp = p.get("search.packages", p.get("packages", null)); packages = getSearchJarsPackages(packagesProp); collectQueryStatsByNode = p.getBoolean("collectQueryStatsByNode", collectQueryStatsByNode); collectQueryOrigins = p.getBoolean("collectQueryOrigins", collectQueryOrigins); skipCacheAfterWrite = p.getBoolean("skipCacheAfterWrite", skipCacheAfterWrite); updateAllPropertiesInBatch = p.getBoolean("updateAllPropertiesInBatch", updateAllPropertiesInBatch); updateChangesOnly = p.getBoolean("updateChangesOnly", updateChangesOnly); boolean defaultDeleteMissingChildren = p.getBoolean("defaultDeleteMissingChildren", updatesDeleteMissingChildren); updatesDeleteMissingChildren = p.getBoolean("updatesDeleteMissingChildren", defaultDeleteMissingChildren);
/** * Return a long property value. */ public long getLong(String key, long defaultValue) { String value = get(key, String.valueOf(defaultValue)); return Long.parseLong(value); }
/** * Load settings from test-ebean.properties and do nothing if the properties is not found. * <p> * This is typically used when test-ebean.properties is put into the test class path and used * to configure Ebean for running tests. * </p> */ public void loadTestProperties() { Properties properties = PropertyMap.testProperties(); if (!properties.isEmpty()) { PropertiesWrapper p = new PropertiesWrapper("ebean", name, properties); loadSettings(p); } }
/** * Return a double property value. */ public double getDouble(String key, double defaultValue) { String value = get(key, String.valueOf(defaultValue)); return Double.parseDouble(value); }
/** * Return a Enum property value. */ public <T extends Enum<T>> T getEnum(Class<T> enumType, String key, T defaultValue) { String level = get(key, null); return (level == null) ? defaultValue : Enum.valueOf(enumType, level.toUpperCase()); }
/** * Return the instance to use (can be null) for the given plugin. * * @param properties the properties * @param pluginType the type of plugin * @param key properties key * @param instance existing instance */ protected <T> T createInstance(PropertiesWrapper properties, Class<T> pluginType, String key, T instance) { if (instance != null) { return instance; } String classname = properties.get(key, null); return createInstance(pluginType, classname); }
/** * Build the list of classes from the comma delimited string. * * @param properties the properties * @return the classes */ private List<Class<?>> getClasses(PropertiesWrapper properties) { String classNames = properties.get("classes", null); if (classNames == null) { return classes; } List<Class<?>> classes = new ArrayList<>(); String[] split = classNames.split("[ ,;]"); for (String aSplit : split) { String cn = aSplit.trim(); if (!cn.isEmpty() && !"class".equalsIgnoreCase(cn)) { try { classes.add(Class.forName(cn)); } catch (ClassNotFoundException e) { String msg = "Error registering class [" + cn + "] from [" + classNames + "]"; throw new RuntimeException(msg, e); } } } return classes; }