org.nutz.lang.Lang.loadClassQuite()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(153)

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

Lang.loadClassQuite介绍

暂无

代码示例

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

@SuppressWarnings("unchecked")
private void createIocLoader(String className, List<String> args) throws ClassNotFoundException {
  Class<? extends IocLoader> klass = loaders.get(className);
  if (klass == null) {
    if (!className.contains(".")) {
      Set<String> _names = new HashSet<String>();
      String uccp = Strings.upperFirst(className);
      _names.add(String.format("org.nutz.integration.%s.%sIocLoader", className, uccp));
      _names.add(String.format("org.nutz.integration.%s.%sAopConfigure", className, uccp));
      _names.add(String.format("org.nutz.plugins.%s.%sIocLoader", className, uccp));
      _names.add(String.format("org.nutz.plugins.%s.%sAopConfigure", className, uccp));
      // 寻找插件或集成类 @since 1.r.57
      for (String _className : _names) {
        klass = (Class<? extends IocLoader>) Lang.loadClassQuite(_className);
        if (klass != null) {
          log.debug("found " + className + " -- " + _className);
          break;
        }
      }
    }
    if (klass == null)
      klass = (Class<? extends IocLoader>) Lang.loadClass(className);
  }
  iocLoaders.add((IocLoader) Mirror.me(klass).born(args.toArray(new Object[args.size()])));
}

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

public DaoInterceptor makeInterceptor(Object it) {
  if (it == null)
    return null;
  if (it instanceof String) {
    String itName = it.toString().trim();
    if ("log".equals(itName)) {
      return new DaoLogInterceptor();
    }
    else if ("time".equals(itName)) {
      return new DaoTimeInterceptor();
    } 
    else if (itName.contains(".")) {
      Class<?> klass = Lang.loadClassQuite(itName);
      if (klass == null) {
        log.warn("no such interceptor name="+itName);
      } else {
        return (DaoInterceptor) Mirror.me(klass).born();
      }
    } else {
      log.info("unkown interceptor name="+itName);
    }
  }
  else if (it instanceof DaoInterceptor) {
    return (DaoInterceptor) it;
  } else {
    log.info("unkown interceptor -> "+it);
  }
  return null;
}

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

public NbApp(AppContext ctx) {
  this.ctx = ctx;
  StackTraceElement[] ts = Thread.currentThread().getStackTrace();
  if (ts.length > 2) {
    setMainClass(Lang.loadClassQuite(ts[2].getClassName()));
  }
}

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

public NbApp(AppContext ctx) {
  this.ctx = ctx;
  StackTraceElement[] ts = Thread.currentThread().getStackTrace();
  if (ts.length > 2) {
    setMainClass(Lang.loadClassQuite(ts[2].getClassName()));
  }
}

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

/**
 * 创建一个NbApp,把调用本构造方法的类作为mainClass
 */
public NbApp() {
  ctx = AppContext.getDefault();
  StackTraceElement[] ts = Thread.currentThread().getStackTrace();
  if (ts.length > 2) {
    setMainClass(Lang.loadClassQuite(ts[2].getClassName()));
  }
}

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

/**
 * 创建一个NbApp,把调用本构造方法的类作为mainClass
 */
public NbApp() {
  ctx = AppContext.getDefault();
  StackTraceElement[] ts = Thread.currentThread().getStackTrace();
  if (ts.length > 2) {
    setMainClass(Lang.loadClassQuite(ts[2].getClassName()));
  }
}

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

@SuppressWarnings("unchecked")
private void createIocLoader(String className, List<String> args) throws ClassNotFoundException {
  Class<? extends IocLoader> klass = loaders.get(className);
  if (klass == null) {
    if (!className.contains(".")) {
      Set<String> _names = new HashSet<String>();
      String uccp = Strings.upperFirst(className);
      _names.add(String.format("org.nutz.integration.%s.%sIocLoader", className, uccp));
      _names.add(String.format("org.nutz.integration.%s.%sAopConfigure", className, uccp));
      _names.add(String.format("org.nutz.plugins.%s.%sIocLoader", className, uccp));
      _names.add(String.format("org.nutz.plugins.%s.%sAopConfigure", className, uccp));
      // 寻找插件或集成类 @since 1.r.57
      for (String _className : _names) {
        klass = (Class<? extends IocLoader>) Lang.loadClassQuite(_className);
        if (klass != null) {
          log.debug("found " + className + " -- " + _className);
          break;
        }
      }
    }
    if (klass == null)
      klass = (Class<? extends IocLoader>) Lang.loadClass(className);
  }
  iocLoaders.add((IocLoader) Mirror.me(klass).born(args.toArray(new Object[args.size()])));
}

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

