This is an automated email from the ASF dual-hosted git repository. jlmonteiro pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/main by this push: new d76fbd589e Using an interface seems to make it slower to make StatelessInvocationStatsTest d76fbd589e is described below commit d76fbd589e39010af3978ce6dcd5df0c1d2346f4 Author: Jean-Louis Monteiro <jlmonte...@tomitribe.com> AuthorDate: Fri Dec 16 23:29:44 2022 +0100 Using an interface seems to make it slower to make StatelessInvocationStatsTest --- .../interceptor/ReflectionInvocationContext.java | 49 +++++++++++++--------- .../openejb/monitoring/StatsInterceptor.java | 3 -- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/interceptor/ReflectionInvocationContext.java b/container/openejb-core/src/main/java/org/apache/openejb/core/interceptor/ReflectionInvocationContext.java index 39c087935e..2879742cfc 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/interceptor/ReflectionInvocationContext.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/interceptor/ReflectionInvocationContext.java @@ -195,55 +195,64 @@ public class ReflectionInvocationContext implements InvocationContext { } } - public interface Invocation { - Object invoke() throws Exception; - } - protected abstract static class InvocationBase implements Invocation { - private final Executable executable; + protected abstract static class Invocation { + private final Method method; private final Object[] args; private final Object target; - public InvocationBase(final Object target, final Executable executable, final Object[] args) { + public Invocation(final Object target, final Method method, final Object[] args) { this.target = target; - this.executable = executable; + this.method = method; this.args = args; } public Object invoke() throws Exception { - if (executable instanceof Method) { - return ((Method) executable).invoke(target, args); - - } else { - return ((Constructor) executable).newInstance(args); - } + final Object value = method.invoke(target, args); + return value; } public String toString() { - return executable.getDeclaringClass().getName() + "." + executable.getName(); + return method.getDeclaringClass().getName() + "." + method.getName(); } } - private static class BeanInvocation extends InvocationBase { + private static class BeanInvocation extends Invocation { public BeanInvocation(final Object target, final Method method, final Object[] args) { super(target, method, args); } } - protected static class ConstructorInvocation extends InvocationBase { + protected static class ConstructorInvocation extends Invocation { + private final Constructor constructor; + private final Object[] args; + public ConstructorInvocation(final Constructor constructor, final Object[] args) { - super(null, constructor, args); + super(null, null, args); + this.args = args; + this.constructor = constructor; + } + + @Override + public Object invoke() throws Exception { + final Object value = constructor.newInstance(args); + return value; + } + + + public String toString() { + return constructor.getDeclaringClass().getName() + "." + constructor.getName(); } } - private static class InterceptorInvocation extends InvocationBase { + private static class InterceptorInvocation extends Invocation { public InterceptorInvocation(final Object target, final Method method, final InvocationContext invocationContext) { super(target, method, new Object[]{invocationContext}); } } - private static class LifecycleInvocation extends InvocationBase { + private static class LifecycleInvocation extends Invocation { private final InvocationContext invocationContext; public LifecycleInvocation(final Object target, final Method method, final InvocationContext invocationContext, final Object[] args) { @@ -261,7 +270,7 @@ public class ReflectionInvocationContext implements InvocationContext { } } - private static class NoOpInvocation extends InvocationBase { + private static class NoOpInvocation extends Invocation { public NoOpInvocation() { super(null, null, null); } diff --git a/container/openejb-core/src/main/java/org/apache/openejb/monitoring/StatsInterceptor.java b/container/openejb-core/src/main/java/org/apache/openejb/monitoring/StatsInterceptor.java index 7ad47df47d..5ca49a6778 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/monitoring/StatsInterceptor.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/monitoring/StatsInterceptor.java @@ -22,8 +22,6 @@ import org.apache.openejb.api.Monitor; import org.apache.openejb.core.interceptor.InterceptorData; import org.apache.openejb.loader.SystemInstance; import org.apache.openejb.math.stat.descriptive.SynchronizedDescriptiveStatistics; -import org.apache.openejb.util.LogCategory; -import org.apache.openejb.util.Logger; import org.apache.xbean.finder.ClassFinder; import jakarta.annotation.PostConstruct; @@ -38,7 +36,6 @@ import jakarta.interceptor.AroundTimeout; import jakarta.interceptor.InvocationContext; import java.lang.reflect.Method; import java.util.Collection; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit;