use of org.nutz.ioc.loader.json.JsonLoader in project nutz by nutzam.
the class EvensJsonIocTest method test_event_from_parent.
@Test
public void test_event_from_parent() {
Ioc ioc = new NutIoc(new JsonLoader("org/nutz/ioc/json/events.js"));
Animal f = ioc.get(Animal.class, "fox");
assertEquals(1, f.getCreateTime());
assertEquals(1, f.getFetchTime());
assertEquals(0, f.getDeposeTime());
ioc.depose();
assertEquals(1, f.getCreateTime());
assertEquals(1, f.getFetchTime());
assertEquals(1, f.getDeposeTime());
}
use of org.nutz.ioc.loader.json.JsonLoader in project nutz by nutzam.
the class SimpleJsonIocTest method test_load_from_reader.
@Test
public void test_load_from_reader() throws ObjectLoadException {
IocLoader loader = new JsonLoader(Streams.fileInr("org/nutz/ioc/json/main.js"));
assertTrue(loader.getName().length > 0);
}
use of org.nutz.ioc.loader.json.JsonLoader in project nutz by nutzam.
the class SimpleJsonIocTest method test_load_from_dir.
@Test
public void test_load_from_dir() throws ObjectLoadException {
IocLoader loader = new JsonLoader("org/nutz/ioc/json/");
assertTrue(loader.getName().length > 0);
}
use of org.nutz.ioc.loader.json.JsonLoader in project nutz by nutzam.
the class ComboIocLoader method load.
public IocObject load(IocLoading loading, String name) throws ObjectLoadException {
for (IocLoader iocLoader : iocLoaders) if (iocLoader.has(name)) {
IocObject iocObject = iocLoader.load(loading, name);
if (log.isDebugEnabled()) {
// TODO 弄成更好看的格式,方便debug
String printName;
if (iocLoader instanceof AnnotationIocLoader) {
String packages = Arrays.toString(((AnnotationIocLoader) iocLoader).getPackages());
printName = "AnnotationIocLoader(packages=" + packages + ")";
} else if (JsonLoader.class.equals(iocLoader.getClass()) && ((JsonLoader) iocLoader).getPaths() != null) {
String paths = Arrays.toString(((JsonLoader) iocLoader).getPaths());
printName = "JsonLoader(paths=" + paths + ")";
} else {
printName = iocLoader.getClass().getSimpleName() + "@" + iocLoader.hashCode();
}
log.debugf("Found IocObject(%s) in %s", name, printName);
}
return iocObject;
}
throw new ObjectLoadException("Object '" + name + "' without define!");
}
Aggregations