本文整理了Java中org.nutz.ioc.Ioc.getNamesByType()
方法的一些代码示例,展示了Ioc.getNamesByType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ioc.getNamesByType()
方法的具体详情如下:
包路径:org.nutz.ioc.Ioc
类名称:Ioc
方法名:getNamesByType
暂无
代码示例来源:origin: nutzam/nutz
names = ioc.getNamesByType(type);
if (names != null && names.length == 1) {
return ioc.get(type, names[0]);
代码示例来源:origin: org.nutz/nutzboot-core
/**
* 根据Class获取指定的Ioc Bean列表
*
* @param klass
* 需要指定的Class类
* @return 符合Class类的Ioc Bean列表
*/
public <T> List<T> getBeans(Class<T> klass) {
List<T> list = new ArrayList<>();
for (String name : getIoc().getNamesByType(klass)) {
if (name == null)
continue;
list.add(getIoc().get(klass, name));
}
return list;
}
代码示例来源:origin: nutzam/nutzboot
/**
* 根据Class获取指定的Ioc Bean列表
*
* @param klass
* 需要指定的Class类
* @return 符合Class类的Ioc Bean列表
*/
public <T> List<T> getBeans(Class<T> klass) {
List<T> list = new ArrayList<>();
for (String name : getIoc().getNamesByType(klass)) {
if (name == null)
continue;
list.add(getIoc().get(klass, name));
}
return list;
}
代码示例来源:origin: nutzam/nutzboot
public void init() {
Map<String, CacheStrategy> map = new HashMap<>();
String[] types = ioc.getNamesByType(KeyStringifier.class);
if (Lang.isEmptyArray(types)) {
this.stringifier = String::valueOf;
代码示例来源:origin: nutzam/nutzboot
for (String realmName : ioc.getNamesByType(Realm.class)) {
AuthorizingRealm realm = ioc.get(AuthorizingRealm.class, realmName);
if (conf.getBoolean(PROP_REALM_CACHE_ENABLE, false)) {
代码示例来源:origin: nutzam/nutzboot
public static DataSource createDataSource(Ioc ioc, PropertiesProxy conf, String prefix) {
switch (conf.get(prefix + "type", "druid")) {
case "simple":
case "org.nutz.dao.impl.SimpleDataSource":
SimpleDataSource simpleDataSource = new SimpleDataSource();
String jdbcUrl = conf.get(PRE + "jdbcUrl", conf.get(PRE + "url"));
if (Strings.isBlank(jdbcUrl)) {
throw new RuntimeException("need " + PRE + ".url");
}
simpleDataSource.setJdbcUrl(jdbcUrl);
simpleDataSource.setUsername(conf.get(PROP_USERNAME));
simpleDataSource.setPassword(conf.get(PROP_PASSWORD));
return simpleDataSource;
case "druid":
case "com.alibaba.druid.pool.DruidDataSource":
DataSource ds = ioc.get(DataSource.class, "druidDataSource");
String[] tmp = ioc.getNamesByType(DruidPasswordCallback.class);
for (String beanName : tmp) {
if (!Strings.isBlank(beanName))
((DruidDataSource)ds).setPasswordCallback(ioc.get(DruidPasswordCallback.class, beanName));
}
return ds;
case "hikari":
case "com.zaxxer.hikari.HikariDataSource":
return ioc.get(DataSource.class, "hikariDataSource");
default:
break;
}
throw new RuntimeException("not supported jdbc.type=" + conf.get("jdbc.type"));
}
代码示例来源:origin: org.nutz/nutzboot-starter-jdbc
public static DataSource createDataSource(Ioc ioc, PropertiesProxy conf, String prefix) {
switch (conf.get(prefix + "type", "druid")) {
case "simple":
case "org.nutz.dao.impl.SimpleDataSource":
SimpleDataSource simpleDataSource = new SimpleDataSource();
String jdbcUrl = conf.get(PRE + "jdbcUrl", conf.get(PRE + "url"));
if (Strings.isBlank(jdbcUrl)) {
throw new RuntimeException("need " + PRE + ".url");
}
simpleDataSource.setJdbcUrl(jdbcUrl);
simpleDataSource.setUsername(conf.get(PROP_USERNAME));
simpleDataSource.setPassword(conf.get(PROP_PASSWORD));
return simpleDataSource;
case "druid":
case "com.alibaba.druid.pool.DruidDataSource":
DataSource ds = ioc.get(DataSource.class, "druidDataSource");
String[] tmp = ioc.getNamesByType(DruidPasswordCallback.class);
for (String beanName : tmp) {
if (!Strings.isBlank(beanName))
((DruidDataSource)ds).setPasswordCallback(ioc.get(DruidPasswordCallback.class, beanName));
}
return ds;
case "hikari":
case "com.zaxxer.hikari.HikariDataSource":
return ioc.get(DataSource.class, "hikariDataSource");
default:
break;
}
throw new RuntimeException("not supported jdbc.type=" + conf.get("jdbc.type"));
}
代码示例来源:origin: org.nutz/nutz
names = ioc.getNamesByType(type);
if (names != null && names.length == 1) {
return ioc.get(type, names[0]);
内容来源于网络,如有侵权,请联系作者删除!