Skip to content

Commit

Permalink
Minor updates related to configs.
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshk15 committed Oct 24, 2016
1 parent 7c2a595 commit dc93d9a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static void launchBrowser(URL url) throws IOException {
} else if (isWindows()) {
Runtime.getRuntime().exec(WIN_BROWSER_LAUNCH_CMD + url);
} else if (isUnix()) {
String[] browsers = Configs.INSTANCE.main().getString(KEY_BROWSERS).split(REGEX_COMMA);
String[] browsers = Configs.INSTANCE.common().getString(KEY_BROWSERS).split(REGEX_COMMA);
StringBuilder cmdBuilder = new StringBuilder();
int index = OFFSET;
for (String browser : browsers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public final class Constants {
public static final String PROVISIONING_FILE = "provisioning";

public static final String MAIN_CONF_SECTION = "main";

public static final String UNDERTOW_CONF_SECTION = "undertow";

public static final String FELIX_CONF_SECTION = "felix";

public static final String COMMON_CONF_SECTION = "common";

public static final String CONTEXT_PATH = "/";

Expand Down Expand Up @@ -82,7 +88,7 @@ public final class Constants {

// Configuration Keys constants start.

public static final String KEY_BROWSERS = "common.browsers";
public static final String KEY_BROWSERS = "browsers";

public static final String KEY_HOST = "host";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public class LogbackProvisioner {

private static final String KEY_LOG_MAX_SIZE = "log-max-size";

private static final String CONF_COMMON = "common";

private static final String HYPHEN = "-";

private static final String EXTN_LOG = ".log";
Expand All @@ -78,7 +76,7 @@ public class LogbackProvisioner {
public static void start() {
long startNanos = System.nanoTime();
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
Config commonConf = Configs.INSTANCE.main().getConfig(CONF_COMMON);
Config commonConf = Configs.INSTANCE.common();
// Console Appender
ConsoleAppender<ILoggingEvent> consoleAppender = consoleAppender(context, commonConf);
// File Appender
Expand Down
23 changes: 18 additions & 5 deletions src/main/java/com/adeptj/modularweb/micro/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
*/
package com.adeptj.modularweb.micro.config;

import com.adeptj.modularweb.micro.common.Constants;
import static com.adeptj.modularweb.micro.common.Constants.COMMON_CONF_SECTION;
import static com.adeptj.modularweb.micro.common.Constants.FELIX_CONF_SECTION;
import static com.adeptj.modularweb.micro.common.Constants.MAIN_CONF_SECTION;
import static com.adeptj.modularweb.micro.common.Constants.PROVISIONING_FILE;
import static com.adeptj.modularweb.micro.common.Constants.UNDERTOW_CONF_SECTION;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;

Expand All @@ -35,10 +40,18 @@ public enum Configs {
private final Config main;

Configs() {
this.main = ConfigFactory.load(Constants.PROVISIONING_FILE).getConfig(Constants.MAIN_CONF_SECTION);
this.main = ConfigFactory.load(PROVISIONING_FILE).getConfig(MAIN_CONF_SECTION);
}

public Config main() {
return main;

public Config undertow() {
return this.main.getConfig(UNDERTOW_CONF_SECTION);
}

public Config felix() {
return this.main.getConfig(FELIX_CONF_SECTION);
}

public Config common() {
return this.main.getConfig(COMMON_CONF_SECTION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private Framework createFramework(Logger logger) throws Exception {

private Map<String, String> createFrameworkConfigs(Logger logger) throws IOException {
Map<String, String> configs = this.loadFrameworkProps();
Config felixConf = Configs.INSTANCE.main().getConfig("felix");
Config felixConf = Configs.INSTANCE.felix();
configs.put("felix.cm.dir", felixConf.getString("felix-cm-dir"));
configs.put("felix.memoryusage.dump.location", felixConf.getString("memoryusage-dump-loc"));
logger.debug("OSGi Framework Configurations: {}", configs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private UndertowProvisioner() {}
private static final String PROTOCOL_TLS = "TLS";

public static void provision(Map<String, String> arguments) throws Exception {
Config undertowConf = Configs.INSTANCE.main().getConfig("undertow");
Config undertowConf = Configs.INSTANCE.undertow();
Config httpConf = undertowConf.getConfig(KEY_HTTP);
Logger logger = LoggerFactory.getLogger(UndertowProvisioner.class);
int port = getPort(httpConf, logger);
Expand Down

0 comments on commit dc93d9a

Please sign in to comment.