/** * @return interaction that will be passed to #aroundSlimInvoke(). */ public FixtureInteraction getInteraction() { if (interaction == null) { interaction = new DefaultInteraction(); } return interaction; }
private Method findMatchingMethod(String methodName, Method[] methods, int nArgs) { Method method = null; for (int i = 0; i < methods.length && method == null; i++) if (isMatchingMethod(methods[i], methodName, nArgs)) method = methods[i]; return method; }
private Method findMatchingMethod(String[] methodNames, Method[] methods, int nArgs) { Method method = null; for (int i = 0; i < methodNames.length && method == null; i++) method = findMatchingMethod(methodNames[i], methods, nArgs); return method; }
@Override protected Method findMatchingMethod(String methodName, Object instance, Object... args) { MethodKey key = new MethodKey(instance.getClass(), methodName, args.length); Method cached = methodsByNameAndArgs.get(key); if (cached == noMethod) return null; if (cached != null) return cached; Method method = handleMethodCacheMiss(methodName, instance, args); if (method == null) { methodsByNameAndArgs.put(key, noMethod); } else { methodsByNameAndArgs.put(key, method); } return method; }
@Override protected Constructor<?> getConstructor(Class<?> clazz, Object[] args) { String key = getConstructorKey(clazz, args); Constructor<?> cached = constructorsByClassAndArgs.get(key); if (cached == noConstructor) return null; if (cached != null) return cached; Constructor<?> constructor = handleConstructorCacheMiss(clazz, args); if (constructor == null) { constructorsByClassAndArgs.put(key, noConstructor); } else { constructorsByClassAndArgs.put(key, constructor); } return constructor; }
protected Object invoke(FixtureInteraction interaction, Method method, Object[] arguments) throws Throwable { return interaction.methodInvoke(method, this, arguments); }
protected MethodExecutionResult findAndInvoke(String methodName, Object[] args, Object instance) throws Throwable { FixtureInteraction interaction = context.getInteraction(); return interaction.findAndInvoke(methodName, instance, args); } }
@Override protected Class<?> getClass(String className) { Class<?> cached = classCache.get(className); if (cached == NotExisting.class) return null; if (cached != null) return cached; Class<?> k = handleClassCacheMiss(className); if (k == null) { classCache.put(className, NotExisting.class); } else { classCache.put(className, k); } return k; }
protected Class<?> handleClassCacheMiss(String className) { return super.getClass(className); }
private Class<?> findClassInPaths(List<String> paths, String... classNames) { Class<?> k = null; for (int i = 0; i < classNames.length && k == null; i++) k = findClassInPaths(paths, classNames[i]); return k; }
protected Constructor<?> handleConstructorCacheMiss(Class<?> clazz, Object[] args) { return super.getConstructor(clazz, args); }
protected Method handleMethodCacheMiss(String methodName, Object instance, Object[] args) { return super.findMatchingMethod(methodName, instance, args); }
protected Constructor<?> handleConstructorCacheMiss(Class<?> clazz, Object[] args) { return super.getConstructor(clazz, args); }
protected Class<?> handleClassCacheMiss(String className) { return super.getClass(className); }
@Override protected Method findMatchingMethod(String methodName, Object instance, Object... args) { MethodKey key = new MethodKey(instance.getClass(), methodName, args.length); Method cached = methodsByNameAndArgs.get(key); if (cached == noMethod) return null; if (cached != null) return cached; Method method = handleMethodCacheMiss(methodName, instance, args); if (method == null) { methodsByNameAndArgs.put(key, noMethod); } else { methodsByNameAndArgs.put(key, method); } return method; }
@Override protected Constructor<?> getConstructor(Class<?> clazz, Object[] args) { String key = getConstructorKey(clazz, args); Constructor<?> cached = constructorsByClassAndArgs.get(key); if (cached == noConstructor) return null; if (cached != null) return cached; Constructor<?> constructor = handleConstructorCacheMiss(clazz, args); if (constructor == null) { constructorsByClassAndArgs.put(key, noConstructor); } else { constructorsByClassAndArgs.put(key, constructor); } return constructor; }
protected MethodExecutionResult findAndInvoke(String methodName, Object[] args, Object instance) throws Throwable { FixtureInteraction interaction = context.getInteraction(); return interaction.findAndInvoke(methodName, instance, args); } }
@Override protected Class<?> getClass(String className) { Class<?> cached = classCache.get(className); if (cached == NotExisting.class) return null; if (cached != null) return cached; Class<?> k = handleClassCacheMiss(className); if (k == null) { classCache.put(className, NotExisting.class); } else { classCache.put(className, k); } return k; }
protected Method handleMethodCacheMiss(String methodName, Object instance, Object[] args) { return super.findMatchingMethod(methodName, instance, args); }
private Class<?> findClassInPaths(List<String> paths, String className) { Class<?> k = null; for (int i = 0; i < paths.size() && k == null; i++) k = getClass(paths.get(i) + "." + className); return k; }