use of org.nutz.mvc.adaptor.injector.ObjectNaviNode in project nutz by nutzam.
the class PropertiesIocLoader method reload.
@SuppressWarnings("rawtypes")
public void reload() {
List<String> beanNames = new ArrayList<String>();
for (String key : keys()) {
if (!key.startsWith("ioc.") || key.length() < 5)
continue;
String[] tmp = key.split("[.]");
if (tmp.length == 3) {
if (tmp[2].equals("type") || tmp[2].equals("factory")) {
beanNames.add(tmp[1]);
}
}
}
for (String beanName : beanNames) {
ObjectNaviNode no = new ObjectNaviNode();
String prefix = "ioc." + beanName + ".";
String pre = "";
ParamExtractor pe = Params.makeParamExtractor(null, this.toMap());
for (Object name : pe.keys()) {
String na = (String) name;
if (na.startsWith(prefix)) {
no.put(pre + na, pe.extractor(na));
}
}
Object model = no.get();
Object re = Mapl.maplistToObj(((Map) model).get(beanName), IocObject.class);
this.objs.put(beanName, (IocObject) re);
}
// 插入自身
//this.objs.put("conf", Iocs.wrap(this));
}
use of org.nutz.mvc.adaptor.injector.ObjectNaviNode in project nutz by nutzam.
the class MaplTest method test_complex_prefix.
@Test
public void test_complex_prefix() throws Exception {
String params = "draw=1&columns%5B0%5D%5Bdata%5D=userId&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=loginname&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=true&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=nickname&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=true&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=0&order%5B0%5D%5Bdir%5D=asc&start=0&length=10&search%5Bvalue%5D=&search%5Bregex%5D=false";
//String params = "columns%5B0%5D%5Bdata%5D=userId&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true";
NutMap map = new NutMap();
for (String kv : params.split("&")) {
//System.out.println(kv);
String[] tmp = kv.split("=");
String key = URLDecoder.decode(tmp[0], "UTF-8");
String value = URLDecoder.decode(tmp.length > 1 ? tmp[1] : "", "UTF-8");
map.put(key, value);
}
System.out.println(map);
String prefix = "columns";
Object refer = map;
HttpServletRequest req = new MockHttpServletRequest();
ObjectNaviNode no = new ObjectNaviNode();
String pre = "";
if ("".equals(prefix))
pre = "node.";
ParamExtractor pe = Params.makeParamExtractor(req, refer);
for (Object name : pe.keys()) {
String na = (String) name;
if (na.startsWith(prefix)) {
String[] val = pe.extractor(na);
no.put(pre + na, val);
}
}
Object model = no.get();
System.out.println(Json.toJson(model));
Object re = Mapl.maplistToObj(model, NutType.list(DataTableColumn.class));
System.out.println(Json.toJson(re));
}
Aggregations