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


Java ReflectHelper类代码示例

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


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


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