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


Java ReflectHelper类代码示例

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


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

示例1: parseIdentifierGeneratorRegistration

import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private static void parseIdentifierGeneratorRegistration(Element element, Mappings mappings) {
	String strategy = element.attributeValue( "name" );
	if ( StringHelper.isEmpty( strategy ) ) {
		throw new MappingException( "'name' attribute expected for identifier-generator elements" );
	}
	String generatorClassName = element.attributeValue( "class" );
	if ( StringHelper.isEmpty( generatorClassName ) ) {
		throw new MappingException( "'class' attribute expected for identifier-generator [[email protected]=" + strategy + "]" );
	}

	try {
		Class generatorClass = ReflectHelper.classForName( generatorClassName );
		mappings.getIdentifierGeneratorFactory().register( strategy, generatorClass );
	}
	catch ( ClassNotFoundException e ) {
		throw new MappingException( "Unable to locate identifier-generator class [name=" + strategy + ", class=" + generatorClassName + "]" );
	}

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:HbmBinder.java

示例2: addTargetClass

import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private void addTargetClass(Element element, AnnotationDescriptor ad, String nodeName, XMLContext.Default defaults) {
	String className = element.attributeValue( nodeName );
	if ( className != null ) {
		Class clazz;
		try {
			clazz = ReflectHelper.classForName(
					XMLContext.buildSafeClassName( className, defaults ), this.getClass()
			);
		}
		catch ( ClassNotFoundException e ) {
			throw new AnnotationException(
					"Unable to find " + element.getPath() + " " + nodeName + ": " + className, e
			);
		}
		ad.setValue( getJavaAttributeNameFromXMLOne( nodeName ), clazz );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:JPAOverriddenAnnotationReader.java

示例3: getMapKeyClass

import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private void getMapKeyClass(List<Annotation> annotationList, Element element, XMLContext.Default defaults) {
	String nodeName = "map-key-class";
	Element subelement = element != null ? element.element( nodeName ) : null;
	if ( subelement != null ) {
		String mapKeyClassName = subelement.attributeValue( "class" );
		AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyClass.class );
		if ( StringHelper.isNotEmpty( mapKeyClassName ) ) {
			Class clazz;
			try {
				clazz = ReflectHelper.classForName(
						XMLContext.buildSafeClassName( mapKeyClassName, defaults ),
						this.getClass()
				);
			}
			catch ( ClassNotFoundException e ) {
				throw new AnnotationException(
						"Unable to find " + element.getPath() + " " + nodeName + ": " + mapKeyClassName, e
				);
			}
			ad.setValue( "value", clazz );
		}
		annotationList.add( AnnotationFactory.create( ad ) );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:JPAOverriddenAnnotationReader.java

示例4: bindNamedSubgraph

import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private static void bindNamedSubgraph(XMLContext.Default defaults, AnnotationDescriptor ann, List<Element> subgraphNodes) {
	List<NamedSubgraph> annSubgraphNodes = new ArrayList<NamedSubgraph>(  );
	for(Element subgraphNode : subgraphNodes){
		AnnotationDescriptor annSubgraphNode = new AnnotationDescriptor( NamedSubgraph.class );
		copyStringAttribute( annSubgraphNode, subgraphNode, "name", true );
		String clazzName = subgraphNode.attributeValue( "class" );
		Class clazz;
		try {
			clazz = ReflectHelper.classForName(
					XMLContext.buildSafeClassName( clazzName, defaults ),
					JPAOverriddenAnnotationReader.class
			);
		}
		catch ( ClassNotFoundException e ) {
			throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
		}
		annSubgraphNode.setValue( "type", clazz );
		bindNamedAttributeNodes(subgraphNode, annSubgraphNode);
		annSubgraphNodes.add( (NamedSubgraph) AnnotationFactory.create( annSubgraphNode ) );
	}
	ann.setValue( "subgraphs", annSubgraphNodes.toArray( new NamedSubgraph[annSubgraphNodes.size()] ) );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:JPAOverriddenAnnotationReader.java

示例5: getElementClass

import org.hibernate.internal.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:lamsfoundation,项目名称:lams,代码行数:17,代码来源:Array.java

示例6: getConfiguration

import org.hibernate.internal.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:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SchemaExportTask.java

示例7: getConfiguration

import org.hibernate.internal.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:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SchemaUpdateTask.java

示例8: getConfiguration

import org.hibernate.internal.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:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SchemaValidatorTask.java

示例9: PojoInstantiator

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

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

	try {
		constructor = ReflectHelper.getDefaultConstructor(mappedClass);
	}
	catch ( PropertyNotFoundException pnfe ) {
		LOG.noDefaultConstructor(mappedClass.getName());
		constructor = null;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:PojoInstantiator.java

示例10: postInstantiate

import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
@Override
public void postInstantiate(
		final String entityName,
		final Class persistentClass,
		final Set interfaces,
		final Method getIdentifierMethod,
		final Method setIdentifierMethod,
		CompositeType componentIdType) throws HibernateException {
	this.entityName = entityName;
	this.persistentClass = persistentClass;
	this.interfaces = (Class[]) interfaces.toArray(NO_CLASSES);
	this.getIdentifierMethod = getIdentifierMethod;
	this.setIdentifierMethod = setIdentifierMethod;
	this.componentIdType = componentIdType;
	this.factory = JavassistLazyInitializer.getProxyFactory( persistentClass, this.interfaces );
	this.overridesEquals = ReflectHelper.overridesEquals(persistentClass);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:JavassistProxyFactory.java

示例11: getIdentifierGeneratorClass

import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
@Override
public Class getIdentifierGeneratorClass(String strategy) {
	if ( "native".equals( strategy ) ) {
		return dialect.getNativeIdentifierGeneratorClass();
	}

	Class generatorClass = generatorStrategyToClassNameMap.get( strategy );
	try {
		if ( generatorClass == null ) {
			generatorClass = ReflectHelper.classForName( strategy );
		}
	}
	catch ( ClassNotFoundException e ) {
		throw new MappingException( String.format( "Could not interpret id generator strategy [%s]", strategy ) );
	}
	return generatorClass;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:DefaultIdentifierGeneratorFactory.java

示例12: setProperties

import org.hibernate.internal.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:lamsfoundation,项目名称:lams,代码行数:26,代码来源:AbstractQueryImpl.java

示例13: locateOracleTypesClass

import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private Class locateOracleTypesClass() {
	try {
		return ReflectHelper.classForName( ORACLE_TYPES_CLASS_NAME );
	}
	catch (ClassNotFoundException e) {
		try {
			return ReflectHelper.classForName( DEPRECATED_ORACLE_TYPES_CLASS_NAME );
		}
		catch (ClassNotFoundException e2) {
			throw new HibernateException(
					String.format(
							"Unable to locate OracleTypes class using either known FQN [%s, %s]",
							ORACLE_TYPES_CLASS_NAME,
							DEPRECATED_ORACLE_TYPES_CLASS_NAME
					),
					e
			);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:OracleTypesHelper.java

示例14: lookupConstant

import org.hibernate.internal.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 + "'"
			);
		}
		// the class discriminator value
		setSQLValue( node, text, discrim );
	}
	else {
		Object value = ReflectHelper.getConstantValue( text );
		if ( value == null ) {
			throw new InvalidPathException( "Invalid path: '" + text + "'" );
		}
		setConstantValue( node, text, value );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:LiteralProcessor.java

示例15: customCollection

import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
/**
 * @deprecated Use {@link #customCollection(String, java.util.Properties, String, String)}
 * instead.
 * See Jira issue: <a href="https://hibernate.onjira.com/browse/HHH-7771">HHH-7771</a>
 */
@Deprecated
public 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( typeScope, typeClass, role, propertyRef, embedded );
	if ( typeParameters != null ) {
		injectParameters( result.getUserType(), typeParameters );
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:TypeFactory.java


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