HHH-8956 - JandexHelper love

This commit is contained in:
Steve Ebersole 2014-03-19 17:09:27 -05:00
parent e83691501f
commit 9d0af62385
29 changed files with 1045 additions and 360 deletions

View File

@ -0,0 +1,90 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.metamodel.spi.ClassLoaderAccess;
import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
public class ClassLoaderAccessImpl implements ClassLoaderAccess {
private static final Logger log = Logger.getLogger( ClassLoaderAccessImpl.class );
private final ClassLoader jpaTempClassLoader;
private final ClassLoaderService classLoaderService;
public ClassLoaderAccessImpl(
ClassLoader jpaTempClassLoader,
ClassLoaderService classLoaderService) {
this.jpaTempClassLoader = jpaTempClassLoader;
this.classLoaderService = classLoaderService;
}
public ClassLoaderAccessImpl(ClassLoader tempClassLoader, StandardServiceRegistry serviceRegistry) {
this( tempClassLoader, serviceRegistry.getService( ClassLoaderService.class ) );
}
@Override
public Class classForName(String name) {
if ( isSafeClass( name ) ) {
return classLoaderService.classForName( name );
}
else {
log.debugf( "Not known whether passed class name [%s] is safe", name );
if ( jpaTempClassLoader == null ) {
log.debugf(
"No temp ClassLoader provided; using live ClassLoader " +
"for loading potentially unsafe class : %s",
name
);
return classLoaderService.classForName( name );
}
else {
log.debugf(
"Temp ClassLoader was provided, so we will use that : %s",
name
);
try {
return jpaTempClassLoader.loadClass( name );
}
catch (ClassNotFoundException e) {
throw new ClassLoadingException( name );
}
}
}
}
private boolean isSafeClass(String name) {
// classes in any of these packages are safe to load through the "live" ClassLoader
return name.startsWith( "java." )
|| name.startsWith( "javax." )
|| name.startsWith( "org.hibernate" );
}
}

View File

