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

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

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

Ioc.has介绍

暂无

代码示例

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

  1. public boolean has(String key) {
  2. if (key == null)
  3. return false;
  4. if ("sys".equals(key))
  5. return true;
  6. if ("env".equals(key))
  7. return true;
  8. if ("$ioc".equals(key))
  9. return true;
  10. if (key.startsWith("$") && key.length() > 1)
  11. return ioc.has(key.substring(1));
  12. return super.has(key);
  13. }

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

  1. injectName);
  2. injectName = ai.getInjectName();
  3. if (!ioc.has(injectName)) {
  4. log.warnf("Moudle with @InjectName('%s') or @IocBean('%s') but no such ioc bean found!! Pls check your ioc configure!!",
  5. injectName,

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

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

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

  1. public boolean has(String key) {
  2. if (key == null)
  3. return false;
  4. if ("sys".equals(key))
  5. return true;
  6. if ("env".equals(key))
  7. return true;
  8. if ("$ioc".equals(key))
  9. return true;
  10. if (key.startsWith("$") && key.length() > 1)
  11. return ioc.has(key.substring(1));
  12. return super.has(key);
  13. }

代码示例来源:origin: org.nutz/nutzboot-starter-jdbc

  1. public static DataSource getSlaveDataSource(Ioc ioc, PropertiesProxy conf, String prefix) {
  2. if (ioc.has("slaveDataSource")) {
  3. return ioc.get(DataSource.class, "slaveDataSource");
  4. } else {
  5. return _getSlaveDataSource(ioc, conf, prefix);
  6. }
  7. }

代码示例来源:origin: org.nutz/nutzboot-starter-jdbc

  1. public static DataSource getManySlaveDataSource(Ioc ioc, PropertiesProxy conf, String prefix) {
  2. if (ioc.has(prefix + "slaveDataSource")) {
  3. return ioc.get(DataSource.class, prefix + "slaveDataSource");
  4. } else {
  5. return _getSlaveDataSource(ioc, conf, prefix);
  6. }
  7. }

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

  1. public static DataSource getSlaveDataSource(Ioc ioc, PropertiesProxy conf, String prefix) {
  2. if (ioc.has("slaveDataSource")) {
  3. return ioc.get(DataSource.class, "slaveDataSource");
  4. } else {
  5. return _getSlaveDataSource(ioc, conf, prefix);
  6. }
  7. }

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

  1. public static DataSource getManySlaveDataSource(Ioc ioc, PropertiesProxy conf, String prefix) {
  2. if (ioc.has(prefix + "slaveDataSource")) {
  3. return ioc.get(DataSource.class, prefix + "slaveDataSource");
  4. } else {
  5. return _getSlaveDataSource(ioc, conf, prefix);
  6. }
  7. }

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

  1. protected void checkOrigin() {
  2. if (ioc == null) {
  3. ioc = AppContext.getDefault().getIoc();
  4. if (ioc.has("uflo.environmentProvider")) {
  5. origin = ioc.get(EnvironmentProvider.class, "uflo.environmentProvider");
  6. }
  7. }
  8. if (origin == this) {
  9. log.warn("you have to define a class implements EnvironmentProvider and mask @IocBean(name='uflo.environmentProvider')");
  10. }
  11. }

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

  1. public FilterChainResolver createFilterChainResolver() {
  2. if (ioc.has("shiroFilterChainResolver")) {
  3. return ioc.get(FilterChainResolver.class, "shiroFilterChainResolver");
  4. }
  5. else {
  6. log.debug("ioc name=shiroFilterChainResolver not found, fallback to " + ShiroEnvStarter.PROP_INIT_URLS);
  7. String iniUrls = "[urls]\r\n" + conf.get(ShiroEnvStarter.PROP_INIT_URLS, "").trim();
  8. log.debug("shiro ini urls ---> \r\n" + iniUrls);
  9. Ini ini = new Ini();
  10. ini.load(iniUrls);
  11. IniFilterChainResolverFactory resolverFactory = new IniFilterChainResolverFactory(ini, objects);
  12. return resolverFactory.getInstance();
  13. }
  14. }

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

  1. @IocBean(name = "shiroEhcacheCacheManager")
  2. public CacheManager getShiroEhcacheCacheManager() {
  3. EhCacheManager cacheManager = new EhCacheManager();
  4. if (ioc.has("ehcacheCacheManager")) {
  5. cacheManager.setCacheManager(ioc.get(net.sf.ehcache.CacheManager.class, "ehcacheCacheManager"));
  6. } else {
  7. cacheManager.setCacheManager((net.sf.ehcache.CacheManager) _getCacheManager());
  8. }
  9. return cacheManager;
  10. }

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

  1. public void prepareIoc() {
  2. if (ctx.getIoc() == null) {
  3. ctx.setIoc(new NutIoc(ctx.getComboIocLoader()));
  4. }
  5. // 把核心对象放进ioc容器
  6. if (!ctx.ioc.has("appContext")) {
  7. ctx.ioc.addBean("appContext", ctx);
  8. ctx.ioc.addBean("conf", ctx.getConf());
  9. ctx.ioc.addBean("nbApp", this);
  10. // 添加更多扩展bean
  11. ctx.ioc.addBean("counterService", new MemoryCounterService());
  12. }
  13. Mvcs.ctx().iocs.put("nutz", ctx.getIoc());
  14. }

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

  1. public void prepareIoc() {
  2. if (ctx.getIoc() == null) {
  3. ctx.setIoc(new NutIoc(ctx.getComboIocLoader()));
  4. }
  5. // 把核心对象放进ioc容器
  6. if (!ctx.ioc.has("appContext")) {
  7. ctx.ioc.addBean("appContext", ctx);
  8. ctx.ioc.addBean("conf", ctx.getConf());
  9. ctx.ioc.addBean("nbApp", this);
  10. // 添加更多扩展bean
  11. ctx.ioc.addBean("counterService", new MemoryCounterService());
  12. }
  13. Mvcs.ctx().iocs.put("nutz", ctx.getIoc());
  14. }

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

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

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

  1. injectName);
  2. injectName = ai.getInjectName();
  3. if (!ioc.has(injectName)) {
  4. log.warnf("Moudle with @InjectName('%s') or @IocBean('%s') but no such ioc bean found!! Pls check your ioc configure!!",
  5. injectName,

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

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

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

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

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

  1. /**
  2. * 异步客户端
  3. */
  4. @IocBean(name = "mqttAsyncClient", depose = "close")
  5. public MqttAsyncClient createMqttAsyncClient(@Inject MqttConnectOptions mqttConnectOptions, @Inject MqttClientPersistence mqttClientPersistence) throws MqttException {
  6. String clientId = conf.get(PROP_CLIENT_ID);
  7. if (Strings.isBlank(clientId)) {
  8. clientId = MqttClient.generateClientId();
  9. }
  10. log.info("Client Id = " + clientId);
  11. MqttAsyncClient client = new MqttAsyncClient(conf.get(PROP_URL, "tcp://127.0.0.1:1883"), clientId, mqttClientPersistence);
  12. if (ioc.has("mqttCallback")) {
  13. client.setCallback(ioc.get(MqttCallback.class, "mqttCallback"));
  14. }
  15. if (conf.getBoolean(PROP_CONNECT_ON_START, true)) {
  16. IMqttToken token = client.connect(mqttConnectOptions, null, null);
  17. token.waitForCompletion(conf.getLong(PROP_TIME_TO_WAIT, -1));
  18. if (token.getException() != null)
  19. throw token.getException();
  20. }
  21. return client;
  22. }
  23. }

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

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

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

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

相关文章