/** * Get a property with no default value. */ public String get(String key) { return get(key, null); }
/** * 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 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 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); }
/** * 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 a boolean property value. */ public boolean getBoolean(String key, boolean defaultValue) { String value = get(key, String.valueOf(defaultValue)); return Boolean.parseBoolean(value); }
String packagesProp = p.get("search.packages", p.get("packages", null)); packages = getSearchJarsPackages(packagesProp); if (p.get("batch.mode") != null || p.get("persistBatching") != null) { throw new IllegalArgumentException("Property 'batch.mode' or 'persistBatching' is being set but no longer used. Please change to use 'persistBatchMode'"); persistenceContextScope = PersistenceContextScope.valueOf(p.get("persistenceContextScope", "TRANSACTION")); dataTimeZone = p.get("dataTimeZone", dataTimeZone); asOfViewSuffix = p.get("asOfViewSuffix", asOfViewSuffix); asOfSysPeriod = p.get("asOfSysPeriod", asOfSysPeriod); historyTableSuffix = p.get("historyTableSuffix", historyTableSuffix); dataSourceJndiName = p.get("dataSourceJndiName", dataSourceJndiName); jdbcFetchSizeFindEach = p.getInt("jdbcFetchSizeFindEach", jdbcFetchSizeFindEach); jdbcFetchSizeFindList = p.getInt("jdbcFetchSizeFindList", jdbcFetchSizeFindList); databaseSequenceBatchSize = p.getInt("databaseSequenceBatchSize", databaseSequenceBatchSize); databaseBooleanTrue = p.get("databaseBooleanTrue", databaseBooleanTrue); databaseBooleanFalse = p.get("databaseBooleanFalse", databaseBooleanFalse); databasePlatformName = p.get("databasePlatformName", databasePlatformName); jodaLocalTimeMode = p.get("jodaLocalTimeMode", jodaLocalTimeMode); String jsonDateTimeFormat = p.get("jsonDateTime", null); if (jsonDateTimeFormat != null) { jsonDateTime = JsonConfig.DateTime.valueOf(jsonDateTimeFormat); ddlRun = p.getBoolean("ddl.run", ddlRun); ddlCreateOnly = p.getBoolean("ddl.createOnly", ddlCreateOnly); ddlInitSql = p.get("ddl.initSql", ddlInitSql);
/** * Return an int property value. */ public int getInt(String key, int defaultValue) { String value = get(key, String.valueOf(defaultValue)); return Integer.parseInt(value); }
/** * Return a long property value. */ public long getLong(String key, long defaultValue) { String value = get(key, String.valueOf(defaultValue)); return Long.parseLong(value); }
/** * 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; }