Skip to content

Commit

Permalink
Don't use reflection on each 'around invocation'
Browse files Browse the repository at this point in the history
  • Loading branch information
fhoeben committed Apr 25, 2015
1 parent f1f2dcd commit 4ca5efc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/fitnesse/slim/MethodExecutor.java
Expand Up @@ -8,8 +8,14 @@
import fitnesse.slim.fixtureInteraction.InteractionAwareFixture;

public abstract class MethodExecutor {
public MethodExecutor() {
super();
private static final Method AROUND_METHOD;

static {
try {
AROUND_METHOD = InteractionAwareFixture.class.getMethod("aroundSlimInvoke", FixtureInteraction.class, Method.class, Object[].class);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}

public abstract MethodExecutionResult execute(String instanceName, String methodName, Object[] args) throws Throwable;
Expand Down Expand Up @@ -45,10 +51,8 @@ protected Object callMethod(Object instance, Method method, Object[] convertedAr
Object result;
if (instance instanceof InteractionAwareFixture) {
// invoke via interaction, so it can also do its thing on the aroundMethod invocation
Class<?> clazz = instance.getClass();
Method aroundMethod = clazz.getMethod("aroundSlimInvoke", FixtureInteraction.class, Method.class, Object[].class);
Object[] args = { interaction, method, convertedArgs };
result = interaction.methodInvoke(aroundMethod, instance, args);
result = interaction.methodInvoke(AROUND_METHOD, instance, args);
} else {
result = interaction.methodInvoke(method, instance, convertedArgs);
}
Expand Down

0 comments on commit 4ca5efc

Please sign in to comment.