@SuppressWarnings("unchecked")
public ComboIocLoader(String... args) throws ClassNotFoundException {
if (loaders.isEmpty()) {
loaders.put("js", JsonLoader.class);
loaders.put("json", JsonLoader.class);
loaders.put("xml", XmlIocLoader.class);
loaders.put("annotation", AnnotationIocLoader.class);
loaders.put("anno", AnnotationIocLoader.class);
loaders.put("trans", TransIocLoader.class);
loaders.put("tx", TransIocLoader.class);
loaders.put("props", PropertiesIocLoader.class);
loaders.put("properties", PropertiesIocLoader.class);
loaders.put("async", AsyncAopIocLoader.class);
try {
loaders.put("cache",
(Class<? extends IocLoader>) Lang.loadClass("org.nutz.jcache.NutCacheIocLoader"));
}
catch (ClassNotFoundException e) {}
try {
loaders.put("quartz",
(Class<? extends IocLoader>) Lang.loadClass("org.nutz.integration.quartz.QuartzIocLoader"));
}
catch (ClassNotFoundException e) {}
}
ArrayList<String> argsList = null;
String currentClassName = null;
for (String str : args) {
if (str.length() > 0 && str.charAt(0) == '*') {
if (argsList != null)
createIocLoader(currentClassName, argsList);
currentClassName = str.substring(1);
argsList = new ArrayList<String>();
} else {
if (argsList == null) {
throw new IllegalArgumentException("ioc args without Loader ClassName. "
+ Arrays.toString(args));
}
argsList.add(str);
}
}
if (currentClassName != null)
createIocLoader(currentClassName, argsList);
Set<String> beanNames = new HashSet<String>();
for (IocLoader loader : iocLoaders) {
for (String beanName : loader.getName()) {
if (!beanNames.add(beanName) && log.isWarnEnabled())
log.warnf("Found Duplicate beanName=%s, pls check you config! loader=%s", beanName,loader.getClass());
}
}
}
问答
ComboIocLoader 没有机会让我添加一个自定义的IocLoader 吗? 是不是增加一个 可以重载的方法呢?
标签:
无
6 回复
指的是自定义一个缩写?
来自炫酷的 NutzCN
Spring 的机制好像都可以这么做
public void ComboIocLoader(String... args) throws ClassNotFoundException {
addDefaultLoaders();
......
}
private void addDefaultLoaders() {
if (loaders.isEmpty()) {
loaders.put("js", JsonLoader.class);
loaders.put("json", JsonLoader.class);
loaders.put("xml", XmlIocLoader.class);
loaders.put("annotation", AnnotationIocLoader.class);
loaders.put("anno", AnnotationIocLoader.class);
loaders.put("trans", TransIocLoader.class);
loaders.put("tx", TransIocLoader.class);
loaders.put("props", PropertiesIocLoader.class);
loaders.put("properties", PropertiesIocLoader.class);
loaders.put("async", AsyncAopIocLoader.class);
try {
loaders.put("cache",
(Class<? extends IocLoader>) Lang.loadClass("org.nutz.jcache.NutCacheIocLoader"));
}
catch (ClassNotFoundException e) {}
try {
loaders.put("quartz",
(Class<? extends IocLoader>) Lang.loadClass("org.nutz.integration.quartz.QuartzIocLoader"));
}
catch (ClassNotFoundException e) {}
}
}
我可以重载 addDefaultLoaders 增加自定义的
添加回复
请先登陆