org.nutz.ioc.Ioc.has()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(230)

本文整理了Java中org.nutz.ioc.Ioc.has()方法的一些代码示例,展示了Ioc.has()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ioc.has()方法的具体详情如下:
包路径:org.nutz.ioc.Ioc
类名称:Ioc
方法名:has

Ioc.has介绍

暂无

代码示例

代码示例来源: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/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: nutzam/nutz

if (ioc.has(name)) {
  if (ioc instanceof Ioc2)
    return ((Ioc2)ioc).get(type, name, ctx);

代码示例来源:origin: org.nutz/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: 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: org.nutz/nutzboot-starter-jdbc

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: 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

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: nutzam/nutzboot

protected void checkOrigin() {
  if (ioc == null) {
    ioc = AppContext.getDefault().getIoc();
    if (ioc.has("uflo.environmentProvider")) {
      origin = ioc.get(EnvironmentProvider.class, "uflo.environmentProvider");
    }
  }
  if (origin == this) {
    log.warn("you have to define a class implements EnvironmentProvider and mask @IocBean(name='uflo.environmentProvider')");
  }
}

代码示例来源:origin: nutzam/nutzboot

public FilterChainResolver createFilterChainResolver() {
  if (ioc.has("shiroFilterChainResolver")) {
    return ioc.get(FilterChainResolver.class, "shiroFilterChainResolver");
  }
  else {
    log.debug("ioc name=shiroFilterChainResolver not found, fallback to " + ShiroEnvStarter.PROP_INIT_URLS);
    String iniUrls = "[urls]\r\n" + conf.get(ShiroEnvStarter.PROP_INIT_URLS, "").trim();
    log.debug("shiro ini urls  ---> \r\n" + iniUrls);
    Ini ini = new Ini();
    ini.load(iniUrls);
    IniFilterChainResolverFactory resolverFactory = new IniFilterChainResolverFactory(ini, objects);
    return resolverFactory.getInstance();
  }
}

代码示例来源:origin: nutzam/nutzboot

@IocBean(name = "shiroEhcacheCacheManager")
public CacheManager getShiroEhcacheCacheManager() {
  EhCacheManager cacheManager = new EhCacheManager();
  if (ioc.has("ehcacheCacheManager")) {
    cacheManager.setCacheManager(ioc.get(net.sf.ehcache.CacheManager.class, "ehcacheCacheManager"));
  } else {
    cacheManager.setCacheManager((net.sf.ehcache.CacheManager) _getCacheManager());
  }
  return cacheManager;
}

代码示例来源: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: 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: nutzam/nutzboot

if (ioc.has("authenticationStrategy")) {
  ModularRealmAuthenticator modularRealmAuthenticator = new ModularRealmAuthenticator();
  modularRealmAuthenticator.setAuthenticationStrategy(ioc.get(AuthenticationStrategy.class, "authenticationStrategy"));

代码示例来源:origin: org.nutz/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: nutzam/nutzboot

@IocBean
public HttpServerStarter getHttpServerStarter(HttpConfig httpConfig) {
  String[] scanPackages = new String[]{appContext.getPackage()};//tio mvc需要扫描的根目录包
  Routes routes = new Routes(scanPackages, this);
  DefaultHttpRequestHandler requestHandler = new DefaultHttpRequestHandler(httpConfig, routes);
  String apiInterceptorName = conf.get(PROP_API_INTERCEPTOR, "apiInterceptor");
  if (appContext.getIoc().has(apiInterceptorName)) {
    requestHandler.setHttpServerInterceptor(appContext.ioc().get(HttpServerInterceptor.class, apiInterceptorName));
  }
  else {
    log.debugf("apiInterceptor name=%s not found in ioc , skiped", apiInterceptorName);
  }
  return new HttpServerStarter(httpConfig, requestHandler);
}

代码示例来源:origin: org.nutz/nutz

if (ioc.has(name)) {
  if (ioc instanceof Ioc2)
    return ((Ioc2)ioc).get(type, name, ctx);

代码示例来源:origin: nutzam/nutzboot

/**
   * 异步客户端
   */
  @IocBean(name = "mqttAsyncClient", depose = "close")
  public MqttAsyncClient createMqttAsyncClient(@Inject MqttConnectOptions mqttConnectOptions, @Inject MqttClientPersistence mqttClientPersistence) throws MqttException {
    String clientId = conf.get(PROP_CLIENT_ID);
    if (Strings.isBlank(clientId)) {
      clientId = MqttClient.generateClientId();
    }
    log.info("Client Id = " + clientId);
    MqttAsyncClient client = new MqttAsyncClient(conf.get(PROP_URL, "tcp://127.0.0.1:1883"), clientId, mqttClientPersistence);
    if (ioc.has("mqttCallback")) {
      client.setCallback(ioc.get(MqttCallback.class, "mqttCallback"));
    }
    if (conf.getBoolean(PROP_CONNECT_ON_START, true)) {
      IMqttToken token = client.connect(mqttConnectOptions, null, null);
      token.waitForCompletion(conf.getLong(PROP_TIME_TO_WAIT, -1));
      if (token.getException() != null)
        throw token.getException();
    }
    return client;
  }
}

代码示例来源:origin: nutzam/nutzboot

/**
 * 同步阻塞客户端, 然后它不支持通过MqttAsyncClient来构建,真蛋疼
 */
@IocBean(name = "mqttClient", depose = "close")
public MqttClient createMqttClient(@Inject MqttConnectOptions mqttConnectOptions, @Inject MqttClientPersistence mqttClientPersistence) throws MqttException {
  String clientId = conf.get(PROP_CLIENT_ID);
  if (Strings.isBlank(clientId)) {
    clientId = MqttClient.generateClientId();
  }
  log.info("Client Id = " + clientId);
  MqttClient client = new MqttClient(conf.get(PROP_URL, "tcp://127.0.0.1:1883"), clientId, mqttClientPersistence);
  if (ioc.has("mqttCallback")) {
    client.setCallback(ioc.get(MqttCallback.class, "mqttCallback"));
  }
  client.setTimeToWait(conf.getLong(PROP_TIME_TO_WAIT, -1));
  if (conf.getBoolean(PROP_CONNECT_ON_START, true)) {
    IMqttToken token = client.connectWithResult(mqttConnectOptions);
    if (token.getException() != null)
      throw token.getException();
  }
  return client;
}

代码示例来源:origin: nutzam/nutzboot

if (httpConfig.isUseSession()) {
  String sessionIdGeneratorName = conf.get(PROP_SESSION_ID_GENERATOR, "sessionIdGenerator");
  if (appContext.getIoc().has(sessionIdGeneratorName)) {
    httpConfig.setSessionIdGenerator(appContext.getIoc().get(ISessionIdGenerator.class, sessionIdGeneratorName));
  if (appContext.getIoc().has(sessionStoreName)) {
    httpConfig.setSessionStore(appContext.getIoc().get(ICache.class, sessionStoreName));

相关文章