本文整理汇总了Java中org.hibernate.internal.util.ReflectHelper.classForName方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectHelper.classForName方法的具体用法?Java ReflectHelper.classForName怎么用?Java ReflectHelper.classForName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.internal.util.ReflectHelper
的用法示例。
在下文中一共展示了ReflectHelper.classForName方法的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 + "]" );
}
}
示例2: customCollection
import org.hibernate.internal.util.ReflectHelper; //导入方法依赖的package包/类
public CollectionType customCollection(
String typeName,
Properties typeParameters,
String role,
String propertyRef) {
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 );
if ( typeParameters != null ) {
injectParameters( result.getUserType(), typeParameters );
}
return result;
}
示例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 ) );
}
}
示例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()] ) );
}
示例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);
}
}
}
示例6: 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;
}
示例7: applyXmlDefinedConverts
import org.hibernate.internal.util.ReflectHelper; //导入方法依赖的package包/类
private void applyXmlDefinedConverts(
Element containingElement,
XMLContext.Default defaults,
String attributeNamePrefix,
Map<String,Convert> convertAnnotationsMap) {
final List<Element> convertElements = containingElement.elements( "convert" );
for ( Element convertElement : convertElements ) {
final AnnotationDescriptor convertAnnotationDescriptor = new AnnotationDescriptor( Convert.class );
copyStringAttribute( convertAnnotationDescriptor, convertElement, "attribute-name", false );
copyBooleanAttribute( convertAnnotationDescriptor, convertElement, "disable-conversion" );
final Attribute converterClassAttr = convertElement.attribute( "converter" );
if ( converterClassAttr != null ) {
final String converterClassName = XMLContext.buildSafeClassName(
converterClassAttr.getValue(),
defaults
);
try {
final Class converterClass = ReflectHelper.classForName( converterClassName, this.getClass() );
convertAnnotationDescriptor.setValue( "converter", converterClass );
}
catch (ClassNotFoundException e) {
throw new AnnotationException( "Unable to find specified converter class id-class: " + converterClassName, e );
}
}
final Convert convertAnnotation = AnnotationFactory.create( convertAnnotationDescriptor );
final String qualifiedAttributeName = qualifyConverterAttributeName(
attributeNamePrefix,
convertAnnotation.attributeName()
);
convertAnnotationsMap.put( qualifiedAttributeName, convertAnnotation );
}
}
示例8: checkForOrphanProperties
import org.hibernate.internal.util.ReflectHelper; //导入方法依赖的package包/类
private void checkForOrphanProperties(Element tree) {
Class clazz;
try {
clazz = ReflectHelper.classForName( className, this.getClass() );
}
catch ( ClassNotFoundException e ) {
return; //a primitive type most likely
}
Element element = tree != null ? tree.element( "attributes" ) : null;
//put entity.attributes elements
if ( element != null ) {
//precompute the list of properties
//TODO is it really useful...
Set<String> properties = new HashSet<String>();
for ( Field field : clazz.getFields() ) {
properties.add( field.getName() );
}
for ( Method method : clazz.getMethods() ) {
String name = method.getName();
if ( name.startsWith( "get" ) ) {
properties.add( Introspector.decapitalize( name.substring( "get".length() ) ) );
}
else if ( name.startsWith( "is" ) ) {
properties.add( Introspector.decapitalize( name.substring( "is".length() ) ) );
}
}
for ( Element subelement : (List<Element>) element.elements() ) {
String propertyName = subelement.attributeValue( "name" );
if ( !properties.contains( propertyName ) ) {
LOG.propertyNotFound( StringHelper.qualify( className, propertyName ) );
}
}
}
}
示例9: resolveClassReference
import org.hibernate.internal.util.ReflectHelper; //导入方法依赖的package包/类
private static Class resolveClassReference(String className, XMLContext.Default defaults) {
if ( className == null ) {
throw new AnnotationException( "<entity-result> without entity-class. " + SCHEMA_VALIDATION );
}
try {
return ReflectHelper.classForName(
XMLContext.buildSafeClassName( className, defaults ),
JPAOverriddenAnnotationReader.class
);
}
catch ( ClassNotFoundException e ) {
throw new AnnotationException( "Unable to find specified class: " + className, e );
}
}
示例10: getIdClass
import org.hibernate.internal.util.ReflectHelper; //导入方法依赖的package包/类
private IdClass getIdClass(Element tree, XMLContext.Default defaults) {
Element element = tree == null ? null : tree.element( "id-class" );
if ( element != null ) {
Attribute attr = element.attribute( "class" );
if ( attr != null ) {
AnnotationDescriptor ad = new AnnotationDescriptor( IdClass.class );
Class clazz;
try {
clazz = ReflectHelper.classForName(
XMLContext.buildSafeClassName( attr.getValue(), defaults ),
this.getClass()
);
}
catch ( ClassNotFoundException e ) {
throw new AnnotationException( "Unable to find id-class: " + attr.getValue(), e );
}
ad.setValue( "value", clazz );
return AnnotationFactory.create( ad );
}
else {
throw new AnnotationException( "id-class without class. " + SCHEMA_VALIDATION );
}
}
else if ( defaults.canUseJavaAnnotations() ) {
return getPhysicalAnnotation( IdClass.class );
}
else {
return null;
}
}
示例11: getComponentClass
import org.hibernate.internal.util.ReflectHelper; //导入方法依赖的package包/类
public Class getComponentClass() throws MappingException {
try {
return ReflectHelper.classForName(componentClassName);
}
catch (ClassNotFoundException cnfe) {
throw new MappingException("component class not found: " + componentClassName, cnfe);
}
}
示例12: getMappedClass
import org.hibernate.internal.util.ReflectHelper; //导入方法依赖的package包/类
public Class getMappedClass() throws MappingException {
if (className==null) return null;
try {
if(mappedClass == null) {
mappedClass = ReflectHelper.classForName(className);
}
return mappedClass;
}
catch (ClassNotFoundException cnfe) {
throw new MappingException("entity class not found: " + className, cnfe);
}
}
示例13: fromString
import org.hibernate.internal.util.ReflectHelper; //导入方法依赖的package包/类
public Class fromString(String string) {
if ( string == null ) {
return null;
}
try {
return ReflectHelper.classForName( string );
}
catch ( ClassNotFoundException e ) {
throw new HibernateException( "Unable to locate named class " + string );
}
}
示例14: resolveCustomAccessor
import org.hibernate.internal.util.ReflectHelper; //导入方法依赖的package包/类
private static PropertyAccessor resolveCustomAccessor(String accessorName) {
Class accessorClass;
try {
accessorClass = ReflectHelper.classForName( accessorName );
}
catch (ClassNotFoundException cnfe) {
throw new MappingException("could not find PropertyAccessor class: " + accessorName, cnfe);
}
try {
return (PropertyAccessor) accessorClass.newInstance();
}
catch (Exception e) {
throw new MappingException("could not instantiate PropertyAccessor class: " + accessorName, e);
}
}
示例15: constructTuplizer
import org.hibernate.internal.util.ReflectHelper; //导入方法依赖的package包/类
/**
* Construct an instance of the given tuplizer class.
*
* @param tuplizerClassName The name of the tuplizer class to instantiate
* @param metamodel The metadata for the entity.
* @param persistentClass The mapping info for the entity.
*
* @return The instantiated tuplizer
*
* @throws HibernateException If class name cannot be resolved to a class reference, or if the
* {@link Constructor#newInstance} call fails.
*/
@SuppressWarnings({ "unchecked" })
public EntityTuplizer constructTuplizer(
String tuplizerClassName,
EntityMetamodel metamodel,
PersistentClass persistentClass) {
try {
Class<? extends EntityTuplizer> tuplizerClass = ReflectHelper.classForName( tuplizerClassName );
return constructTuplizer( tuplizerClass, metamodel, persistentClass );
}
catch ( ClassNotFoundException e ) {
throw new HibernateException( "Could not locate specified tuplizer class [" + tuplizerClassName + "]" );
}
}