This commit is contained in:
Redkale
2017-03-29 13:55:16 +08:00
parent c2edb60218
commit 0bc0755fb3

View File

@@ -5,7 +5,10 @@
*/
package org.redkale.test.source;
import org.redkale.source.FilterBean;
import java.lang.reflect.Method;
import java.util.*;
import java.util.function.BiFunction;
import org.redkale.source.*;
/**
*
@@ -14,7 +17,25 @@ import org.redkale.source.FilterBean;
public class LoginTestBean implements FilterBean {
private String sessionid;
private int sid;
public static void main(String[] args) throws Throwable {
LoginTestBean bean = new LoginTestBean();
bean.setSessionid("xxx");
bean.setSid(23333);
BiFunction<DataSource, Class, List> fullloader = (s, z) -> new ArrayList();
Method method = EntityInfo.class.getDeclaredMethod("load", Class.class, boolean.class, Properties.class,
DataSource.class, BiFunction.class);
method.setAccessible(true);
final EntityInfo<CacheTestBean> info = (EntityInfo<CacheTestBean>) method.invoke(null, CacheTestBean.class, true, new Properties(), null, fullloader);
EntityCache<CacheTestBean> cache = new EntityCache(info, null);
FilterNode node = FilterNodeBean.createFilterNode(bean);
System.out.println("cache = " + cache + ", node = " + node);
Method pre = FilterNode.class.getDeclaredMethod("createPredicate", EntityCache.class);
pre.setAccessible(true);
//为null是因为CacheTestBean 没有sid和sessionid这两个字段
System.out.println(pre.invoke(node,cache));
}
public String getSessionid() {
return sessionid;
}
@@ -23,4 +44,12 @@ public class LoginTestBean implements FilterBean {
this.sessionid = sessionid;
}
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
}