public DaoInterceptor makeInterceptor(Object it) {
  if (it == null)
    return null;
  if (it instanceof String) {
    String itName = it.toString().trim();
    if ("log".equals(itName)) {
      return new DaoLogInterceptor();
    }
    else if ("time".equals(itName)) {
      return new DaoTimeInterceptor();
    } 
    else if (itName.contains(".")) {
      Class<?> klass = Lang.loadClassQuite(itName);
      if (klass == null) {
        log.warn("no such interceptor name="+itName);
      } else {
        return (DaoInterceptor) Mirror.me(klass).born();
      }
    } else {
      log.info("unkown interceptor name="+itName);
    }
  }
  else if (it instanceof DaoInterceptor) {
    return (DaoInterceptor) it;
  } else {
    log.info("unkown interceptor -> "+it);
  }
  return null;
}

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

@IocBean(name = "beetlsqlConnectionSource")
public ConnectionSource createConnectionSource(@Inject DataSource dataSource) {
  DataSource[] slaves = null;
  if (Lang.loadClassQuite("org.nutz.boot.starter.jdbc.DataSourceStarter") != null) {
    DataSource slaveDataSource = DataSourceStarter.getSlaveDataSource(ioc, conf, "jdbc.slave.");
    if (slaveDataSource != null)
      slaves = new DataSource[] {slaveDataSource};
  }
  if (conf.getBoolean(PROP_TRANS, true)) {
    // 默认事务管理,就是没有管理
    return new DefaultConnectionSource(dataSource, slaves);
  }
  // 支持 Trans.exec 或者 @Aop(TransAop.READ_COMMITTED)
  return new NutzConnectionSource(dataSource, slaves);
}

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

@IocBean(name = "dao")
public NutDao getDao(@Inject DataSource dataSource, @Inject SqlManager sqlManager) {
  NutDao dao = new NutDao(dataSource, sqlManager);
  List<Object> interceptors = new ArrayList<>();
  // 是否启用了DaoCache呢?
  if (conf.getBoolean(PROP_INTERCEPTOR_CACHE_ENABLE, false)) {
    interceptors.add(ioc.get(DaoCacheInterceptor.class));
  }
  // 日志拦截器
  if (conf.getBoolean(PROP_INTERCEPTOR_LOG_ENABLE, true)) {
    interceptors.add("log");
  }
  // sql耗时拦截器
  if (conf.getBoolean(PROP_INTERCEPTOR_TIME_ENABLE, true)) {
    interceptors.add("time");
  }
  // TODO 自定义其他拦截器?
  // 将拦截器赋予dao对象
  dao.setInterceptors(interceptors);
  // 看看是不是需要注入从数据库
  if (Lang.loadClassQuite("org.nutz.boot.starter.jdbc.DataSourceStarter") != null) {
    DataSource slaveDataSource = DataSourceStarter.getSlaveDataSource(ioc, conf, "jdbc.slave.");
    if (slaveDataSource != null) {
      NutDaoRunner runner = new NutDaoRunner();
      runner.setSlaveDataSource(slaveDataSource);
      dao.setRunner(runner);
    }
  }
  return dao;
}

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

@IocBean(name = "dao")
public NutDao getDao(@Inject DataSource dataSource, @Inject SqlManager sqlManager) {
  NutDao dao = new NutDao(dataSource, sqlManager);
  List<Object> interceptors = new ArrayList<>();
  // 是否启用了DaoCache呢?
  if (conf.getBoolean(PROP_INTERCEPTOR_CACHE_ENABLE, false)) {
    interceptors.add(ioc.get(DaoCacheInterceptor.class));
  }
  // 日志拦截器
  if (conf.getBoolean(PROP_INTERCEPTOR_LOG_ENABLE, true)) {
    interceptors.add("log");
  }
  // sql耗时拦截器
  if (conf.getBoolean(PROP_INTERCEPTOR_TIME_ENABLE, true)) {
    interceptors.add("time");
  }
  // TODO 自定义其他拦截器?
  // 将拦截器赋予dao对象
  dao.setInterceptors(interceptors);
  // 看看是不是需要注入从数据库
  if (Lang.loadClassQuite("org.nutz.boot.starter.jdbc.DataSourceStarter") != null) {
    DataSource slaveDataSource = DataSourceStarter.getSlaveDataSource(ioc, conf, "jdbc.slave.");
    if (slaveDataSource != null) {
      NutDaoRunner runner = new NutDaoRunner();
      runner.setSlaveDataSource(slaveDataSource);
      dao.setRunner(runner);
    }
  }
  return dao;
}

相关文章