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

Java ReflectHelper类代码示例

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

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



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

示例1: createBatcherFactory

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
protected BatcherFactory createBatcherFactory(Properties properties, int batchSize) {
	String batcherClass = properties.getProperty(Environment.BATCH_STRATEGY);
	if (batcherClass==null) {
		return batchSize==0 ?
				(BatcherFactory) new NonBatchingBatcherFactory() :
				(BatcherFactory) new BatchingBatcherFactory();
	}
	else {
		log.info("Batcher factory: " + batcherClass);
		try {
			return (BatcherFactory) ReflectHelper.classForName(batcherClass).newInstance();
		}
		catch (Exception cnfe) {
			throw new HibernateException("could not instantiate BatcherFactory: " + batcherClass, cnfe);
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:SettingsFactory.java


示例2: getElementClass

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
public Class getElementClass() throws MappingException {
	if (elementClassName==null) {
		org.hibernate.type.Type elementType = getElement().getType();
		return isPrimitiveArray() ?
			( (PrimitiveType) elementType ).getPrimitiveClass() :
			elementType.getReturnedClass();
	}
	else {
		try {
			return ReflectHelper.classForName(elementClassName);
		}
		catch (ClassNotFoundException cnfe) {
			throw new MappingException(cnfe);
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:17,代码来源:Array.java


示例3: checkCompositeIdentifier

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
private void checkCompositeIdentifier() {
	if ( getIdentifier() instanceof Component ) {
		Component id = (Component) getIdentifier();
		if ( !id.isDynamic() ) {
			Class idClass = id.getComponentClass();
			if ( idClass != null && !ReflectHelper.overridesEquals( idClass ) ) {
				LogFactory.getLog(RootClass.class)
					.warn( "composite-id class does not override equals(): "
						+ id.getComponentClass().getName() );
			}
			if ( !ReflectHelper.overridesHashCode( idClass ) ) {
				LogFactory.getLog(RootClass.class)
					.warn( "composite-id class does not override hashCode(): "
						+ id.getComponentClass().getName() );
			}
			if ( !Serializable.class.isAssignableFrom( idClass ) ) {
				throw new MappingException( "composite-id class must implement Serializable: "
					+ id.getComponentClass().getName() );
			}
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:RootClass.java


示例4: getTransactionManagerLookup

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
public static final TransactionManagerLookup getTransactionManagerLookup(Properties props) throws HibernateException {

		String tmLookupClass = props.getProperty(Environment.TRANSACTION_MANAGER_STRATEGY);
		if (tmLookupClass==null) {
			log.info("No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)");
			return null;
		}
		else {

			log.info("instantiating TransactionManagerLookup: " + tmLookupClass);

			try {
				TransactionManagerLookup lookup = (TransactionManagerLookup) ReflectHelper.classForName(tmLookupClass).newInstance();
				log.info("instantiated TransactionManagerLookup");
				return lookup;
			}
			catch (Exception e) {
				log.error("Could not instantiate TransactionManagerLookup", e);
				throw new HibernateException("Could not instantiate TransactionManagerLookup '" + tmLookupClass + "'");
			}
		}
	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:TransactionManagerLookupFactory.java


示例5: getSetterOrNull

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
private static BasicSetter getSetterOrNull(Class theClass, String propertyName) {

		if (theClass==Object.class || theClass==null) return null;

		Method method = setterMethod(theClass, propertyName);

		if (method!=null) {
			if ( !ReflectHelper.isPublic(theClass, method) ) method.setAccessible(true);
			return new BasicSetter(theClass, method, propertyName);
		}
		else {
			BasicSetter setter = getSetterOrNull( theClass.getSuperclass(), propertyName );
			if (setter==null) {
				Class[] interfaces = theClass.getInterfaces();
				for ( int i=0; setter==null && i<interfaces.length; i++ ) {
					setter=getSetterOrNull( interfaces[i], propertyName );
				}
			}
			return setter;
		}

	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:BasicPropertyAccessor.java


示例6: getGetterOrNull

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
private static BasicGetter getGetterOrNull(Class theClass, String propertyName) {

		if (theClass==Object.class || theClass==null) return null;

		Method method = getterMethod(theClass, propertyName);

		if (method!=null) {
			if ( !ReflectHelper.isPublic(theClass, method) ) method.setAccessible(true);
			return new BasicGetter(theClass, method, propertyName);
		}
		else {
			BasicGetter getter = getGetterOrNull( theClass.getSuperclass(), propertyName );
			if (getter==null) {
				Class[] interfaces = theClass.getInterfaces();
				for ( int i=0; getter==null && i<interfaces.length; i++ ) {
					getter=getGetterOrNull( interfaces[i], propertyName );
				}
			}
			return getter;
		}
	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:BasicPropertyAccessor.java


示例7: getConfiguration

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
private Configuration getConfiguration() throws Exception {
	Configuration cfg = new Configuration();
	if (namingStrategy!=null) {
		cfg.setNamingStrategy(
				(NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
			);
	}
	if (configurationFile != null) {
		cfg.configure( configurationFile );
	}

	String[] files = getFiles();
	for (int i = 0; i < files.length; i++) {
		String filename = files[i];
		if ( filename.endsWith(".jar") ) {
			cfg.addJar( new File(filename) );
		}
		else {
			cfg.addFile(filename);
		}
	}
	return cfg;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:24,代码来源:SchemaExportTask.java


示例8: getConfiguration

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
private Configuration getConfiguration() throws Exception {
	Configuration cfg = new Configuration();
	if (namingStrategy!=null) {
		cfg.setNamingStrategy(
				(NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
			);
	}
	if (configurationFile!=null) {
		cfg.configure( configurationFile );
	}

	String[] files = getFiles();
	for (int i = 0; i < files.length; i++) {
		String filename = files[i];
		if ( filename.endsWith(".jar") ) {
			cfg.addJar( new File(filename) );
		}
		else {
			cfg.addFile(filename);
		}
	}
	return cfg;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:24,代码来源:SchemaUpdateTask.java


示例9: PojoInstantiator

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
	this.mappedClass = component.getComponentClass();
	this.optimizer = optimizer;

	this.proxyInterface = null;
	this.embeddedIdentifier = false;

	try {
		constructor = ReflectHelper.getDefaultConstructor(mappedClass);
	}
	catch ( PropertyNotFoundException pnfe ) {
		log.info(
		        "no default (no-argument) constructor for class: " +
				mappedClass.getName() +
				" (class must be instantiated by Interceptor)"
		);
		constructor = null;
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:PojoInstantiator.java


示例10: instantiate

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
public Object instantiate() {
	if ( ReflectHelper.isAbstractClass(mappedClass) ) {
		throw new InstantiationException( "Cannot instantiate abstract class or interface: ", mappedClass );
	}
	else if ( optimizer != null ) {
		return optimizer.newInstance();
	}
	else if ( constructor == null ) {
		throw new InstantiationException( "No default constructor for entity: ", mappedClass );
	}
	else {
		try {
			return constructor.newInstance( null );
		}
		catch ( Exception e ) {
			throw new InstantiationException( "Could not instantiate entity: ", mappedClass, e );
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:PojoInstantiator.java


示例11: setProperties

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
public Query setProperties(Object bean) throws HibernateException {
	Class clazz = bean.getClass();
	String[] params = getNamedParameters();
	for (int i = 0; i < params.length; i++) {
		String namedParam = params[i];
		try {
			Getter getter = ReflectHelper.getGetter( clazz, namedParam );
			Class retType = getter.getReturnType();
			final Object object = getter.get( bean );
			if ( Collection.class.isAssignableFrom( retType ) ) {
				setParameterList( namedParam, ( Collection ) object );
			}
			else if ( retType.isArray() ) {
			 	setParameterList( namedParam, ( Object[] ) object );
			}
			else {
				setParameter( namedParam, object, determineType( namedParam, retType ) );
			}
		}
		catch (PropertyNotFoundException pnfe) {
			// ignore
		}
	}
	return this;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:26,代码来源:AbstractQueryImpl.java


示例12: lookupConstant

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
public void lookupConstant(DotNode node) throws SemanticException {
	String text = ASTUtil.getPathText( node );
	Queryable persister = walker.getSessionFactoryHelper().findQueryableUsingImports( text );
	if ( persister != null ) {
		// the name of an entity class
		final String discrim = persister.getDiscriminatorSQLValue();
		node.setDataType( persister.getDiscriminatorType() );
		if ( InFragment.NULL.equals(discrim) || InFragment.NOT_NULL.equals(discrim) ) {
			throw new InvalidPathException( "subclass test not allowed for null or not null discriminator: '" + text + "'" );
		}
		else {
			setSQLValue( node, text, discrim ); //the class discriminator value
		}
	}
	else {
		Object value = ReflectHelper.getConstantValue( text );
		if ( value == null ) {
			throw new InvalidPathException( "Invalid path: '" + text + "'" );
		}
		else {
			setConstantValue( node, text, value );
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:25,代码来源:LiteralProcessor.java


示例13: customCollection

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
public static CollectionType customCollection(
		String typeName,
		Properties typeParameters,
		String role,
		String propertyRef,
		boolean embedded) {
	Class typeClass;
	try {
		typeClass = ReflectHelper.classForName( typeName );
	}
	catch ( ClassNotFoundException cnfe ) {
		throw new MappingException( "user collection type class not found: " + typeName, cnfe );
	}
	CustomCollectionType result = new CustomCollectionType( typeClass, role, propertyRef, embedded );
	if ( typeParameters != null ) {
		TypeFactory.injectParameters( result.getUserType(), typeParameters );
	}
	return result;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:TypeFactory.java


示例14: isInstance

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
public boolean isInstance(Object object) {
		String resolvedEntityName = null;
		if ( Proxy.isProxyClass( object.getClass() ) ) {
			InvocationHandler handler = Proxy.getInvocationHandler( object );
			if ( DataProxyHandler.class.isAssignableFrom( handler.getClass() ) ) {
				DataProxyHandler myHandler = ( DataProxyHandler ) handler;
				resolvedEntityName = myHandler.getEntityName();
			}
		}
		try {
			return ReflectHelper.classForName( entityName ).isInstance( object );
		}
		catch( Throwable t ) {
			throw new HibernateException( "could not get handle to entity-name as interface : " + t );
		}

//		return entityName.equals( resolvedEntityName );
	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:19,代码来源:MyEntityInstantiator.java


示例15: getSetterOrNull

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
/**
 * @param theClass Target class in which the value is to be set
 * @param propertyName Target property name
 * @return returns Setter class instance
 */
@SuppressWarnings("PMD.AccessorClassGeneration")
private static CollectionPropertySetter getSetterOrNull(Class theClass, String propertyName) {

    if (theClass == Object.class || theClass == null) {
        return null;
    }

    Method method  =  setterMethod(theClass, propertyName);

    if (method != null) {
        if (!ReflectHelper.isPublic(theClass, method)) {
            method.setAccessible(true); 
        }
        return new CollectionPropertySetter(theClass, method, propertyName);
    } else {
        CollectionPropertySetter setter  =  getSetterOrNull(theClass.getSuperclass(), propertyName);
        if (setter == null) {
            Class[] interfaces = theClass.getInterfaces();
            for (int i = 0; setter == null && i < interfaces.length; i++) {
                setter = getSetterOrNull(interfaces[i], propertyName);
            }
        }
        return setter;
    }
}
 
开发者ID:NCIP,项目名称:iso21090,代码行数:31,代码来源:CollectionPropertyAccessor.java


示例16: buildDialect

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
/**
 * Returns a dialect instance given the name of the class to use.
 *
 * @param dialectName The name of the dialect class.
 *
 * @return The dialect instance.
 */
public static Dialect buildDialect(String dialectName) {
    try {
        return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance();
    }
    catch ( ClassNotFoundException cnfe ) {
        throw new HibernateException( "Dialect class not found: " + dialectName );
    }
    catch ( Exception e ) {
        throw new HibernateException( "Could not instantiate dialect class", e );
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:19,代码来源:DialectFactory.java


示例17: setListeners

import org.hibernate.util.ReflectHelper; //导入依赖的package包/类
public void setListeners(String type, String[] listenerClasses) {
	Object[] listeners = (Object[]) Array.newInstance( eventListeners.getListenerClassFor(type), listenerClasses.length );
	for ( int i = 0; i < listeners.length ; i++ ) {
		try {
			listeners[i] = ReflectHelper.classForName( listenerClasses[i] ).newInstance();
		}
		catch (Exception e) {
			throw new MappingException(
					"Unable to instantiate specified event (" + type + ") listener class: " + listenerClasses[i],
					e
				);
		}
	}
	setListeners( type, listeners );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:16,代码来源:Configuration.java


示例18: createQueryCacheFactory

import org.hibernate.util.ReflectHelper; //导入依赖的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


示例19: createCacheProvider

import org.hibernate.util.ReflectHelper; //导入依赖的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


示例20: createQueryTranslatorFactory

import org.hibernate.util.ReflectHelper; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java JdpException类代码示例发布时间:2022-05-22
下一篇:
Java Config类代码示例发布时间: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