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


Java PropertiesHelper.getInteger方法代码示例

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


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

示例1: 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

示例2: 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

示例3: configure

import org.hibernate.util.PropertiesHelper; //导入方法依赖的package包/类
@Override
public void configure(Properties props) throws HibernateException {

    String driverClass = props.getProperty(Environment.DRIVER);

    poolSize = PropertiesHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20
    log.info("Using Hibernate built-in connection pool (not for production use!)");
    log.info("Hibernate connection pool size: " + poolSize);

    autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, props);
    log.info("autocommit mode: " + autocommit);

    isolation = PropertiesHelper.getInteger(Environment.ISOLATION, props);
    if (isolation!=null)
    log.info( "JDBC isolation level: " + Environment.isolationLevelToString( isolation.intValue() ) );

    if (driverClass==null) {
        log.warn("no JDBC Driver class was specified by property " + Environment.DRIVER);
    }
    else {
        try {
            // trying via forName() first to be as close to DriverManager's semantics
        	// NOTE for JSS: we use the context class loader because it will be able to locate the database drivers
        	// already loaded in our plug-ins or projects
            driver = (Driver) Class.forName(driverClass, true, Thread.currentThread().getContextClassLoader()).newInstance();
        }
        catch (Exception e) {
            try {
                driver = (Driver) ReflectHelper.classForName(driverClass).newInstance();
            }
            catch (Exception e1) {
                log.error(e1.getMessage());
                throw new HibernateException(e1);
            }
        }
    }

    url = props.getProperty( Environment.URL );
    if ( url == null ) {
        String msg = "JDBC URL was not specified by property " + Environment.URL;
        log.error( msg );
        throw new HibernateException( msg );
    }

    connectionProps = ConnectionProviderFactory.getConnectionProperties( props );

    log.info( "using driver: " + driverClass + " at URL: " + url );
    // if debug level is enabled, then log the password, otherwise mask it
    if ( log.isDebugEnabled() ) {
        log.info( "connection properties: " + connectionProps );
    }
    else if ( log.isInfoEnabled() ) {
        log.info( "connection properties: " + PropertiesHelper.maskOut(connectionProps, "password") );
    }

}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:57,代码来源:HibernateConnectionProvider.java


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