use of org.nutz.ioc.impl.PropertiesProxy in project nutzboot by nutzam.
the class YamlConfigureLoader method init.
public void init() throws Exception {
String path = envHolder.get("nutz.boot.configure.properties_path", "application.yml");
try (InputStream ins = resourceLoader.get(path)) {
if (ins == null) {
throw new RuntimeException("yaml not found : " + path);
}
conf = new PropertiesProxy();
readYaml(ins);
}
}
use of org.nutz.ioc.impl.PropertiesProxy in project nutzboot by nutzam.
the class PropertiesConfigureLoader method init.
public void init() throws Exception {
// 首先, 确定一些从什么路径加载配置文件,默认值application.properties
String path = envHolder.get("nutz.boot.configure.properties_path", "application.properties");
// 另外,加载custom目录下的配置文件,与nutzcn一致
conf.setPaths("custom/");
// 加载application.properties
try (InputStream ins = resourceLoader.get(path)) {
if (ins != null) {
conf.load(Streams.utf8r(ins), false);
}
}
// 也许命令行里面指定了profile,需要提前load进来
PropertiesProxy tmp = new PropertiesProxy();
if (args != null) {
parseCommandLineArgs(tmp, args);
if (tmp.has("nutz.profiles.active")) {
conf.put("nutz.profiles.active", tmp.remove("nutz.profiles.active"));
}
}
if (allowCommandLineProperties) {
conf.putAll(System.getProperties());
}
// 加载指定profile,如果有的话
if (conf.has("nutz.profiles.active")) {
String profile = conf.get("nutz.profiles.active");
path = path.substring(0, path.lastIndexOf('.')) + "-" + profile + ".properties";
try (InputStream ins = resourceLoader.get(path)) {
if (ins != null) {
conf.load(Streams.utf8r(ins), false);
}
}
}
// 把命令行参数放进去
if (tmp.size() > 0) {
conf.putAll(tmp.toMap());
}
}
use of org.nutz.ioc.impl.PropertiesProxy in project nutzboot by nutzam.
the class SwaggerServletStarter method init.
public void init(ServletConfig config) throws ServletException {
PropertiesProxy conf = appContext.getConfigureLoader().get();
swagger = conf.makeDeep(Swagger.class, "swagger.conf.");
Info info = conf.makeDeep(Info.class, "swagger.info.");
swagger.setInfo(info);
HashSet<Class<?>> classes = new HashSet<>();
String pkgName = conf.get("swagger.resource.package", appContext.getPackage());
for (Class<?> klass : Scans.me().scanPackage(pkgName)) {
classes.add(klass);
}
Reader.read(swagger, classes);
}
Aggregations