001/** 002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com). 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package io.jboot.app; 017 018import io.jboot.JbootConsts; 019import io.jboot.app.config.JbootConfigManager; 020import io.jboot.app.config.annotation.ConfigModel; 021import io.jboot.utils.StrUtil; 022 023@ConfigModel(prefix = "jboot.app") 024public class JbootApplicationConfig { 025 026 private String mode = "dev"; 027 private String name = "jboot"; 028 private String version = JbootConsts.VERSION; 029 private boolean bannerEnable = true; 030 private String bannerFile = "banner.txt"; 031 private String jfinalConfig = "io.jboot.core.JbootCoreConfig"; 032 private String listener = "*"; 033 private String listenerPackage = "*"; 034 private boolean handle404 = true; 035 private String proxy; //cglib or javassist 036 037 038 public String getMode() { 039 return mode; 040 } 041 042 public void setMode(String mode) { 043 this.mode = mode; 044 } 045 046 public String getName() { 047 return name; 048 } 049 050 public void setName(String name) { 051 this.name = name; 052 } 053 054 public boolean isBannerEnable() { 055 return bannerEnable; 056 } 057 058 public void setBannerEnable(boolean bannerEnable) { 059 this.bannerEnable = bannerEnable; 060 } 061 062 public String getBannerFile() { 063 return bannerFile; 064 } 065 066 public void setBannerFile(String bannerFile) { 067 this.bannerFile = bannerFile; 068 } 069 070 public String getJfinalConfig() { 071 return jfinalConfig; 072 } 073 074 public void setJfinalConfig(String jfinalConfig) { 075 this.jfinalConfig = jfinalConfig; 076 } 077 078 public String getListener() { 079 return listener; 080 } 081 082 public void setListener(String listener) { 083 this.listener = listener; 084 } 085 086 public String getListenerPackage() { 087 return listenerPackage; 088 } 089 090 public void setListenerPackage(String listenerPackage) { 091 this.listenerPackage = listenerPackage; 092 } 093 094 public boolean isHandle404() { 095 return handle404; 096 } 097 098 public void setHandle404(boolean handle404) { 099 this.handle404 = handle404; 100 } 101 102 public String getProxy() { 103 if (StrUtil.isBlank(proxy)) { 104 proxy = initProxy(); 105 } 106 return proxy; 107 } 108 109 110 private String initProxy() { 111 ///cglib javassist 112 return JdkUtil.isJdk11To19() ? "javassist" : "cglib"; 113 } 114 115 public void setProxy(String proxy) { 116 this.proxy = proxy; 117 } 118 119 private static JbootApplicationConfig instance; 120 121 public static JbootApplicationConfig get() { 122 if (instance == null) { 123 instance = JbootConfigManager.me().get(JbootApplicationConfig.class); 124 } 125 return instance; 126 } 127 128 @Override 129 public String toString() { 130 return "JbootApplication {" + 131 " name='" + name + '\'' + 132 ", mode='" + mode + '\'' + 133 ", version='" + version + '\'' + 134 ", proxy='" + getProxy() + '\'' + 135// ", config='" + jfinalConfig + '\'' + 136 ", listener='" + listener + '\'' + 137 ", listenerPackage='" + listenerPackage + '\'' + 138 " }"; 139 } 140}