本文整理汇总了Java中org.hibernate.internal.util.ReflectHelper类的典型用法代码示例。如果您正苦于以下问题:Java ReflectHelper类的具体用法?Java ReflectHelper怎么用?Java ReflectHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReflectHelper类属于org.hibernate.internal.util包,在下文中一共展示了ReflectHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: setParameterValues
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void setParameterValues(Properties parameters) {
ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE );
if ( reader != null ) {
setJavaTypeDescriptor( new SerializableTypeDescriptor<T>( reader.getReturnedClass() ) );
} else {
String className = parameters.getProperty( CLASS_NAME );
if ( className == null ) {
throw new MappingException( "No class name defined for type: " + SerializableToBlobType.class.getName() );
}
try {
setJavaTypeDescriptor( new SerializableTypeDescriptor<T>( ReflectHelper.classForName( className ) ) );
} catch ( ClassNotFoundException e ) {
throw new MappingException( "Unable to load class from " + CLASS_NAME + " parameter", e );
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:SerializableToBlobType.java
示例17: setParameterValues
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void setParameterValues(Properties parameters) {
if (parameters == null) {
throw new MappingException("No class or return type defined for type: " + JsonBlobType.class.getName());
}
DynamicParameterizedType.ParameterType reader = (DynamicParameterizedType.ParameterType) parameters.get(PARAMETER_TYPE);
if (reader != null) {
setJavaTypeDescriptor(new JsonTypeDescriptor<T>(reader.getReturnedClass()));
} else {
String className = parameters.getProperty(RETURNED_CLASS);
if (className == null) {
throw new MappingException("No class name defined for type: " + JsonBlobType.class.getName());
}
try {
setJavaTypeDescriptor(new JsonTypeDescriptor<T>(ReflectHelper.classForName(className)));
} catch (ClassNotFoundException e) {
throw new MappingException("Unable to load class from " + RETURNED_CLASS + " parameter", e);
}
}
}
开发者ID:hflabs,项目名称:perecoder,代码行数:22,代码来源:JsonBlobType.java
示例18: setGroupsForOperation
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private void setGroupsForOperation(Operation operation, Properties properties) {
Object property = properties.get( operation.getGroupPropertyName() );
Class<?>[] groups;
if ( property == null ) {
groups = operation == Operation.DELETE ? EMPTY_GROUPS : DEFAULT_GROUPS;
}
else {
if ( property instanceof String ) {
String stringProperty = (String) property;
String[] groupNames = stringProperty.split( "," );
if ( groupNames.length == 1 && groupNames[0].equals( "" ) ) {
groups = EMPTY_GROUPS;
}
else {
List<Class<?>> groupsList = new ArrayList<Class<?>>(groupNames.length);
for (String groupName : groupNames) {
String cleanedGroupName = groupName.trim();
if ( cleanedGroupName.length() > 0) {
try {
groupsList.add( ReflectHelper.classForName( cleanedGroupName ) );
}
catch ( ClassNotFoundException e ) {
throw new HibernateException( "Unable to load class " + cleanedGroupName, e );
}
}
}
groups = groupsList.toArray( new Class<?>[groupsList.size()] );
}
}
else if ( property instanceof Class<?>[] ) {
groups = (Class<?>[]) property;
}
else {
//null is bad and excluded by instanceof => exception is raised
throw new HibernateException( JPA_GROUP_PREFIX + operation.getGroupPropertyName() + " is of unknown type: String or Class<?>[] only");
}
}
groupsPerOperation.put( operation, groups );
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:GroupsPerOperation.java
示例19: 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 );
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:JPAOverriddenAnnotationReader.java
示例20: 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 ) );
}
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:JPAOverriddenAnnotationReader.java
注:本文中的org.hibernate.internal.util.ReflectHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论