public abstract class MethodKeyBuilder extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MethodKeyBuilder.FastMethodKeyBuilder
FastMethodKeyBuilder
targetClass、methodName、argTypes 的 hash 直接使用 String.hashCode()
String.hashCode() 会被缓存,性能更好
|
static class |
MethodKeyBuilder.StrictMethodKeyBuilder
StrictMethodKeyBuilder
targetClass、methodName、argTypes 三部分全部使用 fnv1a64 算法计算 hash
|
Constructor and Description |
---|
MethodKeyBuilder() |
Modifier and Type | Method and Description |
---|---|
static MethodKeyBuilder |
getInstance() |
abstract Long |
getMethodKey(Class<?> targetClass,
String methodName,
Class<?>[] argTypes)
生成指定 class、指定方法名、指定方法形参类型的 key 值,用于缓存
|
static void |
setMethodKeyBuilder(MethodKeyBuilder methodKeyBuilder)
切换到用户自定义 MethodKeyBuilder
|
static void |
useStrictMethodKeyBuilder()
切换到 StrictMethodKeyBuilder
|
public abstract Long getMethodKey(Class<?> targetClass, String methodName, Class<?>[] argTypes)
public static MethodKeyBuilder getInstance()
public static void useStrictMethodKeyBuilder()
特别注意: 如果希望将 configEngine(Engine me) 中的 Engine 切换到 StrictMethodKeyBuilder, 需要在 YourJFinalConfig extends JFinalConfig 中利用如下代码块才能生效: static { MethodKeyBuilder.useStrictMethodKeyBuilder(); } 原因是在 com.jfinal.core.Config 中 new Engine() 时 useStrictMethodKeyBuilder() 方法并未生效,所以 extension method 生成 method key 时仍然使用的是 FastMethodKeyBuilder 以至于在运行时,使用 StrictMethodKeyBuilder 生成的 key 找不到 extension method
public static void setMethodKeyBuilder(MethodKeyBuilder methodKeyBuilder)
Copyright © 2018. All rights reserved.