Java Code Examples for io.jboot.Jboot#config()
The following examples show how to use
io.jboot.Jboot#config() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InfluxdbReporter.java From jboot with Apache License 2.0 | 6 votes |
@Override public void report(MetricRegistry metricRegistry) { JbootMetricInfluxdbReporterConfig config = Jboot.config(JbootMetricInfluxdbReporterConfig.class); final ScheduledReporter reporter = metrics_influxdb.InfluxdbReporter.forRegistry(metricRegistry) .protocol(new HttpInfluxdbProtocol("http" , config.getHost() , config.getPort() , config.getUser() , config.getPassword() , config.getDbName())) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .filter(MetricFilter.ALL) .skipIdleMetrics(false) // .tag("cluster", config.getTagCluster()) // .tag("client", config.getTagClient()) // .tag("server", serverIP) // .transformer(new CategoriesMetricMeasurementTransformer("module", "artifact")) .build(); reporter.start(10, TimeUnit.SECONDS); }
Example 2
Source File: JfinalConfigListener.java From jboot-admin with Apache License 2.0 | 5 votes |
@Override public void onJfinalEngineConfig(Engine engine) { engine.setDevMode(true); AppInfo app = Jboot.config(AppInfo.class); engine.addSharedObject("APP", app); engine.addSharedObject("RESOURCE_HOST", app.getResourceHost()); }
Example 3
Source File: JbootCoreConfig.java From jboot with Apache License 2.0 | 5 votes |
/** * 设置必要的系统参数: * 有些组件,比如 apollo、sentinel 等配置需要通过 System Properites来进行配置的 */ private void initSystemProperties() { //加载 jboot-system.properties 代替启动参数的 -D 配置 File spf = new File(PathKit.getRootClassPath(), "jboot-system.properties"); if (spf.exists() && spf.isFile()) { Properties properties = PropKit.use(spf).getProperties(); if (properties != null && !properties.isEmpty()) { for (Object key : properties.keySet()) { if (StrUtil.isNotBlank(key)) { String newKey = key.toString().trim(); String systemValue = System.getProperty(newKey); if (StrUtil.isNotBlank(systemValue)) { continue; } String newValue = properties.getProperty(newKey); if (StrUtil.isNotBlank(newValue)) { System.setProperty(newKey, newValue.trim()); } } } } } //apollo 配置 ApolloServerConfig apolloConfig = Jboot.config(ApolloServerConfig.class); if (apolloConfig.isEnable() && apolloConfig.isConfigOk()) { System.setProperty("app.id", apolloConfig.getAppId()); System.setProperty("apollo.meta", apolloConfig.getMeta()); } }
Example 4
Source File: JbootRedismqImpl.java From jboot with Apache License 2.0 | 5 votes |
public JbootRedismqImpl() { super(); JbootmqRedisConfig redisConfig = Jboot.config(JbootmqRedisConfig.class); if (redisConfig.isConfigOk()) { redis = JbootRedisManager.me().getRedis(redisConfig); } else { redis = Jboot.getRedis(); } if (redis == null) { throw new JbootIllegalConfigException("can not use redis mq (redis mq is default), " + "please config jboot.redis.host=your-host , or use other mq component. "); } }
Example 5
Source File: JbootScheduleManager.java From jboot with Apache License 2.0 | 5 votes |
public JbootScheduleManager() { config = Jboot.config(JbooScheduleConfig.class); fixedScheduler = new ScheduledThreadPoolExecutor(config.getPoolSize(),new NamedThreadFactory("jboot-scheduler")); File cron4jProperties = new File(PathKit.getRootClassPath(), config.getCron4jFile()); cron4jPlugin = cron4jProperties.exists() ? new JbootCron4jPlugin(new Prop(config.getCron4jFile())) : new JbootCron4jPlugin(); }
Example 6
Source File: LimiterManager.java From jboot with Apache License 2.0 | 5 votes |
/** * 解析用户配置 */ private void doParseConfig() { LimitConfig config = Jboot.config(LimitConfig.class); if (!isEnable()) { return; } String rule = config.getRule(); if (StrUtil.isBlank(rule)) { return; } String[] rules = rule.split(","); for (String r : rules) { String[] confs = r.split(":"); if (confs == null || confs.length != 3) { continue; } String packageOrTarget = confs[0]; String type = confs[1]; String rate = confs[2]; if (!ensureLegal(packageOrTarget, type, rate.trim())) { continue; } packageOrTarget = packageOrTarget.replace(".", "\\.") .replace("(", "\\(") .replace(")", "\\)") .replace("*", ".*"); configPackageOrTargets.add(packageOrTarget.trim()); typeAndRateCache.put(packageOrTarget.trim(), new TypeAndRate(type.trim(), Integer.valueOf(rate.trim()))); } }
Example 7
Source File: LimiterManager.java From jboot with Apache License 2.0 | 5 votes |
private void doInitFallbackProcesser() { LimitConfig config = Jboot.config(LimitConfig.class); if (StrUtil.isBlank(config.getFallbackProcesser())) { this.fallbackProcesser = new LimitFallbackProcesserDefault(); } else { this.fallbackProcesser = Objects.requireNonNull(ClassUtil.newInstance(config.getFallbackProcesser()), "can not newInstance class for " + config.getFallbackProcesser()); } }
Example 8
Source File: JbootRedisCacheImpl.java From jboot with Apache License 2.0 | 5 votes |
public JbootRedisCacheImpl() { JbootRedisCacheConfig redisConfig = Jboot.config(JbootRedisCacheConfig.class); if (redisConfig.isConfigOk()) { redis = JbootRedisManager.me().getRedis(redisConfig); } else { redis = Jboot.getRedis(); } if (redis == null) { throw new JbootIllegalConfigException("can not get redis, please check your jboot.properties , please correct config jboot.cache.redis.host or jboot.redis.host "); } }
Example 9
Source File: JbootmqManager.java From jboot with Apache License 2.0 | 5 votes |
public Jbootmq getJbootmq() { if (jbootmq == null) { JbootmqConfig config = Jboot.config(JbootmqConfig.class); jbootmq = getJbootmq(config); } return jbootmq; }
Example 10
Source File: JbootQpidmqImpl.java From jboot with Apache License 2.0 | 5 votes |
public JbootQpidmqImpl() { super(); JbootQpidmqConfig qpidConfig = Jboot.config(JbootQpidmqConfig.class); serializerEnable = qpidConfig.isSerializerEnable(); try { String url = getConnectionUrl(); connection = new AMQConnection(url); connection.start(); } catch (Exception e) { throw new JbootException("can not connection qpidmq server", e); } }
Example 11
Source File: JbootAliyunmqImpl.java From jboot with Apache License 2.0 | 5 votes |
private Properties createProperties() { JbootAliyunmqConfig aliyunmqConfig = Jboot.config(JbootAliyunmqConfig.class); Properties properties = new Properties(); properties.put(PropertyKeyConst.AccessKey, aliyunmqConfig.getAccessKey());//AccessKey 阿里云身份验证,在阿里云服务器管理控制台创建 properties.put(PropertyKeyConst.SecretKey, aliyunmqConfig.getSecretKey());//SecretKey 阿里云身份验证,在阿里云服务器管理控制台创建 properties.put(PropertyKeyConst.ProducerId, aliyunmqConfig.getProducerId());//您在控制台创建的Producer ID properties.put(PropertyKeyConst.ONSAddr, aliyunmqConfig.getAddr()); properties.setProperty(PropertyKeyConst.SendMsgTimeoutMillis, aliyunmqConfig.getSendMsgTimeoutMillis());//设置发送超时时间,单位毫秒 return properties; }
Example 12
Source File: JbootRedisManager.java From jboot with Apache License 2.0 | 5 votes |
public JbootRedis getRedis() { if (redis == null) { JbootRedisConfig config = Jboot.config(JbootRedisConfig.class); redis = getRedis(config); } return redis; }
Example 13
Source File: JbootHttpManager.java From jboot with Apache License 2.0 | 5 votes |
private JbootHttp buildJbootHttp() { JbootHttpConfig config = Jboot.config(JbootHttpConfig.class); switch (config.getType()) { case JbootHttpConfig.TYPE_DEFAULT: return new JbootHttpImpl(); case JbootHttpConfig.TYPE_OKHTTP: return new OKHttpImpl(); case JbootHttpConfig.TYPE_HTTPCLIENT: throw new RuntimeException("not finished!!!!"); default: return JbootSpiLoader.load(JbootHttp.class, config.getType()); } }
Example 14
Source File: JbootEhcacheImpl.java From jboot with Apache License 2.0 | 5 votes |
public JbootEhcacheImpl() { JbootEhCacheConfig config = Jboot.config(JbootEhCacheConfig.class); if (StrUtil.isBlank(config.getConfigFileName())) { cacheManager = CacheManager.create(); } else { String configPath = config.getConfigFileName(); if (!configPath.startsWith("/")){ configPath = PathKit.getRootClassPath()+"/"+configPath; } cacheManager = CacheManager.create(configPath); } }
Example 15
Source File: JbootCoreConfig.java From jboot with Apache License 2.0 | 4 votes |
@Override public void configRoute(Routes routes) { routes.setMappingSuperClass(true); List<Class<Controller>> controllerClassList = ClassScanner.scanSubClass(Controller.class); if (ArrayUtil.isNotEmpty(controllerClassList)) { for (Class<Controller> clazz : controllerClassList) { RequestMapping mapping = clazz.getAnnotation(RequestMapping.class); if (mapping == null) { continue; } String value = AnnotationUtil.get(mapping.value()); if (value == null) { continue; } String viewPath = AnnotationUtil.get(mapping.viewPath()); if (StrUtil.isNotBlank(viewPath)) { routes.add(value, clazz, viewPath); } else { routes.add(value, clazz); } } } JbootSwaggerConfig swaggerConfig = Jboot.config(JbootSwaggerConfig.class); if (swaggerConfig.isConfigOk()) { routes.add(swaggerConfig.getPath(), JbootSwaggerController.class, swaggerConfig.getPath()); } JbootAppListenerManager.me().onRouteConfig(routes); for (Routes.Route route : routes.getRouteItemList()) { JbootControllerManager.me().setMapping(route.getControllerKey(), route.getControllerClass()); } routeList.addAll(routes.getRouteItemList()); }
Example 16
Source File: JbootWechatController.java From jboot with Apache License 2.0 | 4 votes |
@NotAction public void initJsSdkConfig() { JbootWechatConfig config = Jboot.config(JbootWechatConfig.class); // 1.拼接url(当前网页的URL,不包含#及其后面部分) String url = getRequest().getRequestURL().toString().split("#")[0]; String query = getRequest().getQueryString(); if (StrUtil.isNotBlank(query)) { url = url.concat("?").concat(query); } // JsTicket jsTicket = JsTicketApi.getTicket(JsTicketApi.JsApiType.jsapi); JsTicket jsTicket = WechatApis.getTicket(WechatApis.JsApiType.jsapi); String _wxJsApiTicket = jsTicket.getTicket(); String noncestr = StrUtil.uuid(); String timestamp = (System.currentTimeMillis() / 1000) + ""; Map<String, String> _wxMap = new TreeMap<String, String>(); _wxMap.put("noncestr", noncestr); _wxMap.put("timestamp", timestamp); _wxMap.put("jsapi_ticket", _wxJsApiTicket); _wxMap.put("url", url); //拼接字符串 StringBuilder paramsBuilder = new StringBuilder(); for (Map.Entry<String, String> param : _wxMap.entrySet()) { paramsBuilder.append(param.getKey()).append("=").append(param.getValue()).append("&"); } String signString = paramsBuilder.substring(0, paramsBuilder.length() - 1); //签名 String signature = HashKit.sha1(signString); setAttr("wechatDebug", config.getDebug()); setAttr("wechatAppId", getApiConfig().getAppId()); setAttr("wechatNoncestr", noncestr); setAttr("wechatTimestamp", timestamp); setAttr("wechatSignature", signature); }
Example 17
Source File: JbootModelConfig.java From jboot with Apache License 2.0 | 4 votes |
public static JbootModelConfig getConfig() { if (config == null) { config = Jboot.config(JbootModelConfig.class); } return config; }
Example 18
Source File: JbootSerializerManager.java From jboot with Apache License 2.0 | 4 votes |
public JbootSerializer getSerializer() { JbootSerializerConfig config = Jboot.config(JbootSerializerConfig.class); return getSerializer(config.getType()); }
Example 19
Source File: AppServiceImplGenerator.java From jboot-admin with Apache License 2.0 | 4 votes |
public static void doGenerate() { AppServiceImplGeneratorConfig config = Jboot.config(AppServiceImplGeneratorConfig.class); System.out.println(config.toString()); if (StrKit.isBlank(config.getModelpackage())) { System.err.println("jboot.admin.serviceimpl.ge.modelpackage 不可为空"); System.exit(0); } if (StrKit.isBlank(config.getServicepackage())) { System.err.println("jboot.admin.serviceimpl.ge.servicepackage 不可为空"); System.exit(0); } if (StrKit.isBlank(config.getServiceimplpackage())) { System.err.println("jboot.admin.serviceimpl.ge.serviceimplpackage 不可为空"); System.exit(0); } String modelPackage = config.getModelpackage(); String servicepackage = config.getServicepackage(); String serviceimplpackage = config.getServiceimplpackage(); System.out.println("start generate..."); System.out.println("generate dir:" + servicepackage); DataSource dataSource = CodeGenHelpler.getDatasource(); AppMetaBuilder metaBuilder = new AppMetaBuilder(dataSource); if (StrKit.notBlank(config.getRemovedtablenameprefixes())) { metaBuilder.setRemovedTableNamePrefixes(config.getRemovedtablenameprefixes().split(",")); } if (StrKit.notBlank(config.getExcludedtableprefixes())) { metaBuilder.setSkipPre(config.getExcludedtableprefixes().split(",")); } List<TableMeta> tableMetaList = metaBuilder.build(); CodeGenHelpler.excludeTables(tableMetaList, config.getExcludedtable()); new AppJbootServiceImplGenerator(servicepackage , modelPackage, serviceimplpackage).generate(tableMetaList); System.out.println("service generate finished !!!"); }
Example 20
Source File: AppModelGenerator.java From jboot-admin with Apache License 2.0 | 3 votes |
public static void doGenerate() { AppModelGeneratorConfig config = Jboot.config(AppModelGeneratorConfig.class); System.out.println(config.toString()); if (StrKit.isBlank(config.getModelpackage())) { System.err.println("jboot.admin.model.ge.modelpackage 不可为空"); System.exit(0); } String modelPackage = config.getModelpackage(); String baseModelPackage = modelPackage + ".base"; String modelDir = PathKit.getWebRootPath() + "/src/main/java/" + modelPackage.replace(".", "/"); String baseModelDir = PathKit.getWebRootPath() + "/src/main/java/" + baseModelPackage.replace(".", "/"); System.out.println("start generate..."); System.out.println("generate dir:" + modelDir); DataSource dataSource = CodeGenHelpler.getDatasource(); AppMetaBuilder metaBuilder = new AppMetaBuilder(dataSource); if (StrKit.notBlank(config.getRemovedtablenameprefixes())) { metaBuilder.setRemovedTableNamePrefixes(config.getRemovedtablenameprefixes().split(",")); } if (StrKit.notBlank(config.getExcludedtableprefixes())) { metaBuilder.setSkipPre(config.getExcludedtableprefixes().split(",")); } List<TableMeta> tableMetaList = metaBuilder.build(); CodeGenHelpler.excludeTables(tableMetaList, config.getExcludedtable()); new JbootBaseModelGenerator(baseModelPackage, baseModelDir).generate(tableMetaList); new JbootModelGenerator(modelPackage, baseModelPackage, modelDir).generate(tableMetaList); System.out.println("entity generate finished !!!"); }