HHH-12482 Avoid logging overhead within CallbackBuilderLegacyImpl loops
This commit is contained in:
parent
cf75861c0e
commit
e316649fd6
|
@ -53,6 +53,7 @@ public class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildCallbacksForEntity(String entityClassName, CallbackRegistrar callbackRegistrar) {
|
public void buildCallbacksForEntity(String entityClassName, CallbackRegistrar callbackRegistrar) {
|
||||||
|
final boolean debugEnabled = log.isDebugEnabled();
|
||||||
try {
|
try {
|
||||||
final XClass entityXClass = reflectionManager.classForName( entityClassName );
|
final XClass entityXClass = reflectionManager.classForName( entityClassName );
|
||||||
final Class entityClass = reflectionManager.toClass( entityXClass );
|
final Class entityClass = reflectionManager.toClass( entityXClass );
|
||||||
|
@ -60,6 +61,7 @@ public class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
if ( callbackRegistrar.hasRegisteredCallbacks( entityClass, callbackType ) ) {
|
if ( callbackRegistrar.hasRegisteredCallbacks( entityClass, callbackType ) ) {
|
||||||
// this most likely means we have a class mapped multiple times using the hbm.xml
|
// this most likely means we have a class mapped multiple times using the hbm.xml
|
||||||
// "entity name" feature
|
// "entity name" feature
|
||||||
|
if ( debugEnabled ) {
|
||||||
log.debugf(
|
log.debugf(
|
||||||
"CallbackRegistry reported that Class [%s] already had %s callbacks registered; " +
|
"CallbackRegistry reported that Class [%s] already had %s callbacks registered; " +
|
||||||
"assuming this means the class was mapped twice " +
|
"assuming this means the class was mapped twice " +
|
||||||
|
@ -67,6 +69,7 @@ public class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
entityClassName,
|
entityClassName,
|
||||||
callbackType.getCallbackAnnotation().getSimpleName()
|
callbackType.getCallbackAnnotation().getSimpleName()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Callback[] callbacks = resolveEntityCallbacks( entityXClass, callbackType, reflectionManager );
|
final Callback[] callbacks = resolveEntityCallbacks( entityXClass, callbackType, reflectionManager );
|
||||||
|
@ -113,6 +116,7 @@ public class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
XClass currentClazz = beanClass;
|
XClass currentClazz = beanClass;
|
||||||
boolean stopListeners = false;
|
boolean stopListeners = false;
|
||||||
boolean stopDefaultListeners = false;
|
boolean stopDefaultListeners = false;
|
||||||
|
final boolean debugEnabled = log.isDebugEnabled();
|
||||||
do {
|
do {
|
||||||
Callback callback = null;
|
Callback callback = null;
|
||||||
List<XMethod> methods = currentClazz.getDeclaredMethods();
|
List<XMethod> methods = currentClazz.getDeclaredMethods();
|
||||||
|
@ -133,12 +137,14 @@ public class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ReflectHelper.ensureAccessibility( method );
|
ReflectHelper.ensureAccessibility( method );
|
||||||
|
if ( debugEnabled ) {
|
||||||
log.debugf(
|
log.debugf(
|
||||||
"Adding %s as %s callback for entity %s",
|
"Adding %s as %s callback for entity %s",
|
||||||
methodName,
|
methodName,
|
||||||
callbackType.getCallbackAnnotation().getSimpleName(),
|
callbackType.getCallbackAnnotation().getSimpleName(),
|
||||||
beanClass.getName()
|
beanClass.getName()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
callbacks.add( 0, callback ); //superclass first
|
callbacks.add( 0, callback ); //superclass first
|
||||||
callbacksMethodNames.add( 0, methodName );
|
callbacksMethodNames.add( 0, methodName );
|
||||||
}
|
}
|
||||||
|
@ -207,12 +213,14 @@ public class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ReflectHelper.ensureAccessibility( method );
|
ReflectHelper.ensureAccessibility( method );
|
||||||
|
if ( debugEnabled ) {
|
||||||
log.debugf(
|
log.debugf(
|
||||||
"Adding %s as %s callback for entity %s",
|
"Adding %s as %s callback for entity %s",
|
||||||
methodName,
|
methodName,
|
||||||
callbackType.getCallbackAnnotation().getSimpleName(),
|
callbackType.getCallbackAnnotation().getSimpleName(),
|
||||||
beanClass.getName()
|
beanClass.getName()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
callbacks.add( 0, callback ); // listeners first
|
callbacks.add( 0, callback ); // listeners first
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -237,9 +245,9 @@ public class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
final String embeddableClassName = embeddableProperty.getType().getReturnedClass().getName();
|
final String embeddableClassName = embeddableProperty.getType().getReturnedClass().getName();
|
||||||
final XClass embeddableXClass = reflectionManager.classForName( embeddableClassName );
|
final XClass embeddableXClass = reflectionManager.classForName( embeddableClassName );
|
||||||
final Getter embeddableGetter = embeddableProperty.getGetter( entityClass );
|
final Getter embeddableGetter = embeddableProperty.getGetter( entityClass );
|
||||||
|
final boolean debugEnabled = log.isDebugEnabled();
|
||||||
List<Callback> callbacks = new ArrayList<>();
|
final List<Callback> callbacks = new ArrayList<>();
|
||||||
List<String> callbacksMethodNames = new ArrayList<>();
|
final List<String> callbacksMethodNames = new ArrayList<>();
|
||||||
XClass currentClazz = embeddableXClass;
|
XClass currentClazz = embeddableXClass;
|
||||||
do {
|
do {
|
||||||
Callback callback = null;
|
Callback callback = null;
|
||||||
|
@ -261,12 +269,14 @@ public class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ReflectHelper.ensureAccessibility( method );
|
ReflectHelper.ensureAccessibility( method );
|
||||||
|
if ( debugEnabled ) {
|
||||||
log.debugf(
|
log.debugf(
|
||||||
"Adding %s as %s callback for entity %s",
|
"Adding %s as %s callback for entity %s",
|
||||||
methodName,
|
methodName,
|
||||||
callbackType.getCallbackAnnotation().getSimpleName(),
|
callbackType.getCallbackAnnotation().getSimpleName(),
|
||||||
embeddableXClass.getName()
|
embeddableXClass.getName()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
callbacks.add( 0, callback ); //superclass first
|
callbacks.add( 0, callback ); //superclass first
|
||||||
callbacksMethodNames.add( 0, methodName );
|
callbacksMethodNames.add( 0, methodName );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue