List of usage examples for org.hibernate.internal.util.config ConfigurationHelper getString
public static String getString(String name, Map values, String defaultValue)
From source file:com.hazelcast.hibernate.CacheEnvironment.java
License:Open Source License
public static String getConfigFilePath(Properties props) { String configResourcePath = ConfigurationHelper.getString(CacheEnvironment.CONFIG_FILE_PATH_LEGACY, props, null);// w w w .j a v a2s . c om if (StringHelper.isEmpty(configResourcePath)) { configResourcePath = ConfigurationHelper.getString(CacheEnvironment.CONFIG_FILE_PATH, props, null); } return configResourcePath; }
From source file:com.hazelcast.hibernate.CacheEnvironment.java
License:Open Source License
public static String getInstanceName(Properties props) { return ConfigurationHelper.getString(HAZELCAST_INSTANCE_NAME, props, null); }
From source file:com.hazelcast.hibernate.instance.HazelcastClientLoader.java
License:Open Source License
public HazelcastInstance loadInstance() throws CacheException { if (client != null && client.getLifecycleService().isRunning()) { LOGGER.warning("Current HazelcastClient is already active! Shutting it down..."); unloadInstance();//w w w . j a va 2 s. c o m } String address = ConfigurationHelper.getString(CacheEnvironment.NATIVE_CLIENT_ADDRESS, props, null); String group = ConfigurationHelper.getString(CacheEnvironment.NATIVE_CLIENT_GROUP, props, null); String pass = ConfigurationHelper.getString(CacheEnvironment.NATIVE_CLIENT_PASSWORD, props, null); String configResourcePath = CacheEnvironment.getConfigFilePath(props); ClientConfig clientConfig = buildClientConfig(configResourcePath); if (group != null) { clientConfig.getGroupConfig().setName(group); } if (pass != null) { clientConfig.getGroupConfig().setPassword(pass); } if (address != null) { clientConfig.getNetworkConfig().addAddress(address); } clientConfig.getNetworkConfig().setSmartRouting(true); clientConfig.getNetworkConfig().setRedoOperation(true); client = HazelcastClient.newHazelcastClient(clientConfig); return client; }
From source file:com.hazelcast.hibernate4.instance.HazelcastClientLoader.java
License:Open Source License
public HazelcastInstance loadInstance() throws CacheException { if (props == null) { throw new NullPointerException("Hibernate environment properties is null!"); }//ww w . ja va 2 s . co m if (client != null && client.getLifecycleService().isRunning()) { logger.log(Level.WARNING, "Current HazelcastClient is already active! Shutting it down..."); unloadInstance(); } String address = ConfigurationHelper.getString(CacheEnvironment.NATIVE_CLIENT_ADDRESS, props, null); if (address == null) { String[] hosts = ConfigurationHelper.toStringArray(CacheEnvironment.NATIVE_CLIENT_HOSTS, ",", props); if (hosts != null && hosts.length > 0) { address = hosts[0]; logger.log(Level.WARNING, "Hibernate property '" + CacheEnvironment.NATIVE_CLIENT_HOSTS + "' " + "is deprecated, use '" + CacheEnvironment.NATIVE_CLIENT_ADDRESS + "' instead!"); } } String group = ConfigurationHelper.getString(CacheEnvironment.NATIVE_CLIENT_GROUP, props, null); String pass = ConfigurationHelper.getString(CacheEnvironment.NATIVE_CLIENT_PASSWORD, props, null); String configResourcePath = CacheEnvironment.getConfigFilePath(props); ClientConfig clientConfig = null; if (configResourcePath != null) { try { clientConfig = new ClientConfigBuilder(configResourcePath).build(); } catch (IOException e) { logger.log(Level.WARNING, "Could not load client configuration: " + configResourcePath, e); } } if (clientConfig == null) { clientConfig = new ClientConfig(); clientConfig.setUpdateAutomatic(true); clientConfig.setInitialConnectionAttemptLimit(3); clientConfig.setReconnectionAttemptLimit(5); } if (group != null) { clientConfig.getGroupConfig().setName(group); } if (pass != null) { clientConfig.getGroupConfig().setPassword(pass); } if (address != null) { clientConfig.addAddress(address); } return (client = HazelcastClient.newHazelcastClient(clientConfig)); }
From source file:com.literatejava.hibernate.allocator.LinearBlockAllocator.java
License:Open Source License
public void configure(Type type, Properties params, Dialect dialect) { ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get(IDENTIFIER_NORMALIZER); this.tableName = ConfigurationHelper.getString(ALLOC_TABLE, params, DEFAULT_TABLE); this.sequenceColumn = ConfigurationHelper.getString(SEQUENCE_COLUMN, params, DEFAULT_SEQUENCE_COLUMN); this.allocColumn = ConfigurationHelper.getString(ALLOC_COLUMN, params, DEFAULT_ALLOC_COLUMN); // get SequenceName; default to Entities' TableName. // -/* www.ja va 2 s .c om*/ this.sequenceName = ConfigurationHelper.getString(SEQUENCE_NAME, params, params.getProperty(PersistentIdentifierGenerator.TABLE)); if (sequenceName == null) { throw new IdentifierGenerationException( "LinearBlockAllocator: '" + SEQUENCE_NAME + "' must be specified"); } this.blockSize = ConfigurationHelper.getInt(BLOCK_SIZE, params, DEFAULT_BLOCK_SIZE); if (blockSize < 1) { blockSize = 1; } // qualify Table Name, if necessary; // -- if (tableName.indexOf('.') < 0) { String schemaName = normalizer.normalizeIdentifierQuoting(params.getProperty(SCHEMA)); String catalogName = normalizer.normalizeIdentifierQuoting(params.getProperty(CATALOG)); this.tableName = Table.qualify(catalogName, schemaName, tableName); } // build SQL strings; // -- use appendLockHint(LockMode) for now, as that is how Hibernate's generators do it. // this.query = "select " + allocColumn + " from " + dialect.appendLockHint(LockMode.PESSIMISTIC_WRITE, tableName) + " where " + sequenceColumn + " = ?" + dialect.getForUpdateString(); this.update = "update " + tableName + " set " + allocColumn + " = ? where " + sequenceColumn + " = ? and " + allocColumn + " = ?"; // setup Return Type & Result Holder. // -- this.returnType = type; this.returnClass = type.getReturnedClass(); this.resultFactory = IdentifierGeneratorHelper.getIntegralDataTypeHolder(returnClass); // done. }
From source file:com.tsoft.app.domain.identifier.StringSequenceIdentifier.java
@Override public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService(JdbcEnvironment.class); final Dialect dialect = jdbcEnvironment.getDialect(); final ConfigurationService configurationService = serviceRegistry.getService(ConfigurationService.class); String globalEntityIdentifierPrefix = configurationService.getSetting("entity.identifier.prefix", String.class, "SEQ_"); sequencePrefix = ConfigurationHelper.getString(SEQUENCE_PREFIX, params, globalEntityIdentifierPrefix); final String sequencePerEntitySuffix = ConfigurationHelper.getString( SequenceStyleGenerator.CONFIG_SEQUENCE_PER_ENTITY_SUFFIX, params, SequenceStyleGenerator.DEF_SEQUENCE_SUFFIX); final String defaultSequenceName = ConfigurationHelper .getBoolean(SequenceStyleGenerator.CONFIG_PREFER_SEQUENCE_PER_ENTITY, params, false) ? params.getProperty(JPA_ENTITY_NAME) + sequencePerEntitySuffix : SequenceStyleGenerator.DEF_SEQUENCE_NAME; sequenceCallSyntax = dialect.getSequenceNextValString( ConfigurationHelper.getString(SequenceStyleGenerator.SEQUENCE_PARAM, params, defaultSequenceName)); }
From source file:de.innovationgate.webgate.api.mysql.GaleraClusterTableGenerator.java
License:Open Source License
@Override public void configure(Type type, Properties params, Dialect dialect) throws MappingException { identifierType = type;//ww w . ja v a 2 s .c o m tableName = determineGeneratorTableName(params, dialect); segmentColumnName = determineSegmentColumnName(params, dialect); valueColumnName = determineValueColumnName(params, dialect); segmentValue = determineSegmentValue(params); segmentValueLength = determineSegmentColumnSize(params); initialValue = determineInitialValue(params); incrementSize = determineIncrementSize(params); this.selectQuery = buildSelectQuery(dialect); this.updateQuery = buildUpdateQuery(); this.insertQuery = buildInsertQuery(); // if the increment size is greater than one, we prefer pooled optimization; but we // need to see if the user prefers POOL or POOL_LO... String defaultPooledOptimizerStrategy = ConfigurationHelper.getBoolean(Environment.PREFER_POOLED_VALUES_LO, params, false) ? OptimizerFactory.StandardOptimizerDescriptor.POOLED_LO.getExternalName() : OptimizerFactory.StandardOptimizerDescriptor.POOLED.getExternalName(); final String defaultOptimizerStrategy = incrementSize <= 1 ? OptimizerFactory.StandardOptimizerDescriptor.NONE.getExternalName() : defaultPooledOptimizerStrategy; final String optimizationStrategy = ConfigurationHelper.getString(OPT_PARAM, params, defaultOptimizerStrategy); optimizer = OptimizerFactory.buildOptimizer(optimizationStrategy, identifierType.getReturnedClass(), incrementSize, ConfigurationHelper.getInt(INITIAL_PARAM, params, -1)); }
From source file:de.innovationgate.webgate.api.mysql.GaleraClusterTableGenerator.java
License:Open Source License
/** * Determine the table name to use for the generator values. * <p/>//from ww w . jav a 2s . com * Called during {@link #configure configuration}. * * @see #getTableName() * @param params The params supplied in the generator config (plus some standard useful extras). * @param dialect The dialect in effect * @return The table name to use. */ protected String determineGeneratorTableName(Properties params, Dialect dialect) { String name = ConfigurationHelper.getString(TABLE_PARAM, params, DEF_TABLE); boolean isGivenNameUnqualified = name.indexOf('.') < 0; if (isGivenNameUnqualified) { ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get(IDENTIFIER_NORMALIZER); name = normalizer.normalizeIdentifierQuoting(name); // if the given name is un-qualified we may neen to qualify it String schemaName = normalizer.normalizeIdentifierQuoting(params.getProperty(SCHEMA)); String catalogName = normalizer.normalizeIdentifierQuoting(params.getProperty(CATALOG)); name = Table.qualify(dialect.quote(catalogName), dialect.quote(schemaName), dialect.quote(name)); } else { // if already qualified there is not much we can do in a portable manner so we pass it // through and assume the user has set up the name correctly. } return name; }
From source file:de.innovationgate.webgate.api.mysql.GaleraClusterTableGenerator.java
License:Open Source License
/** * Determine the name of the column used to indicate the segment for each * row. This column acts as the primary key. * <p/>//from w w w. jav a 2 s .c o m * Called during {@link #configure configuration}. * * @see #getSegmentColumnName() * @param params The params supplied in the generator config (plus some standard useful extras). * @param dialect The dialect in effect * @return The name of the segment column */ protected String determineSegmentColumnName(Properties params, Dialect dialect) { ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get(IDENTIFIER_NORMALIZER); String name = ConfigurationHelper.getString(SEGMENT_COLUMN_PARAM, params, DEF_SEGMENT_COLUMN); return dialect.quote(normalizer.normalizeIdentifierQuoting(name)); }
From source file:de.innovationgate.webgate.api.mysql.GaleraClusterTableGenerator.java
License:Open Source License
/** * Determine the name of the column in which we will store the generator persistent value. * <p/>/*from w w w . j a v a 2 s .c o m*/ * Called during {@link #configure configuration}. * * @see #getValueColumnName() * @param params The params supplied in the generator config (plus some standard useful extras). * @param dialect The dialect in effect * @return The name of the value column */ protected String determineValueColumnName(Properties params, Dialect dialect) { ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get(IDENTIFIER_NORMALIZER); String name = ConfigurationHelper.getString(VALUE_COLUMN_PARAM, params, DEF_VALUE_COLUMN); return dialect.quote(normalizer.normalizeIdentifierQuoting(name)); }