com.networknt.config.Config.getJsonObjectConfig()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(220)

本文整理了Java中com.networknt.config.Config.getJsonObjectConfig()方法的一些代码示例,展示了Config.getJsonObjectConfig()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.getJsonObjectConfig()方法的具体详情如下:
包路径:com.networknt.config.Config
类名称:Config
方法名:getJsonObjectConfig

Config.getJsonObjectConfig介绍

暂无

代码示例

代码示例来源: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

@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
  ServerInfoConfig config = (ServerInfoConfig)Config.getInstance().getJsonObjectConfig(CONFIG_NAME, ServerInfoConfig.class);
  if(config.isEnableServerInfo()) {
    Map<String, Object> infoMap = new LinkedHashMap<>();
    infoMap.put("deployment", getDeployment());
    infoMap.put("environment", getEnvironment(exchange));
    infoMap.put("security", getSecurity());
    infoMap.put("specification", Config.getInstance().getJsonMapConfigNoCache("swagger"));
    infoMap.put("component", ModuleRegistry.getRegistry());
    exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json");
    exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(infoMap));
  } else {
    setExchangeStatus(exchange, STATUS_SERVER_INFO_DISABLED);
  }
}

代码示例来源: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()));
  }
}

代码示例来源:origin: com.networknt/eventuate-cdccore

public CdcKafkaConsumer(String subscriberId, BiConsumer<ConsumerRecord<String, String>, BiConsumer<Void, Throwable>> handler, List<String> topics, String bootstrapServers) {
 this.subscriberId = subscriberId;
 this.handler = handler;
 this.topics = topics;
 config = (KafkaConfig) Config.getInstance().getJsonObjectConfig(CONFIG_NAME, KafkaConfig.class);
 if (bootstrapServers!=null) {
  this.bootstrapServers = bootstrapServers;
 } else {
  this.bootstrapServers = config.getBootstrapServers();
 }
 System.out.println("kafka bootstrap services:" + this.bootstrapServers);
 consumerProperties = new Properties();
 consumerProperties.put("bootstrap.servers", this.bootstrapServers);
 consumerProperties.put("group.id", subscriberId);
 consumerProperties.put("enable.auto.commit", config.isEnableaAutocommit());
 //consumerProperties.put("auto.commit.interval.ms", "1000");
 consumerProperties.put("session.timeout.ms", config.getSessionTimeout());
 consumerProperties.put("key.deserializer", config.getKeyDeSerializer());
 consumerProperties.put("value.deserializer", config.getValueDeSerializer());
 consumerProperties.put("auto.offset.reset", config.getAutoOffsetreset());
}

代码示例来源:origin: com.networknt/handler

static void setConfig(String configName) throws Exception {
    Handler.configName = configName;
    config = (HandlerConfig) Config.getInstance().getJsonObjectConfig(configName, HandlerConfig.class);
    initHandlers();
    initPaths();
  }
}

代码示例来源:origin: networknt/light-rest-4j

@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
  SpecificationConfig config = (SpecificationConfig)Config.getInstance().getJsonObjectConfig(CONFIG_NAME, SpecificationConfig.class);
  final String payload = Config.getInstance().getStringFromFile(config.getFileName());
  exchange.getResponseHeaders().add(new HttpString("Content-Type"), config.getContentType());
  exchange.getResponseSender().send(payload);
}

相关文章