本文整理了Java中org.nutz.ioc.Ioc
类的一些代码示例,展示了Ioc
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ioc
类的具体详情如下:
包路径:org.nutz.ioc.Ioc
类名称:Ioc
[英]Ioc 容器接口
[中]国际奥委会容器接口
代码示例来源:origin: nutzam/nutz
public Object get(ServletContext sc, HttpServletRequest req, HttpServletResponse resp, Object refer) {
Ioc ioc = Mvcs.getIoc();
if (null == ioc)
throw new RuntimeException("You need define @IocBy in main module!!!");
if (Strings.isBlank(objName))
return ioc.get(objType);
return ioc.get(objType, objName);
}
代码示例来源:origin: nutzam/nutz
names = ioc.getNamesByType(type);
if (names != null && names.length == 1) {
return ioc.get(type, names[0]);
if (ioc.has(name)) {
if (ioc instanceof Ioc2)
return ((Ioc2)ioc).get(type, name, ctx);
return ioc.get(type, name);
return ((Ioc2)ioc).getByType(type, ctx);
else
return ioc.getByType(type);
代码示例来源:origin: nutzam/nutz
L.set(Integer.TYPE);
boolean flag = true;
String[] names = ioc.getNames();
Arrays.sort(names);
for (String beanName : names) {
if (!beanName.startsWith(AopConfigration.IOCNAME))
continue;
AopConfigration cnf = ioc.get(AopConfigration.class, beanName);
list.add(cnf);
if (cnf instanceof AnnotationAopConfigration)
代码示例来源:origin: nutzam/nutzboot
public static DataSource getSlaveDataSource(Ioc ioc, PropertiesProxy conf, String prefix) {
if (ioc.has("slaveDataSource")) {
return ioc.get(DataSource.class, "slaveDataSource");
} else {
return _getSlaveDataSource(ioc, conf, prefix);
}
}
代码示例来源: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
webSecurityManager.setSessionManager(ioc.get(WebSessionManager.class, "shiroWebSessionManager"));
for (String realmName : ioc.getNamesByType(Realm.class)) {
AuthorizingRealm realm = ioc.get(AuthorizingRealm.class, realmName);
if (conf.getBoolean(PROP_REALM_CACHE_ENABLE, false)) {
realm.setCacheManager(ioc.get(CacheManager.class, "shiroCacheManager"));
if (ioc.has("authenticationStrategy")) {
ModularRealmAuthenticator modularRealmAuthenticator = new ModularRealmAuthenticator();
modularRealmAuthenticator.setAuthenticationStrategy(ioc.get(AuthenticationStrategy.class, "authenticationStrategy"));
if (realms.size() > 0)
modularRealmAuthenticator.setRealms(realms);
webSecurityManager.setRememberMeManager(ioc.get(RememberMeManager.class, "shiroRememberMeManager"));
return webSecurityManager;
代码示例来源:origin: nutzam/nutzboot
protected Object createTest() throws Exception {
if (hasIocBean)
return getIoc().get(getTestClass().getJavaClass());
Object obj = getTestClass().getJavaClass().newInstance();
for (Field field : fields) {
field.set(obj, getIoc().getByType(field.getType()));
}
return obj;
}
代码示例来源:origin: nutzam/nutzboot
/**
* 容器初始化时,初始化Spring Mvc的Ioc容器,并放入ServletContext
*/
public void contextInitialized(ServletContextEvent sce) {
applicationContext = new XmlWebApplicationContext();
applicationContext.setServletContext(sce.getServletContext());
applicationContext.setConfigLocation(configLocation);
applicationContext.refresh();
appContext.getComboIocLoader().addLoader(new SpringIocLoader2(applicationContext, getSpringBeanNames().toArray(new String[0])));
sce.getServletContext().setAttribute("spring." + selfName, applicationContext);
// 登记所有标注了@AsSpringBean的对象到spring ioc
Ioc ioc = appContext.getIoc();
for (String name : ioc.getNamesByAnnotation(AsSpringBean.class)) {
applicationContext.getBeanFactory().registerSingleton(name, ioc.get(null, name));
}
}
代码示例来源:origin: nutzam/nutz
public boolean has(String key) {
if (key == null)
return false;
if ("sys".equals(key))
return true;
if ("env".equals(key))
return true;
if ("$ioc".equals(key))
return true;
if (key.startsWith("$") && key.length() > 1)
return ioc.has(key.substring(1));
return super.has(key);
}
代码示例来源:origin: nutzam/nutzboot
public void prepareIoc() {
if (ctx.getIoc() == null) {
ctx.setIoc(new NutIoc(ctx.getComboIocLoader()));
}
// 把核心对象放进ioc容器
if (!ctx.ioc.has("appContext")) {
ctx.ioc.addBean("appContext", ctx);
ctx.ioc.addBean("conf", ctx.getConf());
ctx.ioc.addBean("nbApp", this);
// 添加更多扩展bean
ctx.ioc.addBean("counterService", new MemoryCounterService());
}
Mvcs.ctx().iocs.put("nutz", ctx.getIoc());
}
代码示例来源:origin: nutzam/nutz
public Object getByType(Ioc ioc, IocContext ctx) {
if (ioc instanceof Ioc2)
return ((Ioc2)ioc).getByType(type, ctx);
else
return ioc.getByType(type);
}
}
代码示例来源:origin: nutzam/nutzboot
public static DataSource getManySlaveDataSource(Ioc ioc, PropertiesProxy conf, String prefix) {
if (ioc.has(prefix + "slaveDataSource")) {
return ioc.get(DataSource.class, prefix + "slaveDataSource");
} else {
return _getSlaveDataSource(ioc, conf, prefix);
}
}
代码示例来源: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/nutz
for (int i = 0; i < vms.value().length; i++) {
if (vms.value()[i].getAnnotation(IocBean.class) != null && ioc != null) {
makers.add(ioc.get(vms.value()[i]));
} else {
makers.add(Mirror.me(vms.value()[i]).born());
String[] names = ioc.getNames();
Arrays.sort(names);
for (String name : ioc.getNames()) {
if (name != null && name.startsWith(ViewMaker.IOCNAME)) {
log.debug("add ViewMaker from Ioc by name=" + name);
makers.add(ioc.get(ViewMaker.class, name));
代码示例来源:origin: nutzam/nutz
injectName);
injectName = ai.getInjectName();
if (!ioc.has(injectName)) {
log.warnf("Moudle with @InjectName('%s') or @IocBean('%s') but no such ioc bean found!! Pls check your ioc configure!!",
injectName,
代码示例来源:origin: org.nutz/nutzboot-core
public void prepareIoc() {
if (ctx.getIoc() == null) {
ctx.setIoc(new NutIoc(ctx.getComboIocLoader()));
}
// 把核心对象放进ioc容器
if (!ctx.ioc.has("appContext")) {
ctx.ioc.addBean("appContext", ctx);
ctx.ioc.addBean("conf", ctx.getConf());
ctx.ioc.addBean("nbApp", this);
// 添加更多扩展bean
ctx.ioc.addBean("counterService", new MemoryCounterService());
}
Mvcs.ctx().iocs.put("nutz", ctx.getIoc());
}
代码示例来源:origin: org.nutz/nutz
public Object getByType(Ioc ioc, IocContext ctx) {
if (ioc instanceof Ioc2)
return ((Ioc2)ioc).getByType(type, ctx);
else
return ioc.getByType(type);
}
}
代码示例来源:origin: nutzam/nutz
public List<? extends MethodInterceptor> makeIt(Aop t, Method method, Ioc ioc) {
List<MethodInterceptor> list = new ArrayList<MethodInterceptor>();
for (String name : t.value()) {
list.add(ioc.get(MethodInterceptor.class, name));
}
return list;
}
}
代码示例来源:origin: org.nutz/nutzboot-starter-jdbc
public static DataSource getSlaveDataSource(Ioc ioc, PropertiesProxy conf, String prefix) {
if (ioc.has("slaveDataSource")) {
return ioc.get(DataSource.class, "slaveDataSource");
} else {
return _getSlaveDataSource(ioc, conf, prefix);
}
}
代码示例来源: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;
} else {
this.stringifier = ioc.get(KeyStringifier.class, types[0]);
内容来源于网络,如有侵权,请联系作者删除!