/** * @return interaction that will be passed to #aroundSlimInvoke(). */ public FixtureInteraction getInteraction() { if (interaction == null) { interaction = new DefaultInteraction(); } return interaction; }
protected Method handleMethodCacheMiss(String methodName, Object instance, Object[] args) { return super.findMatchingMethod(methodName, instance, args); }
protected Class<?> handleClassCacheMiss(String className) { return super.getClass(className); }
@Override public Object createInstance(List<String> paths, String className, Object[] args) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<?> k = searchPathsForClass(paths, className); Constructor<?> constructor = getConstructor(k, args); if (constructor == null) { throw new SlimError(String.format("message:<<%s %s>>", SlimServer.NO_CONSTRUCTOR, className)); } return newInstance(args, constructor); }
final Object[] convertedArgs = getConvertedConstructorArgsTypes(constructor, args); final boolean matchedConstructorArgsTypes = hasConstructorArgsTypes(constructorArgs, convertedArgs); if (matchedConstructorArgsTypes) { currentDiffCounter = getConstructorArgsConvertionDiff(args, convertedArgs);
protected MethodExecutionResult invokeMethod(Object instance, Method method, Object[] args) throws Throwable { Object[] convertedArgs = convertArgs(method, args); Object retval = callMethod(instance, method, convertedArgs); Class<?> retType = method.getReturnType(); return new MethodExecutionResult(retval, retType); }
@Override public MethodExecutionResult findAndInvoke(String methodName, Object instance, Object... args) throws Throwable { Method method = findMatchingMethod(methodName, instance, args); if (method != null) { return this.invokeMethod(instance, method, args); } return MethodExecutionResult.noMethod(methodName, instance.getClass(), args.length); }
protected Constructor<?> handleConstructorCacheMiss(Class<?> clazz, Object[] args) { return super.getConstructor(clazz, args); }
@SuppressWarnings("unchecked") public static FixtureInteraction createInteraction(String interactionClassName, ClassLoader classLoader) { if (interactionClassName == null) { return new DefaultInteraction(); } try { return ((Class<FixtureInteraction>) classLoader.loadClass(interactionClassName)).newInstance(); } catch (Exception e) { throw new SlimError(e); } } }
protected Class<?> searchPathsForClass(List<String> paths, String className) { Class<?> k = getClass(className); if (k != null) { return k; } for (String path : paths) { k = getClass(path + "." + className); if (k != null) { return k; } } throw new SlimError(String.format("message:<<%s %s>>", SlimServer.NO_CLASS, className)); }
@SuppressWarnings("unchecked") public static FixtureInteraction createInteraction(String interactionClassName, ClassLoader classLoader) { if (interactionClassName == null) { return new DefaultInteraction(); } try { return ((Class<FixtureInteraction>) classLoader.loadClass(interactionClassName)).newInstance(); } catch (Exception e) { throw new SlimError(e); } } }