@ -54,7 +54,6 @@ import org.hibernate.engine.spi.NamedSQLQueryDefinition;
import org.hibernate.engine.spi.SyntheticAttributeHelper;
import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.MetadataSourceProcessingOrder;
import org.hibernate.metamodel.MetadataSources;
@ -65,6 +64,8 @@ import org.hibernate.metamodel.reflite.internal.JavaTypeDescriptorRepositoryImpl
import org.hibernate.metamodel.reflite.spi.JavaTypeDescriptor;
import org.hibernate.metamodel.reflite.spi.JavaTypeDescriptorRepository;
import org.hibernate.metamodel.source.internal.annotations.AnnotationMetadataSourceProcessorImpl;
import org.hibernate.metamodel.source.internal.annotations.JandexAccess;
import org.hibernate.metamodel.source.internal.annotations.JandexAccessImpl;
import org.hibernate.metamodel.source.internal.hbm.HbmMetadataSourceProcessorImpl;
import org.hibernate.metamodel.source.internal.jandex.Unifier;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
@ -76,6 +77,7 @@ import org.hibernate.metamodel.source.spi.MetaAttributeContext;
import org.hibernate.metamodel.source.spi.TypeDescriptorSource;
import org.hibernate.metamodel.spi.AdditionalJaxbRootProducer;
import org.hibernate.metamodel.spi.BindingContext;
import org.hibernate.metamodel.spi.ClassLoaderAccess;
import org.hibernate.metamodel.spi.InFlightMetadataCollector;
import org.hibernate.metamodel.spi.MetadataBuildingOptions;
import org.hibernate.metamodel.spi.MetadataContributor;
@ -97,7 +99,6 @@ import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
import org.hibernate.metamodel.spi.binding.SecondaryTable;
import org.hibernate.metamodel.spi.binding.TypeDefinition;
import org.hibernate.metamodel.spi.domain.BasicType;
import org.hibernate.metamodel.spi.domain.JavaClassReference;
import org.hibernate.metamodel.spi.domain.SingularAttribute;
import org.hibernate.metamodel.spi.domain.Type;
import org.hibernate.metamodel.spi.relational.Database;
@ -135,11 +136,19 @@ public class MetadataBuildingProcess {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// prep to start handling binding in earnest
final MappingDefaultsImpl mappingDefaults = new MappingDefaultsImpl( options );
final JavaTypeDescriptorRepository javaTypeDescriptorRepository = new JavaTypeDescriptorRepositoryImpl(
jandexView,
final ClassLoaderAccess classLoaderAccess = new ClassLoaderAccessImpl(
options.getTempClassLoader(),
options.getServiceRegistry()
);
final JandexAccessImpl jandexAccess = new JandexAccessImpl(
jandexView,
classLoaderAccess
);
final JavaTypeDescriptorRepository javaTypeDescriptorRepository = new JavaTypeDescriptorRepositoryImpl(
jandexAccess,
classLoaderAccess
);
final InFlightMetadataCollectorImpl metadataCollector = new InFlightMetadataCollectorImpl(
options,
new TypeResolver( basicTypeRegistry, new TypeFactory() )
@ -148,6 +157,8 @@ public class MetadataBuildingProcess {
options,
mappingDefaults,
javaTypeDescriptorRepository,
jandexAccess,
classLoaderAccess,
metadataCollector
);
@ -495,22 +506,24 @@ public class MetadataBuildingProcess {
private final MetadataBuildingOptions options;
private final MappingDefaults mappingDefaults;
private final JavaTypeDescriptorRepository javaTypeDescriptorRepository;
private final JandexAccessImpl jandexAccess;
private final ClassLoaderAccess classLoaderAccess;
private final InFlightMetadataCollectorImpl metadataCollector;
private final MetaAttributeContext globalMetaAttributeContext = new MetaAttributeContext();
private final ClassLoaderService classLoaderService;
public RootBindingContextImpl(
MetadataBuildingOptions options,
MappingDefaults mappingDefaults,
MappingDefaultsImpl mappingDefaults,
JavaTypeDescriptorRepository javaTypeDescriptorRepository,
JandexAccessImpl jandexAccess,
ClassLoaderAccess classLoaderAccess,
InFlightMetadataCollectorImpl metadataCollector) {
this.options = options;
this.mappingDefaults = mappingDefaults;
this.javaTypeDescriptorRepository = javaTypeDescriptorRepository;
this.jandexAccess = jandexAccess;
this.classLoaderAccess = classLoaderAccess;
this.metadataCollector = metadataCollector;
this.classLoaderService = options.getServiceRegistry().getService( ClassLoaderService.class );
}
@Override
@ -523,6 +536,11 @@ public class MetadataBuildingProcess {
return mappingDefaults;
}
@Override
public JandexAccess getJandexAccess() {
return jandexAccess;
}
@Override
public JavaTypeDescriptorRepository getJavaTypeDescriptorRepository() {
return javaTypeDescriptorRepository;
@ -550,6 +568,11 @@ public class MetadataBuildingProcess {
return options.getServiceRegistry();
}
@Override
public ClassLoaderAccess getClassLoaderAccess() {
return classLoaderAccess;
}
@Override
public boolean quoteIdentifiersInContext() {
return options.getDatabaseDefaults().isGloballyQuotedIdentifiers();
@ -560,14 +583,10 @@ public class MetadataBuildingProcess {
return javaTypeDescriptorRepository.getType( javaTypeDescriptorRepository.buildName( qualifyClassName( name ) ) );
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// BindingContext deprecated impls
@Override
public <T> Class<T> locateClassByName(String name) {
return classLoaderService.classForName( name );
}
@Override
public Type makeDomainType(String className) {
return new BasicType( className, typeDescriptor( className ) );
@ -580,58 +599,6 @@ public class MetadataBuildingProcess {
typeDescriptor( typeName.toString() )
);
}
private Map<String, JavaClassReference> nameToJavaTypeMap = new HashMap<String, JavaClassReference>();
@Override
public JavaClassReference makeJavaClassReference(String className) {
if ( className == null ) {
throw new IllegalArgumentException( "className must be non-null." );
}
JavaClassReference javaClassReference = nameToJavaTypeMap.get( className );
if ( javaClassReference == null ) {
javaClassReference = new JavaClassReference( className, classLoaderService );
nameToJavaTypeMap.put( className, javaClassReference );
}
return javaClassReference;
}
@Override
public JavaClassReference makeJavaClassReference(Class<?> clazz) {
if ( clazz == null ) {
throw new IllegalArgumentException( "clazz must be non-null." );
}
JavaClassReference javaClassReference = nameToJavaTypeMap.get( clazz.getName() );
if ( javaClassReference == null ) {
javaClassReference = new JavaClassReference( clazz );
nameToJavaTypeMap.put( clazz.getName(), javaClassReference );
}
return javaClassReference;
}
@Override
public JavaClassReference makeJavaPropertyClassReference(
JavaClassReference propertyContainerClassReference, String propertyName) {
if ( propertyContainerClassReference == null || propertyName == null ) {
throw new IllegalArgumentException( "propertyContainerClassReference and propertyName must be non-null." );
}
try {
return makeJavaClassReference(
ReflectHelper.reflectedPropertyClass(
propertyContainerClassReference.getResolvedClass(),
propertyName
)
);
}
catch ( Exception ignore ) {
log.debugf(
"Unable to locate attribute [%s] on class [%s]",
propertyName,
propertyContainerClassReference.getName()
);
}
return null;
}
}
public static class MappingDefaultsImpl implements MappingDefaults {

View File

@ -334,7 +334,7 @@ public class Binder {
final String customTuplizerClassName = source.getCustomTuplizerClassName();
if ( customTuplizerClassName != null ) {
binding.setCustomEntityTuplizerClass(
localBindingContext().<EntityTuplizer>locateClassByName(
localBindingContext().getClassLoaderAccess().<EntityTuplizer>classForName(
customTuplizerClassName
)
);
@ -342,7 +342,7 @@ public class Binder {
final String customPersisterClassName = source.getCustomPersisterClassName();
if ( customPersisterClassName != null ) {
binding.setCustomEntityPersisterClass(
localBindingContext().<EntityPersister>locateClassByName(
localBindingContext().getClassLoaderAccess().<EntityPersister>classForName(
customPersisterClassName
)
);
@ -2142,7 +2142,7 @@ public class Binder {
if ( StringHelper.isNotEmpty( attributeSource.getCustomPersisterClassName() ) ) {
attributeBinding.setExplicitPersisterClass(
localBindingContext().<CollectionPersister>locateClassByName(
localBindingContext().getClassLoaderAccess().<CollectionPersister>classForName(
attributeSource.getCustomPersisterClassName()
)
);
@ -2845,8 +2845,9 @@ public class Binder {
attributeBinding.setSorted( sortable.isSorted() );
if ( sortable.isSorted()
&& !sortable.getComparatorName().equalsIgnoreCase( "natural" ) ) {
Class<Comparator<?>> comparatorClass =
localBindingContext().locateClassByName( sortable.getComparatorName() );
Class<Comparator<?>> comparatorClass = localBindingContext().
getClassLoaderAccess()
.classForName( sortable.getComparatorName() );
try {
attributeBinding.setComparator( comparatorClass.newInstance() );
}

View File

@ -34,7 +34,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.reflite.spi.ArrayDescriptor;
@ -47,13 +46,13 @@ import org.hibernate.metamodel.reflite.spi.MethodDescriptor;
import org.hibernate.metamodel.reflite.spi.ParameterizedType;
import org.hibernate.metamodel.reflite.spi.PrimitiveTypeDescriptor;
import org.hibernate.metamodel.reflite.spi.VoidDescriptor;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.metamodel.source.internal.annotations.JandexAccessImpl;
import org.hibernate.metamodel.spi.ClassLoaderAccess;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.MethodInfo;
import org.jboss.jandex.MethodParameterInfo;
import org.jboss.logging.Logger;
@ -76,10 +75,8 @@ import com.fasterxml.classmate.members.ResolvedMethod;
public class JavaTypeDescriptorRepositoryImpl implements JavaTypeDescriptorRepository {
private static final Logger log = Logger.getLogger( JavaTypeDescriptorRepositoryImpl.class );
private final ClassLoader jpaTempClassLoader;
private final ClassLoaderService classLoaderService;
private final IndexView jandexIndex;
private final JandexAccessImpl jandexAccess;
private final ClassLoaderAccess classLoaderAccess;
private final TypeResolver classmateTypeResolver;
private final MemberResolver classmateMemberResolver;
@ -92,19 +89,10 @@ public class JavaTypeDescriptorRepositoryImpl implements JavaTypeDescriptorRepos
private final InterfaceDescriptor jdkMapDescriptor;
public JavaTypeDescriptorRepositoryImpl(
IndexView jandexIndex,
ClassLoader jpaTempClassLoader,
ServiceRegistry serviceRegistry) {
this( jandexIndex, jpaTempClassLoader, serviceRegistry.getService( ClassLoaderService.class ) );
}
public JavaTypeDescriptorRepositoryImpl(
IndexView jandexIndex,
ClassLoader jpaTempClassLoader,
ClassLoaderService classLoaderService) {
this.jandexIndex = jandexIndex;
this.jpaTempClassLoader = jpaTempClassLoader;
this.classLoaderService = classLoaderService;
JandexAccessImpl jandexAccess,
ClassLoaderAccess classLoaderAccess) {
this.jandexAccess = jandexAccess;
this.classLoaderAccess = classLoaderAccess;
this.classmateTypeResolver = new TypeResolver();
this.classmateMemberResolver = new MemberResolver( classmateTypeResolver );
@ -224,54 +212,14 @@ public class JavaTypeDescriptorRepositoryImpl implements JavaTypeDescriptorRepos
protected JavaTypeDescriptor makeTypeDescriptor(DotName typeName) {
final String classNameToLoad = typeName.toString();
if ( isSafeClass( typeName ) ) {
return makeTypeDescriptor( typeName, classLoaderService.classForName( classNameToLoad ) );
try {
return makeTypeDescriptor( typeName, classLoaderAccess.classForName( classNameToLoad ) );
}
else {
if ( jpaTempClassLoader == null ) {
log.debug(
"Request to makeTypeDescriptor(%s) - but passed class is not known to be " +
"safe (it might be, it might not be). However, there was no " +
"temp ClassLoader provided; we will use the live ClassLoader"
);
try {
// this reference is "safe" because it was loaded from the live ClassLoader
return makeTypeDescriptor( typeName, classLoaderService.classForName( classNameToLoad ) );
}
catch (ClassLoadingException e) {
return new NoSuchClassTypeDescriptor( typeName );
}
}
else {
log.debug(
"Request to makeTypeDescriptor(%s) - passed class is not known to be " +
"safe (it might be, it might not be). There was a temp ClassLoader " +
"provided, so we will use that"
);
// this is the Class reference that is unsafe to keep around...
final Class unSafeReference;
try {
unSafeReference = jpaTempClassLoader.loadClass( classNameToLoad );
}
catch (ClassNotFoundException e) {
return new NoSuchClassTypeDescriptor( typeName );
}
return makeTypeDescriptor( typeName, unSafeReference );
}
catch (ClassLoadingException e) {
return new NoSuchClassTypeDescriptor( typeName );
}
}
private boolean isSafeClass(DotName className) {
final String classNameString = className.toString();
// classes in any of these packages are safe to load through the "live" ClassLoader
return classNameString.startsWith( "java." )
|| classNameString.startsWith( "javax." )
|| classNameString.startsWith( "org.hibernate" );
}
private JavaTypeDescriptor makeTypeDescriptor(DotName typeName, Class clazz) {
final JandexPivot jandexPivot = pivotAnnotations( typeName );
@ -340,11 +288,11 @@ public class JavaTypeDescriptorRepositoryImpl implements JavaTypeDescriptorRepos
private static final JandexPivot NO_JANDEX_PIVOT = new JandexPivot( null );
private JandexPivot pivotAnnotations(DotName typeName) {
if ( jandexIndex == null ) {
if ( jandexAccess.getIndex() == null ) {
return NO_JANDEX_PIVOT;
}
final ClassInfo jandexClassInfo = jandexIndex.getClassByName( typeName );
final ClassInfo jandexClassInfo = jandexAccess.getIndex().getClassByName( typeName );
if ( jandexClassInfo == null ) {
return new JandexPivot(
ClassInfo.create(

View File

@ -26,12 +26,6 @@ package org.hibernate.metamodel.source.internal.annotations;
import org.hibernate.metamodel.spi.BindingContext;
import org.hibernate.metamodel.spi.binding.IdentifierGeneratorDefinition;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.IndexView;
import com.fasterxml.classmate.MemberResolver;
import com.fasterxml.classmate.TypeResolver;
/**
* Defines an interface for providing additional annotation related context information.
*
@ -40,36 +34,5 @@ import com.fasterxml.classmate.TypeResolver;
* @author Strong Liu
*/
public interface AnnotationBindingContext extends BindingContext {
/**
* The annotation repository that this context know about.
*
* @return The {@link IndexView} that this context know about.
*/
IndexView getIndex();
/**
* Gets the class (or interface, or annotation) that was scanned during the
* indexing phase.
*
* @param className the name of the class
* @return information about the class or null if it is not known
*/
ClassInfo getClassInfo(String className);
/**
* Gets the {@literal ClassMate} {@link TypeResolver} used in this context.
*
* @return The {@link TypeResolver} associated within this context.
*/
TypeResolver getTypeResolver();
/**
* Gets the {@literal ClassMate} {@link MemberResolver} used in this context.
*
* @return The {@link MemberResolver} associated within this context.
*/
MemberResolver getMemberResolver();
IdentifierGeneratorDefinition findIdGenerator(String name);
}

View File

@ -23,18 +23,10 @@
*/
package org.hibernate.metamodel.source.internal.annotations;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.metamodel.spi.BaseDelegatingBindingContext;
import org.hibernate.metamodel.spi.BindingContext;
import org.hibernate.metamodel.spi.binding.IdentifierGeneratorDefinition;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;
import com.fasterxml.classmate.MemberResolver;
import com.fasterxml.classmate.TypeResolver;
/**
* Default implementation of {@code AnnotationBindingContext}
*
@ -45,46 +37,12 @@ public class AnnotationBindingContextImpl
extends BaseDelegatingBindingContext
implements AnnotationBindingContext {
private final TypeResolver classmateTypeResolver = new TypeResolver();
private final MemberResolver classmateMemberResolver = new MemberResolver( classmateTypeResolver );
private final IndexView index;
private final ClassLoaderService classLoaderService;
public AnnotationBindingContextImpl(BindingContext rootBindingContext, IndexView index) {
public AnnotationBindingContextImpl(BindingContext rootBindingContext) {
super( rootBindingContext );
this.classLoaderService = rootBindingContext.getBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class );
this.index = index;
}
@Override
public IndexView getIndex() {
return index;
}
@Override
public ClassInfo getClassInfo(String name) {
DotName dotName = DotName.createSimple( name );
return index.getClassByName( dotName );
}
@Override
public MemberResolver getMemberResolver() {
return classmateMemberResolver;
}
@Override
public TypeResolver getTypeResolver() {
return classmateTypeResolver;
}
@Override
public IdentifierGeneratorDefinition findIdGenerator(String name) {
return getMetadataCollector().getIdGenerator( name );
}
@Override
public <T> Class<T> locateClassByName(String name) {
return classLoaderService.classForName( name );
}
}

View File

@ -66,14 +66,14 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
bindingContext.getMetadataCollector().setGloballyQuotedIdentifiers( true );
}
this.bindingContext = new AnnotationBindingContextImpl( bindingContext, jandexView );
this.bindingContext = new AnnotationBindingContextImpl( bindingContext );
}
@Override
public Iterable<TypeDescriptorSource> extractTypeDefinitionSources() {
List<TypeDescriptorSource> typeDescriptorSources = new ArrayList<TypeDescriptorSource>();
Collection<AnnotationInstance> annotations = JandexHelper.getAnnotations(
bindingContext.getIndex(),
bindingContext.getJandexAccess().getIndex(),
HibernateDotNames.TYPE_DEF,
HibernateDotNames.TYPE_DEFS,
bindingContext.getBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class )
@ -88,7 +88,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
public Iterable<FilterDefinitionSource> extractFilterDefinitionSources() {
List<FilterDefinitionSource> filterDefinitionSources = new ArrayList<FilterDefinitionSource>();
Collection<AnnotationInstance> annotations = JandexHelper.getAnnotations(
bindingContext.getIndex(),
bindingContext.getJandexAccess().getIndex(),
HibernateDotNames.FILTER_DEF,
HibernateDotNames.FILTER_DEFS,
bindingContext.getBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class )

View File

@ -84,34 +84,38 @@ public class DiscriminatorSourceImpl
}
this.isFormula = discriminatorFormula != null;
if ( isFormula ) {
final String expression = JandexHelper.getValue(
discriminatorFormula,
"value",
String.class,
cls
);
final String expression = entityTypeMetadata.getLocalBindingContext()
.getJandexAccess()
.getTypedValueExtractor( String.class )
.extract( discriminatorFormula, "value" );
this.relationalValueSource = new DerivedValueSourceImpl( expression, null );
}
else {
discriminatorType = JandexHelper.getEnumValue(
discriminatorColumn,
"discriminatorType",
DiscriminatorType.class,
cls
);
discriminatorType = entityTypeMetadata.getLocalBindingContext()
.getJandexAccess()
.getTypedValueExtractor( DiscriminatorType.class )
.extract( discriminatorColumn, "discriminatorType" );
final Column column = new Column( null );
column.setNullable( false );
column.setName(
JandexHelper.getValue( discriminatorColumn, "name", String.class, cls )
entityTypeMetadata.getLocalBindingContext()
.getJandexAccess()
.getTypedValueExtractor( String.class )
.extract( discriminatorColumn, "name" )
);
column.setLength(
JandexHelper.getValue( discriminatorColumn, "length", Integer.class, cls )
entityTypeMetadata.getLocalBindingContext()
.getJandexAccess()
.getTypedValueExtractor( Integer.class )
.extract( discriminatorColumn, "length" )
);
column.setColumnDefinition(
JandexHelper.getValue( discriminatorColumn, "columnDefinition", String.class, cls )
entityTypeMetadata.getLocalBindingContext()
.getJandexAccess()
.getTypedValueExtractor( String.class )
.extract( discriminatorColumn, "columnDefinition" )
);
this.relationalValueSource = new ColumnSourceImpl( column );

View File

@ -45,7 +45,6 @@ import org.hibernate.metamodel.source.internal.annotations.entity.EntityTypeMeta
import org.hibernate.metamodel.source.internal.annotations.entity.ManagedTypeMetadata;
import org.hibernate.metamodel.source.internal.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.source.internal.annotations.util.JPADotNames;
import org.hibernate.metamodel.source.internal.annotations.util.JandexHelper;
import org.hibernate.metamodel.source.spi.ConstraintSource;
import org.hibernate.metamodel.source.spi.EntitySource;
import org.hibernate.metamodel.source.spi.FilterSource;
@ -357,7 +356,9 @@ public abstract class EntitySourceImpl extends IdentifiableTypeSourceAdapter imp
JPADotNames.SECONDARY_TABLE
);
if ( secondaryTable != null ) {
String tableName = JandexHelper.getValue( secondaryTable, "name", String.class, classLoaderService );
String tableName = getLocalBindingContext().getJandexAccess()
.getTypedValueExtractor( String.class )
.extract( secondaryTable, "name" );
addUniqueConstraints( constraintSources, secondaryTable, tableName );
addIndexConstraints( constraintSources, secondaryTable, tableName );
@ -371,14 +372,13 @@ public abstract class EntitySourceImpl extends IdentifiableTypeSourceAdapter imp
JPADotNames.SECONDARY_TABLES
);
if ( secondaryTables != null ) {
final AnnotationInstance[] secondaryTableArray = JandexHelper.getValue(
secondaryTables,
"value",
AnnotationInstance[].class,
classLoaderService
);
final AnnotationInstance[] secondaryTableArray = getLocalBindingContext().getJandexAccess()
.getTypedValueExtractor( AnnotationInstance[].class )
.extract( secondaryTables, "value" );
for ( AnnotationInstance secondaryTable : secondaryTableArray ) {
String tableName = JandexHelper.getValue( secondaryTable, "name", String.class, classLoaderService );
String tableName = getLocalBindingContext().getJandexAccess()
.getTypedValueExtractor( String.class )
.extract( secondaryTable, "name" );
addUniqueConstraints( constraintSources, secondaryTable, tableName );
addIndexConstraints( constraintSources, secondaryTable, tableName );
}
@ -393,7 +393,9 @@ public abstract class EntitySourceImpl extends IdentifiableTypeSourceAdapter imp
if ( collectionTables != null ) {
for ( AnnotationInstance collectionTable : collectionTables ) {
String tableName = JandexHelper.getValue( collectionTable, "name", String.class, classLoaderService );
String tableName = getLocalBindingContext().getJandexAccess()
.getTypedValueExtractor( String.class )
.extract( collectionTable, "name" );
addUniqueConstraints( constraintSources, collectionTable, tableName );
addIndexConstraints( constraintSources, collectionTable, tableName );
}
@ -407,7 +409,9 @@ public abstract class EntitySourceImpl extends IdentifiableTypeSourceAdapter imp
);
if ( joinTables != null ) {
for (AnnotationInstance joinTable : joinTables) {
String tableName = JandexHelper.getValue( joinTable, "name", String.class, classLoaderService );
String tableName = getLocalBindingContext().getJandexAccess()
.getTypedValueExtractor( String.class )
.extract( joinTable, "name" );
addUniqueConstraints( constraintSources, joinTable, tableName );
addIndexConstraints( constraintSources, joinTable, tableName );
}
@ -421,7 +425,9 @@ public abstract class EntitySourceImpl extends IdentifiableTypeSourceAdapter imp
);
if ( tableGenerators != null ) {
for (AnnotationInstance tableGenerator : tableGenerators) {
String tableName = JandexHelper.getValue( tableGenerator, "table", String.class, classLoaderService );
String tableName = getLocalBindingContext().getJandexAccess()
.getTypedValueExtractor( String.class )
.extract( tableGenerator, "table" );
addUniqueConstraints( constraintSources, tableGenerator, tableName );
addIndexConstraints( constraintSources, tableGenerator, tableName );
}
@ -453,12 +459,9 @@ public abstract class EntitySourceImpl extends IdentifiableTypeSourceAdapter imp
JPADotNames.SECONDARY_TABLES
);
if ( secondaryTables != null ) {
AnnotationInstance[] tableAnnotations = JandexHelper.getValue(
secondaryTables,
"value",
AnnotationInstance[].class,
classLoaderService
);
AnnotationInstance[] tableAnnotations = getLocalBindingContext().getJandexAccess()
.getTypedValueExtractor( AnnotationInstance[].class )
.extract( secondaryTables, "value" );
for ( AnnotationInstance secondaryTable : tableAnnotations ) {
secondaryTableSources.add( createSecondaryTableSource( secondaryTable, true ) );
}
@ -556,12 +559,10 @@ public abstract class EntitySourceImpl extends IdentifiableTypeSourceAdapter imp
private List<? extends Column> collectSecondaryTableKeys(
final AnnotationInstance tableAnnotation,
final boolean isPrimaryKeyJoinColumn) {
final AnnotationInstance[] joinColumnAnnotations = JandexHelper.getValue(
tableAnnotation,
isPrimaryKeyJoinColumn ? "pkJoinColumns" : "joinColumns",
AnnotationInstance[].class,
classLoaderService
);
final AnnotationInstance[] joinColumnAnnotations = getLocalBindingContext()
.getJandexAccess()
.getTypedValueExtractor( AnnotationInstance[].class )
.extract( tableAnnotation, isPrimaryKeyJoinColumn ? "pkJoinColumns" : "joinColumns" );
if ( joinColumnAnnotations == null ) {
return Collections.emptyList();

View File

@ -0,0 +1,60 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.internal.annotations;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.IndexView;
/**
* @author Steve Ebersole
*/
public interface JandexAccess {
/**
* The annotation repository that this context know about.
*
* @return The {@link org.jboss.jandex.IndexView} that this context know about.
*/
IndexView getIndex();
/**
* Gets the class (or interface, or annotation) that was scanned during the
* indexing phase.
*
* @param className the name of the class
* @return information about the class or null if it is not known
*/
ClassInfo getClassInfo(String className);
/**
* Get a type-specific extractor for extracting attribute values from Jandex
* AnnotationInstances.
*
* @param type The type of extractor we want
* @param <T> The generic type of the extractor
*
* @return The typed extractor
*/
<T> TypedValueExtractor<T> getTypedValueExtractor(Class<T> type);
}

View File

@ -0,0 +1,598 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.internal.annotations;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.hibernate.metamodel.spi.ClassLoaderAccess;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Type;
/**
* @author Steve Ebersole
*/
public class JandexAccessImpl implements JandexAccess {
private final IndexView index;
private final ClassLoaderAccess classLoaderAccess;
public JandexAccessImpl(
IndexView index,
ClassLoaderAccess classLoaderAccess) {
this.index = index;
this.classLoaderAccess = classLoaderAccess;
}
@Override
public IndexView getIndex() {
return index;
}
@Override
public ClassInfo getClassInfo(String className) {
DotName dotName = DotName.createSimple( className );
return index.getClassByName( dotName );
}
@Override
@SuppressWarnings("unchecked")
public <T> TypedValueExtractor<T> getTypedValueExtractor(Class<T> type) {
if ( boolean.class.equals( type ) || Boolean.class.equals( type ) ) {
return (TypedValueExtractor<T>) booleanExtractor;
}
else if ( byte.class.equals( type ) || Byte.class.equals( type ) ) {
return (TypedValueExtractor<T>) byteExtractor;
}
else if ( char.class.equals( type ) || Character.class.equals( type ) ) {
return (TypedValueExtractor<T>) characterExtractor;
}
else if ( short.class.equals( type ) || Short.class.equals( type ) ) {
return (TypedValueExtractor<T>) shortExtractor;
}
else if ( int.class.equals( type ) || Integer.class.equals( type ) ) {
return (TypedValueExtractor<T>) integerExtractor;
}
else if ( long.class.equals( type ) || Long.class.equals( type ) ) {
return (TypedValueExtractor<T>) longExtractor;
}
else if ( float.class.equals( type ) || Float.class.equals( type ) ) {
return (TypedValueExtractor<T>) floatExtractor;
}
else if ( double.class.equals( type ) || Double.class.equals( type ) ) {
return (TypedValueExtractor<T>) doubleExtractor;
}
else if ( String.class.equals( type ) ) {
return (TypedValueExtractor<T>) stringExtractor;
}
else if ( String[].class.equals( type ) ) {
return (TypedValueExtractor<T>) stringArrayExtractor;
}
else if ( type.isEnum() ) {
return new EnumExtractor( type );
}
else if ( type.isArray() && type.getComponentType().isEnum() ) {
return new EnumArrayExtractor( type );
}
else if ( Type.class.equals( type ) ) {
return (TypedValueExtractor<T>) classTypeExtractor;
}
else if ( type.isArray() && Type.class.equals( type.getComponentType() ) ) {
return (TypedValueExtractor<T>) classTypeArrayExtractor;
}
else if ( AnnotationInstance.class.equals( type ) ) {
return (TypedValueExtractor<T>) nestedExtractor;
}
else if ( type.isArray() && AnnotationInstance.class.equals( type.getComponentType() ) ) {
return (TypedValueExtractor<T>) nestedArrayExtractor;
}
// checks for some specific unsupported types
if ( Class.class.equals( type ) || Class[].class.equals( type ) ) {
throw new IllegalArgumentException(
"Class and Class[] typed annotation attributes should be extracted" +
"by FQN or by org.jboss.jandex.Type"
);
}
throw new IllegalArgumentException(
"Unsupported extraction type [" + type.getName() + "] requested"
);
}
private abstract class AbstractTypedValueExtractor<T> implements TypedValueExtractor<T> {
@Override
public T extract(AnnotationInstance annotationInstance, String name) {
final AnnotationValue attributeInstance = annotationInstance.value( name );
if ( attributeInstance == null ) {
return interpretDefaultValue( getDefaultValue( annotationInstance, name ) );
}
else {
return extract( attributeInstance );
}
}
protected abstract T interpretDefaultValue(Object defaultValue);
protected abstract T extract(AnnotationValue attributeInstance);
@Override
public T extract(AnnotationInstance annotationInstance, String name, T defaultValue) {
final AnnotationValue attributeInstance = annotationInstance.value( name );
if ( attributeInstance == null ) {
return defaultValue;
}
else {
return extract( attributeInstance );
}
}
}
public final TypedValueExtractor<Boolean> booleanExtractor = new AbstractTypedValueExtractor<Boolean>() {
@Override
public Boolean extract(AnnotationValue value) {
return value.asBoolean();
}
@Override
public Boolean interpretDefaultValue(Object value) {
if ( boolean.class.isInstance( value ) || Boolean.class.isInstance( value ) ) {
return (Boolean) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Boolean" );
}
};
public final TypedValueExtractor<Byte> byteExtractor = new AbstractTypedValueExtractor<Byte>() {
@Override
public Byte extract(AnnotationValue value) {
return value.asByte();
}
@Override
public Byte interpretDefaultValue(Object value) {
if ( byte.class.isInstance( value ) || Byte.class.isInstance( value ) ) {
return (Byte) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Byte" );
}
};
public final TypedValueExtractor<Character> characterExtractor = new AbstractTypedValueExtractor<Character>() {
@Override
public Character extract(AnnotationValue value) {
return value.asChar();
}
@Override
public Character interpretDefaultValue(Object value) {
if ( char.class.isInstance( value ) || Character.class.isInstance( value ) ) {
return (Character) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Character" );
}
};
public final TypedValueExtractor<Short> shortExtractor = new AbstractTypedValueExtractor<Short>() {
@Override
public Short extract(AnnotationValue value) {
return value.asShort();
}
@Override
public Short interpretDefaultValue(Object value) {
if ( short.class.isInstance( value ) || Short.class.isInstance( value ) ) {
return (Short) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Short" );
}
};
public final TypedValueExtractor<Integer> integerExtractor = new AbstractTypedValueExtractor<Integer>() {
@Override
public Integer extract(AnnotationValue value) {
return value.asInt();
}
@Override
public Integer interpretDefaultValue(Object value) {
if ( int.class.isInstance( value ) || Integer.class.isInstance( value ) ) {
return (Integer) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Integer" );
}
};
public final TypedValueExtractor<Long> longExtractor = new AbstractTypedValueExtractor<Long>() {
@Override
public Long extract(AnnotationValue value) {
return value.asLong();
}
@Override
public Long interpretDefaultValue(Object value) {
if ( long.class.isInstance( value ) || Long.class.isInstance( value ) ) {
return (Long) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Long" );
}
};
public final TypedValueExtractor<Double> doubleExtractor = new AbstractTypedValueExtractor<Double>() {
@Override
public Double extract(AnnotationValue value) {
return value.asDouble();
}
@Override
public Double interpretDefaultValue(Object value) {
if ( double.class.isInstance( value ) || Double.class.isInstance( value ) ) {
return (Double) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Double" );
}
};
public final TypedValueExtractor<Float> floatExtractor = new AbstractTypedValueExtractor<Float>() {
@Override
public Float extract(AnnotationValue value) {
return value.asFloat();
}
@Override
public Float interpretDefaultValue(Object value) {
if ( float.class.isInstance( value ) || Float.class.isInstance( value ) ) {
return (Float) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Float" );
}
};
public final TypedValueExtractor<String> stringExtractor = new AbstractTypedValueExtractor<String>() {
@Override
public String extract(AnnotationValue value) {
return value.asString();
}
@Override
public String interpretDefaultValue(Object value) {
if ( value == null ) {
return null;
}
if ( String.class.isInstance( value ) ) {
return (String) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to String" );
}
};
public final TypedValueExtractor<String[]> stringArrayExtractor = new AbstractTypedValueExtractor<String[]>() {
@Override
public String[] extract(AnnotationValue value) {
return value.asStringArray();
}
@Override
public String[] interpretDefaultValue(Object value) {
if ( value == null ) {
return null;
}
if ( String[].class.isInstance( value ) ) {
return (String[]) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to String[]" );
}
};
public final TypedValueExtractor<String> enumNameExtractor = new AbstractTypedValueExtractor<String>() {
@Override
public String extract(AnnotationValue value) {
return value.asEnum();
}
@Override
public String interpretDefaultValue(Object value) {
if ( Enum.class.isInstance( value ) ) {
return ( (Enum) value ).name();
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Enum (to extract name)" );
}
};
public final TypedValueExtractor<String[]> enumNameArrayExtractor = new AbstractTypedValueExtractor<String[]>() {
@Override
public String[] extract(AnnotationValue value) {
return value.asEnumArray();
}
@Override
public String[] interpretDefaultValue(Object value) {
if ( Enum[].class.isInstance( value ) ) {
final Enum[] enums = (Enum[]) value;
final String[] names = new String[enums.length];
for ( int i = 0, length = enums.length; i < length; i++ ) {
names[i] = enums[i].name();
}
return names;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Enum[] (to extract names)" );
}
};
public final AbstractTypedValueExtractor<String> classNameExtractor = new AbstractTypedValueExtractor<String>() {
@Override
public String extract(AnnotationValue value) {
return ( (AbstractTypedValueExtractor<String>) stringExtractor ).extract( value );
}
@Override
public String interpretDefaultValue(Object value) {
if ( value == null ) {
return null;
}
if ( Class.class.isInstance( value ) ) {
return ( (Class) value ).getName();
}
else if ( String.class.isInstance( value ) ) {
return (String) value;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Class (to extract name)" );
}
};
public final TypedValueExtractor<String[]> classNameArrayExtractor = new AbstractTypedValueExtractor<String[]>() {
@Override
public String[] extract(AnnotationValue value) {
return value.asStringArray();
}
@Override
public String[] interpretDefaultValue(Object value) {
if ( Class[].class.isInstance( value ) ) {
final Class[] types = (Class[]) value;
final String[] names = new String[types.length];
for ( int i = 0, length = types.length; i < length; i++ ) {
names[i] = types[i].getName();
}
return names;
}
throw new IllegalArgumentException( "Cannot convert given value [" + value + "] to Class[] (to extract names)" );
}
};
public final TypedValueExtractor<Type> classTypeExtractor = new AbstractTypedValueExtractor<Type>() {
@Override
public Type extract(AnnotationValue value) {
return value.asClass();
}
@Override
public Type interpretDefaultValue(Object value) {
// What is the relationship between Type and ClassInfo? is there one?
// How does one get a Type reference from the index?
return null;
}
};
public final TypedValueExtractor<Type[]> classTypeArrayExtractor = new AbstractTypedValueExtractor<Type[]>() {
@Override
public Type[] extract(AnnotationValue value) {
return value.asClassArray();
}
@Override
public Type[] interpretDefaultValue(Object value) {
throw new IllegalStateException(
"Cannot interpret default Class values as Jandex Types atm, " +
"as this class does not have access to the Jandex Index"
);
}
};
public final TypedValueExtractor<AnnotationInstance> nestedExtractor = new AbstractTypedValueExtractor<AnnotationInstance>() {
@Override
public AnnotationInstance extract(AnnotationValue value) {
return value.asNested();
}
@Override
public AnnotationInstance interpretDefaultValue(Object value) {
return null;
}
};
public final TypedValueExtractor<AnnotationInstance[]> nestedArrayExtractor = new AbstractTypedValueExtractor<AnnotationInstance[]>() {
@Override
public AnnotationInstance[] extract(AnnotationValue value) {
return value.asNestedArray();
}
@Override
public AnnotationInstance[] interpretDefaultValue(Object value) {
return new AnnotationInstance[0];
}
};
private class EnumExtractor<T extends Enum<T>> extends AbstractTypedValueExtractor<T> {
private final Class<T> enumType;
private EnumExtractor(Class<T> enumType) {
this.enumType = enumType;
}
@Override
@SuppressWarnings("unchecked")
protected T interpretDefaultValue(Object defaultValue) {
// defaultValue should be an enum already..
if ( enumType.isInstance( defaultValue ) ) {
return (T) defaultValue;
}
else if ( defaultValue instanceof String ) {
return (T) Enum.valueOf( enumType, (String) defaultValue );
}
throw new IllegalArgumentException(
"Do not know how to convert given value [" + defaultValue +
"] to specified enum [" + enumType.getName() + "]"
);
}
@Override
protected T extract(AnnotationValue attributeInstance) {
return Enum.valueOf(
enumType,
( (AbstractTypedValueExtractor<String>) enumNameExtractor ).extract( attributeInstance )
);
}
}
private class EnumArrayExtractor<T extends Enum<T>> extends AbstractTypedValueExtractor<T[]> {
private final Class<T> enumType;
private EnumArrayExtractor(Class<T> enumType) {
this.enumType = enumType;
}
@Override
@SuppressWarnings("unchecked")
protected T[] interpretDefaultValue(Object defaultValue) {
// defaultValue should be an enum array already..
if ( defaultValue == null ) {
return (T[]) Array.newInstance( enumType, 0 );
}
else if ( defaultValue.getClass().isArray()
&& defaultValue.getClass().getComponentType().equals( enumType ) ) {
return (T[]) defaultValue;
}
else if ( defaultValue.getClass().isArray()
&& defaultValue.getClass().getComponentType().equals( String.class ) ) {
final String[] strings = (String[]) defaultValue;
final T[] result = (T[]) Array.newInstance( enumType, strings.length );
for ( int i = 0; i < strings.length; i++ ) {
result[i] = Enum.valueOf( enumType, strings[i] );
}
return result;
}
throw new IllegalArgumentException(
"Do not know how to convert given value [" + defaultValue +
"] to specified enum array [" + enumType.getName() + "]"
);
}
@Override
@SuppressWarnings("unchecked")
protected T[] extract(AnnotationValue attributeInstance) {
final String[] enumValues = ( (AbstractTypedValueExtractor<String[]>) enumNameArrayExtractor ).extract( attributeInstance );
final T[] result = (T[]) Array.newInstance( enumType, enumValues.length );
for ( int i = 0; i < enumValues.length; i++ ) {
result[i] = Enum.valueOf( enumType, enumValues[i] );
}
return result;
}
}
private static final Map<DotName, Map<String,Object>> DEFAULT_VALUES_MAP = new HashMap<DotName, Map<String,Object>>();
private Object getDefaultValue(AnnotationInstance annotation, String attributeName) {
final String annotationFqn = annotation.name().toString();
Map<String,Object> annotationValueMap = DEFAULT_VALUES_MAP.get( annotation.name() );
if ( annotationValueMap == null ) {
// we have not processed this annotation yet
final Class annotationClass = classLoaderAccess.classForName( annotationFqn );
annotationValueMap = parseAttributeDefaults( annotationClass );
DEFAULT_VALUES_MAP.put( annotation.name(), annotationValueMap );
}
final Object value = annotationValueMap.get( attributeName );
if ( value == null ) {
if ( !annotationValueMap.containsKey( attributeName ) ) {
throw new IllegalArgumentException(
String.format(
"Annotation [%s] does not define an attribute named '%s'",
annotationFqn,
attributeName
)
);
}
}
return value;
}
private Map<String, Object> parseAttributeDefaults(Class annotationClass) {
final Map<String,Object> results = new HashMap<String, Object>();
final Method[] methods = annotationClass.getDeclaredMethods();
if ( methods != null ) {
for ( Method method : methods ) {
Object defaultValue = method.getDefaultValue();
if ( defaultValue != null ) {
if ( defaultValue instanceof String ) {
if ( "".equals( defaultValue ) ) {
defaultValue = null;
}
}
else if ( defaultValue instanceof Class ) {
final Class clazz = (Class) defaultValue;
if ( void.class.equals( clazz ) ) {
defaultValue = null;
}
else {
// use its FQN (ideally we'd use the jandex Type)
defaultValue = ( (Class) defaultValue ).getName();
}
}
else if ( defaultValue instanceof Class[] ) {
// use its FQN (ideally we'd use the jandex Type)
final Class[] types = (Class[]) defaultValue;
final String[] fqns = new String[ types.length ];
for ( int i = 0; i < types.length; i++ ) {
fqns[i] = types[i].getName();
}
defaultValue = fqns;
}
else if ( defaultValue.getClass().isAnnotation() ) {
// I can't think of a single instance where the
// default for a nested annotation attribute is
// anything other than an empty annotation instance
defaultValue = null;
}
else if ( defaultValue.getClass().isArray()
&& defaultValue.getClass().getComponentType().isAnnotation() ) {
defaultValue = null;
}
}
results.put( method.getName(), defaultValue );
}
}
return results;
}
}

View File

@ -0,0 +1,64 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.internal.annotations;
import org.jboss.jandex.AnnotationInstance;
/**
* A contract for extracting values from Jandex representation of an
* annotation.
*
* @author Steve Ebersole
*/
public interface TypedValueExtractor<T> {
/**
* Extracts the value by type from the given annotation attribute value
* representation. The attribute value may be {@code null} (which
* represents an unspecified attribute), in which case we need reference
* to the {@link org.hibernate.boot.registry.classloading.spi.ClassLoaderService}
* to be able to resolve the default value for the given attribute.
*
* @param annotationInstance The representation of the annotation usage
* from which to extract an attribute value.
* @param name The name of the attribute to extract
*
* @return The extracted value.
*/
public T extract(AnnotationInstance annotationInstance, String name);
/**
* Just like {@link #extract(org.jboss.jandex.AnnotationInstance,String)}
* except that here we return the passed defaultValue if the annotation
* attribute value is {@code null}.
*
* @param annotationInstance The representation of the annotation usage
* from which to extract an attribute value.
* @param name The name of the attribute to extract
* @param defaultValue The typed value to use if the annotation
* attribute value is {@code null}
*
* @return The extracted value.
*/
public T extract(AnnotationInstance annotationInstance, String name, T defaultValue);
}

View File

@ -25,6 +25,7 @@ package org.hibernate.metamodel.source.internal.annotations.entity;
import org.hibernate.AnnotationException;
import org.hibernate.metamodel.source.internal.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.source.internal.annotations.TypedValueExtractor;
import org.hibernate.metamodel.source.spi.MappingException;
import org.hibernate.metamodel.spi.BaseDelegatingBindingContext;
import org.hibernate.metamodel.spi.LocalBindingContext;
@ -35,8 +36,6 @@ import org.hibernate.xml.spi.SourceType;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.IndexView;
import com.fasterxml.classmate.MemberResolver;
import com.fasterxml.classmate.TypeResolver;
/**
* Annotation version of a local binding context.
@ -74,26 +73,6 @@ public class EntityBindingContext
return new AnnotationException( message, cause, getOrigin() );
}
@Override
public IndexView getIndex() {
return contextDelegate.getIndex();
}
@Override
public ClassInfo getClassInfo(String name) {
return contextDelegate.getClassInfo( name );
}
@Override
public MemberResolver getMemberResolver() {
return contextDelegate.getMemberResolver();
}
@Override
public TypeResolver getTypeResolver() {
return contextDelegate.getTypeResolver();
}
@Override
public IdentifierGeneratorDefinition findIdGenerator(String name) {
return contextDelegate.findIdGenerator( name );

View File

@ -236,7 +236,7 @@ public class IdentifiableTypeMetadata extends ManagedTypeMetadata {
// EntityListeners "annotation" defined as default in orm.xml
final Collection<AnnotationInstance> defaultEntityListenersAnnotations =
getLocalBindingContext().getIndex().getAnnotations( PseudoJpaDotNames.DEFAULT_ENTITY_LISTENERS );
getLocalBindingContext().getJandexAccess().getIndex().getAnnotations( PseudoJpaDotNames.DEFAULT_ENTITY_LISTENERS );
// there really should be only one or none...
if ( defaultEntityListenersAnnotations != null ) {
if ( defaultEntityListenersAnnotations.size() > 1 ) {

View File

@ -356,7 +356,10 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect
AnnotationBindingContext bindingContext) {
// ask Jandex for all the known *direct* subclasses of `superType`
// and iterate them to create the subclass metadata
final Collection<ClassInfo> classInfos = bindingContext.getIndex().getKnownDirectSubclasses( javaTypeDescriptor.getName() );
final Collection<ClassInfo> classInfos = bindingContext.getJandexAccess()
.getIndex()
.getKnownDirectSubclasses( javaTypeDescriptor.getName() );
for ( ClassInfo classInfo : classInfos ) {
final ClassDescriptor subclassTypeDescriptor = (ClassDescriptor) bindingContext.getJavaTypeDescriptorRepository().getType( classInfo.name() );

View File

@ -57,13 +57,14 @@ public class FetchProfileProcessor {
// TODO verify that association exists. See former VerifyFetchProfileReferenceSecondPass
public static void bind(AnnotationBindingContext bindingContext) {
Collection<AnnotationInstance> annotations = bindingContext.getIndex()
Collection<AnnotationInstance> annotations = bindingContext.getJandexAccess()
.getIndex()
.getAnnotations( HibernateDotNames.FETCH_PROFILE );
for ( AnnotationInstance fetchProfile : annotations ) {
bind( bindingContext, fetchProfile );
}
annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.FETCH_PROFILES );
annotations = bindingContext.getJandexAccess().getIndex().getAnnotations( HibernateDotNames.FETCH_PROFILES );
for ( AnnotationInstance fetchProfiles : annotations ) {
AnnotationInstance[] fetchProfileAnnotations = JandexHelper.getValue(
fetchProfiles,

View File

@ -77,19 +77,20 @@ public class IdGeneratorProcessor {
*/
public static Iterable<IdentifierGeneratorSource> extractGlobalIdentifierGeneratorSources(AnnotationBindingContext bindingContext) {
List<IdentifierGeneratorSource> identifierGeneratorSources = new ArrayList<IdentifierGeneratorSource>();
Collection<AnnotationInstance> annotations = bindingContext.getIndex()
Collection<AnnotationInstance> annotations = bindingContext.getJandexAccess()
.getIndex()
.getAnnotations( JPADotNames.SEQUENCE_GENERATOR );
for ( AnnotationInstance generator : annotations ) {
bindSequenceGenerator( generator, identifierGeneratorSources, bindingContext );
}
annotations = bindingContext.getIndex().getAnnotations( JPADotNames.TABLE_GENERATOR );
annotations = bindingContext.getJandexAccess().getIndex().getAnnotations( JPADotNames.TABLE_GENERATOR );
for ( AnnotationInstance generator : annotations ) {
bindTableGenerator( generator, identifierGeneratorSources, bindingContext );
}
annotations = JandexHelper.getAnnotations(
bindingContext.getIndex(),
bindingContext.getJandexAccess().getIndex(),
HibernateDotNames.GENERIC_GENERATOR,
HibernateDotNames.GENERIC_GENERATORS,
bindingContext.getServiceRegistry().getService( ClassLoaderService.class )

View File

@ -99,7 +99,7 @@ public class QueryProcessor {
*/
public static void bind(AnnotationBindingContext bindingContext) {
Collection<AnnotationInstance> annotations = JandexHelper.collectionAnnotations(
bindingContext.getIndex(),
bindingContext.getJandexAccess().getIndex(),
JPADotNames.NAMED_QUERY,
JPADotNames.NAMED_QUERIES
);
@ -108,7 +108,7 @@ public class QueryProcessor {
}
annotations = JandexHelper.collectionAnnotations(
bindingContext.getIndex(),
bindingContext.getJandexAccess().getIndex(),
JPADotNames.NAMED_NATIVE_QUERY,
JPADotNames.NAMED_NATIVE_QUERIES
);
@ -117,7 +117,7 @@ public class QueryProcessor {
}
annotations = JandexHelper.collectionAnnotations(
bindingContext.getIndex(),
bindingContext.getJandexAccess().getIndex(),
JPADotNames.NAMED_STORED_PROCEDURE_QUERY,
JPADotNames.NAMED_STORED_PROCEDURE_QUERIES
);
@ -126,7 +126,7 @@ public class QueryProcessor {
}
annotations = JandexHelper.collectionAnnotations(
bindingContext.getIndex(),
bindingContext.getJandexAccess().getIndex(),
HibernateDotNames.NAMED_QUERY,
HibernateDotNames.NAMED_QUERIES
);
@ -135,7 +135,7 @@ public class QueryProcessor {
}
annotations = JandexHelper.collectionAnnotations(
bindingContext.getIndex(),
bindingContext.getJandexAccess().getIndex(),
HibernateDotNames.NAMED_NATIVE_QUERY,
HibernateDotNames.NAMED_NATIVE_QUERIES
);

View File

@ -96,7 +96,7 @@ public class SqlResultSetProcessor {
// singular form
{
final Collection<AnnotationInstance> sqlResultSetMappingAnnotations =
bindingContext.getIndex().getAnnotations( SQL_RESULT_SET_MAPPING );
bindingContext.getJandexAccess().getIndex().getAnnotations( SQL_RESULT_SET_MAPPING );
for ( final AnnotationInstance sqlResultSetMappingAnnotation : sqlResultSetMappingAnnotations ) {
bindSqlResultSetMapping( sqlResultSetMappingAnnotation, bindingContext );
}
@ -105,7 +105,7 @@ public class SqlResultSetProcessor {
// plural form
{
final Collection<AnnotationInstance> sqlResultSetMappingsAnnotations =
bindingContext.getIndex().getAnnotations( SQL_RESULT_SET_MAPPINGS );
bindingContext.getJandexAccess().getIndex().getAnnotations( SQL_RESULT_SET_MAPPINGS );
for ( final AnnotationInstance sqlResultSetMappingsAnnotationInstance : sqlResultSetMappingsAnnotations ) {
final AnnotationInstance[] sqlResultSetMappingAnnotations = JandexHelper.extractAnnotationsValue(
sqlResultSetMappingsAnnotationInstance,

View File

@ -59,12 +59,12 @@ public class TableProcessor {
* @param bindingContext the context for annotation binding
*/
public static void bind(AnnotationBindingContext bindingContext) {
Collection<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TABLE );
Collection<AnnotationInstance> annotations = bindingContext.getJandexAccess().getIndex().getAnnotations( HibernateDotNames.TABLE );
for ( AnnotationInstance tableAnnotation : annotations ) {
bind( bindingContext, tableAnnotation );
}
annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TABLES );
annotations = bindingContext.getJandexAccess().getIndex().getAnnotations( HibernateDotNames.TABLES );
for ( AnnotationInstance tables : annotations ) {
for ( AnnotationInstance table : JandexHelper.getValue( tables, "value", AnnotationInstance[].class,
bindingContext.getServiceRegistry().getService( ClassLoaderService.class ) ) ) {

View File

@ -136,7 +136,7 @@ public class EntityHierarchyBuilder {
final Set<JavaTypeDescriptor> collectedDescriptors = new HashSet<JavaTypeDescriptor>();
final JavaTypeDescriptorRepository repo = bindingContext.getJavaTypeDescriptorRepository();
for ( ClassInfo classInfo : bindingContext.getIndex().getKnownClasses() ) {
for ( ClassInfo classInfo : bindingContext.getJandexAccess().getIndex().getKnownClasses() ) {
final JavaTypeDescriptor descriptor = repo.getType( repo.buildName( classInfo.name().toString() ) );
if ( descriptor == null ) {
continue;

View File

@ -44,6 +44,7 @@ import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.internal.util.type.PrimitiveWrapperHelper;
import org.hibernate.metamodel.source.internal.annotations.TypedValueExtractor;
import org.hibernate.metamodel.spi.BindingContext;
import org.hibernate.service.ServiceRegistry;
@ -69,10 +70,29 @@ public class JandexHelper {
public static final DotName OBJECT = DotName.createSimple( Object.class.getName() );
// todo : consider making JandexHelper non-static (looked up from context) and caching the ClassLoaderService as instance state
// todo : consider making JandexHelper non-static, resolved from the AnnotationBindingContext
// private final ClassLoaderService classLoaderService;
//
// private JandexHelper(BindingContext context) {
// this.classLoaderService = context.getServiceRegistry().getService( ClassLoaderService.class );
// }
private JandexHelper() {
}
/**
* Retrieves a jandex annotation element value. If the value is {@code null}, the default value specified in the
@ -598,6 +618,8 @@ public class JandexHelper {
}
private static Object getDefaultValue(AnnotationInstance annotation, String element, ClassLoaderService classLoaderService) {
//todo : would it be better to lookup each annotation class once and store this info in a Map primarily by the class?
String name = annotation.name().toString();
String fqElement = name + '.' + element;
Object val = DEFAULT_VALUES_BY_ELEMENT.get( fqElement );

View File

@ -621,8 +621,7 @@ public class EntityHierarchySourceImpl implements EntityHierarchySource {
}
// todo : do we really want to be loading this?
return rootEntitySource.bindingContext().locateClassByName(
rootEntitySource.bindingContext().qualifyClassName( compositeId.getClazz() )
return rootEntitySource.bindingContext().getClassLoaderAccess().classForName( rootEntitySource.bindingContext().qualifyClassName( compositeId.getClazz() )
);
}

View File

@ -25,9 +25,9 @@ package org.hibernate.metamodel.spi;
import org.hibernate.metamodel.reflite.spi.JavaTypeDescriptor;
import org.hibernate.metamodel.reflite.spi.JavaTypeDescriptorRepository;
import org.hibernate.metamodel.source.internal.annotations.JandexAccess;
import org.hibernate.metamodel.source.spi.MappingDefaults;
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
import org.hibernate.metamodel.spi.domain.JavaClassReference;
import org.hibernate.metamodel.spi.domain.Type;
import org.hibernate.service.ServiceRegistry;
@ -52,11 +52,21 @@ public abstract class BaseDelegatingBindingContext implements BindingContext {
return parent.getBuildingOptions();
}
@Override
public JandexAccess getJandexAccess() {
return parent.getJandexAccess();
}
@Override
public JavaTypeDescriptorRepository getJavaTypeDescriptorRepository() {
return parent.getJavaTypeDescriptorRepository();
}
@Override
public ClassLoaderAccess getClassLoaderAccess() {
return parent.getClassLoaderAccess();
}
@Override
public MappingDefaults getMappingDefaults() {
return parent.getMappingDefaults();
@ -87,11 +97,6 @@ public abstract class BaseDelegatingBindingContext implements BindingContext {
return parent.quoteIdentifiersInContext();
}
@Override
public <T> Class<T> locateClassByName(String name) {
return parent.locateClassByName( name );
}
@Override
public Type makeDomainType(String className) {
return parent.makeDomainType( className );
@ -106,20 +111,4 @@ public abstract class BaseDelegatingBindingContext implements BindingContext {
public Type makeDomainType(DotName typeName) {
return parent.makeDomainType( typeName );
}
@Override
public JavaClassReference makeJavaClassReference(String className) {
return parent.makeJavaClassReference( className );
}
@Override
public JavaClassReference makeJavaClassReference(Class<?> clazz) {
return parent.makeJavaClassReference( clazz );
}
@Override
public JavaClassReference makeJavaPropertyClassReference(
JavaClassReference propertyContainerClassReference, String propertyName) {
return parent.makeJavaPropertyClassReference( propertyContainerClassReference, propertyName );
}
}

View File

@ -23,8 +23,10 @@
*/
package org.hibernate.metamodel.spi;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.metamodel.reflite.spi.JavaTypeDescriptor;
import org.hibernate.metamodel.reflite.spi.JavaTypeDescriptorRepository;
import org.hibernate.metamodel.source.internal.annotations.JandexAccess;
import org.hibernate.metamodel.source.spi.MappingDefaults;
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
import org.hibernate.metamodel.spi.domain.JavaClassReference;
@ -50,6 +52,8 @@ public interface BindingContext {
*/
public MetadataBuildingOptions getBuildingOptions();
public JandexAccess getJandexAccess();
/**
* Access to the "reflite" type repository
*
@ -78,6 +82,13 @@ public interface BindingContext {
*/
public ServiceRegistry getServiceRegistry();
/**
* Provides access to ClassLoader services when needed during binding
*
* @return The ClassLoaderAccess
*/
public ClassLoaderAccess getClassLoaderAccess();
public MetaAttributeContext getGlobalMetaAttributeContext();
/**
@ -95,12 +106,6 @@ public interface BindingContext {
// todo : go away
/**
* @deprecated use the JavaTypeDescriptorRepository instead, available from {@link #getJavaTypeDescriptorRepository}
*/
@Deprecated
public <T> Class<T> locateClassByName(String name);
/**
* todo : maybe a `Type makeDomainType(JavaTypeDescriptor)` method instead?
*
@ -111,24 +116,4 @@ public interface BindingContext {
public Type makeDomainType(DotName typeName);
/**
* @deprecated use the JavaTypeDescriptorRepository instead, available from {@link #getJavaTypeDescriptorRepository}
*/
@Deprecated
public JavaClassReference makeJavaClassReference(String className);
/**
* @deprecated use the JavaTypeDescriptorRepository instead, available from {@link #getJavaTypeDescriptorRepository}
*/
@Deprecated
public JavaClassReference makeJavaClassReference(Class<?> clazz);
/**
* @deprecated use the JavaTypeDescriptorRepository instead, available from {@link #getJavaTypeDescriptorRepository}
*/
@Deprecated
public JavaClassReference makeJavaPropertyClassReference(
JavaClassReference propertyContainerClassReference,
String propertyName
);
}

View File

@ -0,0 +1,42 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi;
/**
* During the process of building this metamodel, accessing the ClassLoader
* is very discouraged. However, sometimes it is needed. This contract helps
* mitigate accessing the ClassLoader in these cases.
*
* @author Steve Ebersole
*/
public interface ClassLoaderAccess {
/**
* Obtain a Class reference by name
*
* @param name The name of the Class to get a reference to.
*
* @return The Class.
*/
public <T> Class<T> classForName(String name);
}

View File

@ -24,11 +24,14 @@
package org.hibernate.metamodel.internal.source;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.metamodel.internal.ClassLoaderAccessImpl;
import org.hibernate.metamodel.internal.MetadataBuilderImpl;
import org.hibernate.metamodel.internal.MetadataBuildingProcess;
import org.hibernate.metamodel.reflite.internal.JavaTypeDescriptorRepositoryImpl;
import org.hibernate.metamodel.reflite.spi.JavaTypeDescriptorRepository;
import org.hibernate.metamodel.source.internal.annotations.JandexAccessImpl;
import org.hibernate.metamodel.spi.BindingContext;
import org.hibernate.metamodel.spi.ClassLoaderAccess;
import org.hibernate.type.BasicTypeRegistry;
import org.hibernate.type.TypeFactory;
import org.hibernate.type.TypeResolver;
@ -50,10 +53,14 @@ public class RootBindingContextBuilder {
final MetadataBuildingProcess.MappingDefaultsImpl mappingDefaults = new MetadataBuildingProcess.MappingDefaultsImpl(
options
);
final JavaTypeDescriptorRepository javaTypeDescriptorRepository = new JavaTypeDescriptorRepositoryImpl(
final ClassLoaderAccess classLoaderAccess = new ClassLoaderAccessImpl( null, serviceRegistry );
final JandexAccessImpl jandexAccess = new JandexAccessImpl(
index,
null,
serviceRegistry
classLoaderAccess
);
final JavaTypeDescriptorRepository javaTypeDescriptorRepository = new JavaTypeDescriptorRepositoryImpl(
jandexAccess,
classLoaderAccess
);
final MetadataBuildingProcess.InFlightMetadataCollectorImpl metadataCollector = new MetadataBuildingProcess.InFlightMetadataCollectorImpl(
options,
@ -63,6 +70,8 @@ public class RootBindingContextBuilder {
options,
mappingDefaults,
javaTypeDescriptorRepository,
jandexAccess,
classLoaderAccess,
metadataCollector
);
}

View File

@ -62,8 +62,7 @@ public abstract class BaseAnnotationIndexTestCase extends BaseUnitTestCase {
clazz
);
AnnotationBindingContext context = new AnnotationBindingContextImpl(
RootBindingContextBuilder.buildBindingContext( serviceRegistry, index ),
index
RootBindingContextBuilder.buildBindingContext( serviceRegistry, index )
);
return EntityHierarchyBuilder.createEntityHierarchies( context );
}

View File

@ -31,9 +31,11 @@ import java.util.List;
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.metamodel.internal.ClassLoaderAccessImpl;
import org.hibernate.metamodel.reflite.internal.JavaTypeDescriptorRepositoryImpl;
import org.hibernate.metamodel.reflite.spi.JavaTypeDescriptor;
import org.hibernate.metamodel.reflite.spi.JavaTypeDescriptorRepository;
import org.hibernate.metamodel.source.internal.annotations.JandexAccessImpl;
import org.hibernate.metamodel.spi.domain.Entity;
import org.hibernate.metamodel.spi.domain.SingularAttribute;
import org.hibernate.metamodel.spi.relational.Column;
@ -108,10 +110,10 @@ public class SimpleValueBindingTests extends BaseUnitTestCase {
);
}
private final ClassLoaderAccessImpl classLoaderAccess = new ClassLoaderAccessImpl( null, classLoaderService );
private final JavaTypeDescriptorRepository javaTypeDescriptorRepository = new JavaTypeDescriptorRepositoryImpl(
null,
null,
classLoaderService
new JandexAccessImpl( null, classLoaderAccess ),
classLoaderAccess
);
JavaTypeDescriptor makeJavaType(final String name) {