本文整理了Java中com.networknt.config.Config.getInstance()
方法的一些代码示例,展示了Config.getInstance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.getInstance()
方法的具体详情如下:
包路径:com.networknt.config.Config
类名称:Config
方法名:getInstance
暂无
代码示例来源:origin: networknt/light-4j
private static TokenResponse handleResponse(String responseBody) {
TokenResponse tokenResponse = null;
try {
if (responseBody != null && responseBody.length() > 0) {
tokenResponse = Config.getInstance().getMapper().readValue(responseBody, TokenResponse.class);
} else {
logger.error("Error in token retrieval, response = " + responseBody);
}
} catch (IOException | RuntimeException e) {
logger.error("Error in token retrieval", e);
}
return tokenResponse;
}
代码示例来源:origin: networknt/light-4j
private static KeyStore loadKeyStore() {
String name = config.getKeystoreName();
try (InputStream stream = Config.getInstance().getInputStreamFromFile(name)) {
KeyStore loadedKeystore = KeyStore.getInstance("JKS");
loadedKeystore.load(stream, ((String) secret.get(SecretConstants.SERVER_KEYSTORE_PASS)).toCharArray());
return loadedKeystore;
} catch (Exception e) {
logger.error("Unable to load keystore " + name, e);
throw new RuntimeException("Unable to load keystore " + name, e);
}
}
代码示例来源:origin: networknt/light-4j
protected static KeyStore loadTrustStore() {
String name = config.getTruststoreName();
try (InputStream stream = Config.getInstance().getInputStreamFromFile(name)) {
KeyStore loadedKeystore = KeyStore.getInstance("JKS");
loadedKeystore.load(stream, ((String) secret.get(SecretConstants.SERVER_TRUSTSTORE_PASS)).toCharArray());
return loadedKeystore;
} catch (Exception e) {
logger.error("Unable to load truststore " + name, e);
throw new RuntimeException("Unable to load truststore " + name, e);
}
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
// As passwords are in the config file, we need to mask them.
List<String> masks = new ArrayList<>();
masks.add("");
ModuleRegistry.registerModule(BasicAuthHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(LimitHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(MetricsHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(SanitizerHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(TraceabilityHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(ExceptionHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(CorrelationHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(HeaderHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(BodyHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(DumpHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(RequestDecodeHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(RequestDecodeConfig.CONFIG_NAME), null);
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(ContentConfig.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
代码示例来源:origin: networknt/light-4j
@Override
public void register() {
ModuleRegistry.registerModule(CorsHttpHandler.class.getName(), Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME), null);
}
代码示例来源:origin: networknt/light-4j
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
exchange.getResponseHeaders().put(
Headers.CONTENT_TYPE, "application/json");
Map<String, Object> resMap = new HashMap<>();
resMap.put("access_token", JwtIssuer.getJwt(mockClaims()));
resMap.put("token_type", "bearer");
resMap.put("expires_in", 600);
exchange.getResponseSender().send(ByteBuffer.wrap(
Config.getInstance().getMapper().writeValueAsBytes(
resMap)));
}
代码示例来源:origin: networknt/light-4j
static void setConfig(String configName) throws Exception {
Handler.configName = configName;
config = (HandlerConfig) Config.getInstance().getJsonObjectConfig(configName, HandlerConfig.class);
initHandlers();
initPaths();
}
}
代码示例来源:origin: networknt/light-4j
public VirtualHostHandler() {
VirtualHostConfig config = (VirtualHostConfig)Config.getInstance().getJsonObjectConfig(VirtualHostConfig.CONFIG_NAME, VirtualHostConfig.class);
virtualHostHandler = new NameVirtualHostHandler();
for(VirtualHost host: config.hosts) {
virtualHostHandler.addHost(host.domain, new PathHandler().addPrefixPath(host.getPath(), new ResourceHandler((new PathResourceManager(Paths.get(host.getBase()), host.getTransferMinSize()))).setDirectoryListingEnabled(host.isDirectoryListingEnabled())));
}
}
代码示例来源:origin: networknt/light-4j
public PathResourceHandler() {
PathResourceConfig config = (PathResourceConfig)Config.getInstance().getJsonObjectConfig(PathResourceConfig.CONFIG_NAME, PathResourceConfig.class);
if(config.isPrefix()) {
pathHandler = new PathHandler()
.addPrefixPath(config.getPath(), new ResourceHandler(new PathResourceManager(Paths.get(config.getBase()), config.getTransferMinSize()))
.setDirectoryListingEnabled(config.isDirectoryListingEnabled()));
} else {
pathHandler = new PathHandler()
.addExactPath(config.getPath(), new ResourceHandler(new PathResourceManager(Paths.get(config.getBase()), config.getTransferMinSize()))
.setDirectoryListingEnabled(config.isDirectoryListingEnabled()));
}
}
内容来源于网络,如有侵权,请联系作者删除!