HHH-6733 Avoid frequent usage of ReflectHelper in PojoInstantiator
This commit is contained in:
parent
0f1d6c189b
commit
e93a83f5c2
|
@ -51,9 +51,11 @@ public class PojoInstantiator implements Instantiator, Serializable {
|
||||||
private final transient ReflectionOptimizer.InstantiationOptimizer optimizer;
|
private final transient ReflectionOptimizer.InstantiationOptimizer optimizer;
|
||||||
private final boolean embeddedIdentifier;
|
private final boolean embeddedIdentifier;
|
||||||
private final Class proxyInterface;
|
private final Class proxyInterface;
|
||||||
|
private final boolean isAbstract;
|
||||||
|
|
||||||
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
|
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
|
||||||
this.mappedClass = component.getComponentClass();
|
this.mappedClass = component.getComponentClass();
|
||||||
|
this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
|
||||||
this.optimizer = optimizer;
|
this.optimizer = optimizer;
|
||||||
|
|
||||||
this.proxyInterface = null;
|
this.proxyInterface = null;
|
||||||
|
@ -63,13 +65,14 @@ public class PojoInstantiator implements Instantiator, Serializable {
|
||||||
constructor = ReflectHelper.getDefaultConstructor(mappedClass);
|
constructor = ReflectHelper.getDefaultConstructor(mappedClass);
|
||||||
}
|
}
|
||||||
catch ( PropertyNotFoundException pnfe ) {
|
catch ( PropertyNotFoundException pnfe ) {
|
||||||
LOG.noDefaultConstructor(mappedClass.getName());
|
LOG.noDefaultConstructor(mappedClass.getName());
|
||||||
constructor = null;
|
constructor = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PojoInstantiator(PersistentClass persistentClass, ReflectionOptimizer.InstantiationOptimizer optimizer) {
|
public PojoInstantiator(PersistentClass persistentClass, ReflectionOptimizer.InstantiationOptimizer optimizer) {
|
||||||
this.mappedClass = persistentClass.getMappedClass();
|
this.mappedClass = persistentClass.getMappedClass();
|
||||||
|
this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
|
||||||
this.proxyInterface = persistentClass.getProxyInterface();
|
this.proxyInterface = persistentClass.getProxyInterface();
|
||||||
this.embeddedIdentifier = persistentClass.hasEmbeddedIdentifier();
|
this.embeddedIdentifier = persistentClass.hasEmbeddedIdentifier();
|
||||||
this.optimizer = optimizer;
|
this.optimizer = optimizer;
|
||||||
|
@ -78,13 +81,14 @@ public class PojoInstantiator implements Instantiator, Serializable {
|
||||||
constructor = ReflectHelper.getDefaultConstructor( mappedClass );
|
constructor = ReflectHelper.getDefaultConstructor( mappedClass );
|
||||||
}
|
}
|
||||||
catch ( PropertyNotFoundException pnfe ) {
|
catch ( PropertyNotFoundException pnfe ) {
|
||||||
LOG.noDefaultConstructor(mappedClass.getName());
|
LOG.noDefaultConstructor(mappedClass.getName());
|
||||||
constructor = null;
|
constructor = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PojoInstantiator(EntityBinding entityBinding, ReflectionOptimizer.InstantiationOptimizer optimizer) {
|
public PojoInstantiator(EntityBinding entityBinding, ReflectionOptimizer.InstantiationOptimizer optimizer) {
|
||||||
this.mappedClass = entityBinding.getEntity().getClassReference();
|
this.mappedClass = entityBinding.getEntity().getClassReference();
|
||||||
|
this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
|
||||||
this.proxyInterface = entityBinding.getProxyInterfaceType().getValue();
|
this.proxyInterface = entityBinding.getProxyInterfaceType().getValue();
|
||||||
this.embeddedIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded();
|
this.embeddedIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded();
|
||||||
this.optimizer = optimizer;
|
this.optimizer = optimizer;
|
||||||
|
@ -105,7 +109,7 @@ public class PojoInstantiator implements Instantiator, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object instantiate() {
|
public Object instantiate() {
|
||||||
if ( ReflectHelper.isAbstractClass(mappedClass) ) {
|
if ( isAbstract ) {
|
||||||
throw new InstantiationException( "Cannot instantiate abstract class or interface: ", mappedClass );
|
throw new InstantiationException( "Cannot instantiate abstract class or interface: ", mappedClass );
|
||||||
}
|
}
|
||||||
else if ( optimizer != null ) {
|
else if ( optimizer != null ) {
|
||||||
|
|
Loading…
Reference in New Issue