当前位置: 首页>>代码示例>>Java>>正文


Java PropertiesHelper类代码示例

本文整理汇总了Java中org.hibernate.util.PropertiesHelper的典型用法代码示例。如果您正苦于以下问题:Java PropertiesHelper类的具体用法?Java PropertiesHelper怎么用?Java PropertiesHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PropertiesHelper类属于org.hibernate.util包,在下文中一共展示了PropertiesHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildSessionFactory

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
/**
 * Instantiate a new <tt>SessionFactory</tt>, using the properties and
 * mappings in this configuration. The <tt>SessionFactory</tt> will be
 * immutable, so changes made to the <tt>Configuration</tt> after
 * building the <tt>SessionFactory</tt> will not affect it.
 *
 * @return a new factory for <tt>Session</tt>s
 * @see org.hibernate.SessionFactory
 */
public SessionFactory buildSessionFactory() throws HibernateException {
	log.debug( "Preparing to build session factory with filters : " + filterDefinitions );
	secondPassCompile();
	validate();
	Environment.verifyProperties( properties );
	Properties copy = new Properties();
	copy.putAll( properties );
	PropertiesHelper.resolvePlaceHolders( copy );
	Settings settings = buildSettings( copy );

	return new SessionFactoryImpl(
			this,
			mapping,
			settings,
			getInitializedEventListeners()
		);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:27,代码来源:Configuration.java

示例2: configure

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public void configure(Type type, Properties params, Dialect dialect) {

		tableName = PropertiesHelper.getString(TABLE, params, DEFAULT_TABLE_NAME);
		columnName = PropertiesHelper.getString(COLUMN, params, DEFAULT_COLUMN_NAME);
		String schemaName = params.getProperty(SCHEMA);
		String catalogName = params.getProperty(CATALOG);

		if ( tableName.indexOf( '.' )<0 ) {
			tableName = Table.qualify( catalogName, schemaName, tableName );
		}

		query = "select " + 
			columnName + 
			" from " + 
			dialect.appendLockHint(LockMode.UPGRADE, tableName) +
			dialect.getForUpdateString();

		update = "update " + 
			tableName + 
			" set " + 
			columnName + 
			" = ? where " + 
			columnName + 
			" = ?";
	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:26,代码来源:TableGenerator.java

示例3: buildCache

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
/**
 * Builds a new {@link Cache} instance, and gets it's properties from the OSCache {@link Config}
 * which reads the properties file (<code>oscache.properties</code>) from the classpath.
 * If the file cannot be found or loaded, an the defaults are used.
 *
 * @param region
 * @param properties
 * @return
 * @throws CacheException
 */
public Cache buildCache(String region, Properties properties) throws CacheException {

	int refreshPeriod = PropertiesHelper.getInt(
		StringHelper.qualify(region, OSCACHE_REFRESH_PERIOD),
		OSCACHE_PROPERTIES,
		CacheEntry.INDEFINITE_EXPIRY
	);
	String cron = OSCACHE_PROPERTIES.getProperty( StringHelper.qualify(region, OSCACHE_CRON) );

	// construct the cache
	final OSCache cache = new OSCache(refreshPeriod, cron, region);

	Integer capacity = PropertiesHelper.getInteger( StringHelper.qualify(region, OSCACHE_CAPACITY), OSCACHE_PROPERTIES );
	if ( capacity!=null ) cache.setCacheCapacity( capacity.intValue() );

	return cache;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:28,代码来源:OSCacheProvider.java

示例4: getConfigFilePath

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public static String getConfigFilePath(Properties props) {
    String configResourcePath = PropertiesHelper.getString(CacheEnvironment.CONFIG_FILE_PATH_LEGACY, props, null);
    if (StringHelper.isEmpty(configResourcePath)) {
        configResourcePath = PropertiesHelper.getString(CacheEnvironment.CONFIG_FILE_PATH, props, null);
    }
    return configResourcePath;
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:8,代码来源:CacheEnvironment.java

示例5: getLockTimeoutInMillis

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public static int getLockTimeoutInMillis(Properties props) {
    int timeout = -1;
    try {
        timeout = PropertiesHelper.getInt(LOCK_TIMEOUT, props, -1);
    } catch (Exception e) {
        Logger.getLogger(CacheEnvironment.class).finest(e);
    }
    if (timeout < 0) {
        timeout = MAXIMUM_LOCK_TIMEOUT;
    }
    return timeout;
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:13,代码来源:CacheEnvironment.java

示例6: createQueryCacheFactory

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
protected QueryCacheFactory createQueryCacheFactory(Properties properties) {
	String queryCacheFactoryClassName = PropertiesHelper.getString(
			Environment.QUERY_CACHE_FACTORY, properties, "org.hibernate.cache.StandardQueryCacheFactory"
	);
	log.info("Query cache factory: " + queryCacheFactoryClassName);
	try {
		return (QueryCacheFactory) ReflectHelper.classForName(queryCacheFactoryClassName).newInstance();
	}
	catch (Exception cnfe) {
		throw new HibernateException("could not instantiate QueryCacheFactory: " + queryCacheFactoryClassName, cnfe);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:13,代码来源:SettingsFactory.java

示例7: createCacheProvider

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
protected CacheProvider createCacheProvider(Properties properties) {
	String cacheClassName = PropertiesHelper.getString(
			Environment.CACHE_PROVIDER, properties, DEF_CACHE_PROVIDER
	);
	log.info("Cache provider: " + cacheClassName);
	try {
		return (CacheProvider) ReflectHelper.classForName(cacheClassName).newInstance();
	}
	catch (Exception cnfe) {
		throw new HibernateException("could not instantiate CacheProvider: " + cacheClassName, cnfe);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:13,代码来源:SettingsFactory.java

示例8: createQueryTranslatorFactory

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
protected QueryTranslatorFactory createQueryTranslatorFactory(Properties properties) {
	String className = PropertiesHelper.getString(
			Environment.QUERY_TRANSLATOR, properties, "org.hibernate.hql.ast.ASTQueryTranslatorFactory"
	);
	log.info("Query translator: " + className);
	try {
		return (QueryTranslatorFactory) ReflectHelper.classForName(className).newInstance();
	}
	catch (Exception cnfe) {
		throw new HibernateException("could not instantiate QueryTranslatorFactory: " + className, cnfe);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:13,代码来源:SettingsFactory.java

示例9: SchemaExport

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
/**
 * Create a schema exporter for the given Configuration, with the given
 * database connection properties.
 *
 * @deprecated properties may be specified via the Configuration object
 */
public SchemaExport(Configuration cfg, Properties properties)
		throws HibernateException {
	dialect = Dialect.getDialect( properties );

	Properties props = new Properties();
	props.putAll( dialect.getDefaultProperties() );
	props.putAll( properties );

	connectionHelper = new ManagedProviderConnectionHelper( props );
	dropSQL = cfg.generateDropSchemaScript( dialect );
	createSQL = cfg.generateSchemaCreationScript( dialect );
	format = PropertiesHelper.getBoolean( Environment.FORMAT_SQL, props );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:SchemaExport.java

示例10: configure

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
	identifierType = type;
	boolean forceTableUse = PropertiesHelper.getBoolean( FORCE_TBL_PARAM, params, false );

	String sequenceName = PropertiesHelper.getString( SEQUENCE_PARAM, params, DEF_SEQUENCE_NAME );
	if ( sequenceName.indexOf( '.' ) < 0 ) {
		String schemaName = params.getProperty( SCHEMA );
		String catalogName = params.getProperty( CATALOG );
		sequenceName = Table.qualify( catalogName, schemaName, sequenceName );
	}
	int initialValue = PropertiesHelper.getInt( INITIAL_PARAM, params, DEFAULT_INITIAL_VALUE );
	int incrementSize = PropertiesHelper.getInt( INCREMENT_PARAM, params, DEFAULT_INCREMENT_SIZE );

	String valueColumnName = PropertiesHelper.getString( VALUE_COLUMN_PARAM, params, DEF_VALUE_COLUMN );

	String defOptStrategy = incrementSize <= 1 ? OptimizerFactory.NONE : OptimizerFactory.POOL;
	String optimizationStrategy = PropertiesHelper.getString( OPT_PARAM, params, defOptStrategy );
	if ( OptimizerFactory.NONE.equals( optimizationStrategy ) && incrementSize > 1 ) {
		log.warn( "config specified explicit optimizer of [" + OptimizerFactory.NONE + "], but [" + INCREMENT_PARAM + "=" + incrementSize + "; honoring optimizer setting" );
		incrementSize = 1;
	}
	if ( dialect.supportsSequences() && !forceTableUse ) {
		if ( OptimizerFactory.POOL.equals( optimizationStrategy ) && !dialect.supportsPooledSequences() ) {
			// TODO : may even be better to fall back to a pooled table strategy here so that the db stored values remain consistent...
			optimizationStrategy = OptimizerFactory.HILO;
		}
		databaseStructure = new SequenceStructure( dialect, sequenceName, initialValue, incrementSize );
	}
	else {
		databaseStructure = new TableStructure( dialect, sequenceName, valueColumnName, initialValue, incrementSize );
	}

	optimizer = OptimizerFactory.buildOptimizer( optimizationStrategy, identifierType.getReturnedClass(), incrementSize );
	databaseStructure.prepare( optimizer );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:36,代码来源:SequenceStyleGenerator.java

示例11: configure

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
	tableName = PropertiesHelper.getString( TABLE_PARAM, params, DEF_TABLE );
	if ( tableName.indexOf( '.' ) < 0 ) {
		String schemaName = params.getProperty( SCHEMA );
		String catalogName = params.getProperty( CATALOG );
		tableName = Table.qualify( catalogName, schemaName, tableName );
	}

	segmentColumnName = PropertiesHelper.getString( SEGMENT_COLUMN_PARAM, params, DEF_SEGMENT_COLUMN );
	segmentValue = params.getProperty( SEGMENT_VALUE_PARAM );
	if ( StringHelper.isEmpty( segmentValue ) ) {
		log.debug( "explicit segment value for id generator [" + tableName + '.' + segmentColumnName + "] suggested; using default [" + DEF_SEGMENT_VALUE + "]" );
		segmentValue = DEF_SEGMENT_VALUE;
	}
	segmentValueLength = PropertiesHelper.getInt( SEGMENT_LENGTH_PARAM, params, DEF_SEGMENT_LENGTH );
	valueColumnName = PropertiesHelper.getString( VALUE_COLUMN_PARAM, params, DEF_VALUE_COLUMN );
	initialValue = PropertiesHelper.getInt( INITIAL_PARAM, params, DEFAULT_INITIAL_VALUE );
	incrementSize = PropertiesHelper.getInt( INCREMENT_PARAM, params, DEFAULT_INCREMENT_SIZE );
	identifierType = type;

	String query = "select " + valueColumnName +
			" from " + tableName + " tbl" +
			" where tbl." + segmentColumnName + "=?";
	HashMap lockMap = new HashMap();
	lockMap.put( "tbl", LockMode.UPGRADE );
	this.query = dialect.applyLocksToSql( query, lockMap, CollectionHelper.EMPTY_MAP );

	update = "update " + tableName +
			" set " + valueColumnName + "=? " +
			" where " + valueColumnName + "=? and " + segmentColumnName + "=?";

	insert = "insert into " + tableName + " (" + segmentColumnName + ", " + valueColumnName + ") " + " values (?,?)";

	String defOptStrategy = incrementSize <= 1 ? OptimizerFactory.NONE : OptimizerFactory.POOL;
	String optimizationStrategy = PropertiesHelper.getString( OPT_PARAM, params, defOptStrategy );
	optimizer = OptimizerFactory.buildOptimizer( optimizationStrategy, identifierType.getReturnedClass(), incrementSize );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:38,代码来源:TableGenerator.java

示例12: configure

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
	sequenceName = PropertiesHelper.getString(SEQUENCE, params, "hibernate_sequence");
	parameters = params.getProperty(PARAMETERS);
	String schemaName = params.getProperty(SCHEMA);
	String catalogName = params.getProperty(CATALOG);

	if (sequenceName.indexOf( '.' ) < 0) {
		sequenceName = Table.qualify( catalogName, schemaName, sequenceName );
	}

	this.identifierType = type;
	sql = dialect.getSequenceNextValString(sequenceName);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:14,代码来源:SequenceGenerator.java

示例13: testPlaceholderReplacement

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public void testPlaceholderReplacement() {
	PropertiesHelper.resolvePlaceHolders( props );

	String str = PropertiesHelper.getString( "my.nonexistent.prop", props, "did.not.exist" );
	assertEquals( "did.not.exist", str );
	str = PropertiesHelper.getString( "my.nonexistent.prop", props, null );
	assertNull( str );
	str = PropertiesHelper.getString( "my.string.prop", props, "na" );
	assertEquals( "replacement did not occur", "string", str );
	str = PropertiesHelper.getString( "my.string.prop", props, "did.not.exist" );
	assertEquals( "replacement did not occur", "string", str );

	boolean bool = PropertiesHelper.getBoolean( "my.nonexistent.prop", props );
	assertFalse( "non-exists as boolean", bool );
	bool = PropertiesHelper.getBoolean( "my.nonexistent.prop", props, false );
	assertFalse( "non-exists as boolean", bool );
	bool = PropertiesHelper.getBoolean( "my.nonexistent.prop", props, true );
	assertTrue( "non-exists as boolean", bool );
	bool = PropertiesHelper.getBoolean( "my.boolean.prop", props );
	assertTrue( "boolean replacement did not occur", bool );
	bool = PropertiesHelper.getBoolean( "my.boolean.prop", props, false );
	assertTrue( "boolean replacement did not occur", bool );

	int i = PropertiesHelper.getInt( "my.nonexistent.prop", props, -1 );
	assertEquals( -1, i );
	i = PropertiesHelper.getInt( "my.int.prop", props, 100 );
	assertEquals( 1, i );

	Integer I = PropertiesHelper.getInteger( "my.nonexistent.prop", props );
	assertNull( I );
	I = PropertiesHelper.getInteger( "my.integer.prop", props );
	assertEquals( I, new Integer( 1 ) );

	str = props.getProperty( "partial.prop1" );
	assertEquals( "partial replacement (ends)", "tmp/middle/dir/tmp.txt", str );

	str = props.getProperty( "partial.prop2" );
	assertEquals( "partial replacement (midst)", "basedir/tmp/myfile.txt", str );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:40,代码来源:PropertiesHelperTest.java

示例14: getLockTimeoutInSeconds

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public static int getLockTimeoutInSeconds(Properties props) {
    try {
        return PropertiesHelper.getInt(LOCK_TIMEOUT, props, MAXIMUM_LOCK_TIMEOUT);
    } catch (Exception ignored) {
    }
    return MAXIMUM_LOCK_TIMEOUT;
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:8,代码来源:CacheEnvironment.java

示例15: loadInstance

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public HazelcastInstance loadInstance() throws CacheException {
    if (props == null) {
        throw new NullPointerException("Hibernate environment properties is null!");
    }
    if (client != null && client.getLifecycleService().isRunning()) {
        logger.log(Level.WARNING, "Current HazelcastClient is already active! Shutting it down...");
        unloadInstance();
    }
    String address = PropertiesHelper.getString(CacheEnvironment.NATIVE_CLIENT_ADDRESS, props, null);
    if (address == null) {
        String[] hosts = PropertiesHelper.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 = PropertiesHelper.getString(CacheEnvironment.NATIVE_CLIENT_GROUP, props, null);
    String pass = PropertiesHelper.getString(CacheEnvironment.NATIVE_CLIENT_PASSWORD, props, null);
    if (address == null || group == null || pass == null) {
        throw new CacheException("Configuration properties " + CacheEnvironment.NATIVE_CLIENT_ADDRESS + ", "
                + CacheEnvironment.NATIVE_CLIENT_GROUP + " and " + CacheEnvironment.NATIVE_CLIENT_PASSWORD
                + " are mandatory to use native client!");
    }
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setGroupConfig(new GroupConfig(group, pass)).addAddress(address);
    clientConfig.setUpdateAutomatic(true);
    return (client = HazelcastClient.newHazelcastClient(clientConfig));
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:30,代码来源:HazelcastClientLoader.java


注:本文中的org.hibernate.util.PropertiesHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。