@Aop("redis")
public String set(String key, String value) {
return jedis().set(key, value);
}
这个@Aop("redis")预处理的类在什么目录下,名字是什么?
@Aop("redis")
public String set(String key, String value) {
return jedis().set(key, value);
}
这个@Aop("redis")预处理的类在什么目录下,名字是什么?
public class RedisInterceptor implements MethodInterceptor {
protected JedisAgent jedisAgent;
protected static ThreadLocal<Jedis> TL = new ThreadLocal<Jedis>();
public void filter(InterceptorChain chain) throws Throwable {
if (TL.get() != null) {
chain.doChain();
return;
}
Jedis jedis = null;
try {
jedis = jedisAgent.jedis();
TL.set(jedis);
chain.doChain();
} finally{
Streams.safeClose(jedis);
TL.remove();
}
}
public static Jedis jedis() {
return TL.get();
}
public void setJedisAgent(JedisAgent jedisAgent) {
this.jedisAgent = jedisAgent;
}
}
我按照框架,在其他地方写了个类似的
protected JedisAgent jedisAgent;
jedisAgent.jedis();
怎么是null