• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PropertiesHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


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


示例17: getInstanceName

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


示例18: isNativeClient

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public static boolean isNativeClient(Properties props) {
    return PropertiesHelper.getBoolean(CacheEnvironment.USE_NATIVE_CLIENT, props, false);
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:4,代码来源:CacheEnvironment.java


示例19: shutdownOnStop

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public static boolean shutdownOnStop(Properties props, boolean defaultValue) {
    return PropertiesHelper.getBoolean(CacheEnvironment.SHUTDOWN_ON_STOP, props, defaultValue);
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:4,代码来源:CacheEnvironment.java


示例20: isExplicitVersionCheckEnabled

import org.hibernate.util.PropertiesHelper; //导入依赖的package包/类
public static boolean isExplicitVersionCheckEnabled(Properties props) {
    return PropertiesHelper.getBoolean(CacheEnvironment.EXPLICIT_VERSION_CHECK, props, false);
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:4,代码来源:CacheEnvironment.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SQLObject类代码示例发布时间:2022-05-22
下一篇:
Java WMSParams类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap