本文整理了Java中io.helidon.config.Config.asNodeList()
方法的一些代码示例,展示了Config.asNodeList()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.asNodeList()
方法的具体详情如下:
包路径:io.helidon.config.Config
类名称:Config
方法名:asNodeList
[英]Returns a list of child Config nodes if the node is Type#OBJECT. Returns a list of element nodes if the node is Type#LIST. Throws MissingValueException if the node is Type#MISSING. Otherwise, if node is Type#VALUE, it throws ConfigMappingException.
[中]如果节点类型为#OBJECT,则返回子配置节点的列表。如果节点类型为#list,则返回元素节点列表。如果节点类型#缺失,则引发MissingValueException。否则,如果节点的类型为#VALUE,则会抛出ConfigMappingException。
代码示例来源:origin: oracle/helidon
private void findProviderSpecificConfig(Config pConf, AtomicReference<Config> providerSpecific) {
// no service for this class, must choose the configuration by selection
pConf.asNodeList().get().stream().filter(this::notReservedProviderKey).forEach(providerSpecificConf -> {
if (!providerSpecific.compareAndSet(null, providerSpecificConf)) {
throw new SecurityException("More than one provider configurations found, each provider can only"
+ " have one provide specific config. Conflict: "
+ providerSpecific.get().key()
+ " and " + providerSpecificConf.key());
}
});
}
代码示例来源:origin: oracle/helidon
private Stream<Config> traverseSubNodes(Config config, Predicate<Config> predicate) {
if (config.type().isLeaf()) {
return Stream.of(config);
} else {
return config.asNodeList()
.map(list -> list.stream()
.filter(predicate)
.map(node -> traverseSubNodes(node, predicate))
.reduce(Stream.of(config), Stream::concat))
.orElseThrow(MissingValueException.createSupplier(key()));
}
}
代码示例来源:origin: oracle/helidon
private SecurityHandler(Builder builder) {
// must copy values to be safely immutable
this.rolesAllowed = builder.rolesAllowed.flatMap(strings -> {
Set<String> newRoles = new HashSet<>(strings);
return Optional.of(newRoles);
});
// must copy values to be safely immutable
this.customObjects = builder.customObjects.flatMap(store -> {
ClassToInstanceStore<Object> ctis = new ClassToInstanceStore<>();
ctis.putAll(store);
return Optional.of(ctis);
});
config = builder.config;
explicitAuthenticator = builder.explicitAuthenticator;
explicitAuthorizer = builder.explicitAuthorizer;
authenticate = builder.authenticate;
authenticationOptional = builder.authenticationOptional;
audited = builder.audited;
auditEventType = builder.auditEventType;
auditMessageFormat = builder.auditMessageFormat;
authorize = builder.authorize;
combined = builder.combined;
queryParamHandlers.addAll(builder.queryParamHandlers);
config.ifPresent(conf -> conf.asNodeList().get().forEach(node -> configMap.put(node.name(), node)));
}
代码示例来源:origin: oracle/helidon
private static Config findMyKey(Config rootConfig, String providerName) {
if (rootConfig.key().name().equals(providerName)) {
return rootConfig;
}
return rootConfig.get("security.providers")
.asNodeList()
.get()
.stream()
.filter(it -> it.get(providerName).exists())
.findFirst()
.map(it -> it.get(providerName))
.orElseThrow(() -> new SecurityException("No configuration found for provider named: " + providerName));
}
代码示例来源:origin: oracle/helidon
static <T> ConfigValue<List<T>> createList(Config config,
Function<Config, ConfigValue<T>> getValue,
Function<Config, ConfigValue<List<T>>> getListValue) {
Supplier<Optional<List<T>>> valueSupplier = () -> {
try {
return config.asNodeList()
.map(list -> list.stream()
.map(theConfig -> getValue.apply(theConfig).get())
.collect(Collectors.toList())
);
} catch (MissingValueException | ConfigMappingException ex) {
throw new ConfigMappingException(config.key(),
"Error to map complex node item to list. " + ex.getLocalizedMessage(),
ex);
}
};
return new GenericConfigValueImpl<>(config, valueSupplier, getListValue);
}
代码示例来源:origin: oracle/helidon
private void findProviderService(Map<String, SecurityProviderService> configKeyToService,
String knownKeys,
Config pConf,
AtomicReference<SecurityProviderService> service,
AtomicReference<Config> providerSpecific) {
// everything else is based on provider specific configuration
pConf.asNodeList().get().stream().filter(this::notReservedProviderKey).forEach(providerSpecificConf -> {
if (!providerSpecific.compareAndSet(null, providerSpecificConf)) {
throw new SecurityException("More than one provider configurations found, each provider can only"
+ " have one provider specific config. Conflict: "
+ providerSpecific.get().key()
+ " and " + providerSpecificConf.key());
}
String keyName = providerSpecificConf.name();
if (configKeyToService.containsKey(keyName)) {
service.set(configKeyToService.get(keyName));
} else {
throw new SecurityException("Configuration key " + providerSpecificConf.key()
+ " is not a valid provider configuration. Supported keys: "
+ knownKeys);
}
});
}
代码示例来源:origin: oracle/helidon
.asNodeList()
.orElse(CollectionsHelper.listOf())
.stream()
代码示例来源:origin: oracle/helidon
@Override
public void init(Config config) {
config.get(PROVIDER_NAME + ".auth-method-mapping")
.asNodeList()
.ifPresent(nl -> {
nl.forEach(conf -> {
conf.get("key").asString().ifPresent(key -> {
if (LOGIN_CONFIG_METHOD.equals(key)) {
authenticator = conf.get("provider")
.asString()
.orElse(authenticator);
}
});
});
});
}
代码示例来源:origin: oracle/helidon
/**
* Create an instance from config. Expects key "users" to be the current key.
* Example:
* <pre>
* users: [
* {
* login = "jack"
* password = "${CLEAR=password}"
* roles = ["user", "admin"]
* },
* {
* login = "jill"
* # master password is "jungle", password is "password"
* password = "${AES=3XQ8A1RszE9JbXl+lUnnsX0gakuqjnTyp8YJWIAU1D3SiM2TaSnxd6U0/LjrdJYv}"
* roles = ["user"]
* }
* ]
* </pre>
*
* @param config to load this user store from
* @return {@link UserStore} instance
*/
public static ConfigUserStore create(Config config) {
ConfigUserStore store = new ConfigUserStore();
config.asNodeList().ifPresent(configs -> configs.forEach(config1 -> {
User user = config1.as(ConfigUser::create).get();
store.users.put(user.login(), user);
}));
return store;
}
代码示例来源:origin: oracle/helidon
private void registerRouting(Routing.Rules routing) {
Config wsConfig = config.get("web-server");
SecurityHandler defaults = SecurityHandler.create(wsConfig.get("defaults"), defaultHandler);
wsConfig.get("paths").asNodeList().ifPresent(configs -> {
for (Config pathConfig : configs) {
List<Http.RequestMethod> methods = pathConfig.get("methods").asNodeList().orElse(listOf())
.stream()
.map(Config::asString)
.map(ConfigValue::get)
.map(Http.RequestMethod::create)
.collect(Collectors.toList());
String path = pathConfig.get("path")
.asString()
.orElseThrow(() -> new SecurityException(pathConfig
.key() + " must contain path key with a path to "
+ "register to web server"));
if (methods.isEmpty()) {
routing.any(path, SecurityHandler.create(pathConfig, defaults));
} else {
routing.anyOf(methods, path, SecurityHandler.create(pathConfig, defaults));
}
}
});
}
}
代码示例来源:origin: oracle/helidon
/**
* Load header configuration from config.
*
* @param config config instance, expecting object array as children
* @return signed headers configuration loaded from config
*/
public static SignedHeadersConfig create(Config config) {
Builder builder = builder();
config.asNodeList().get().forEach(methodConfig -> {
HeadersConfig mc = HeadersConfig.create(methodConfig);
methodConfig.get("method")
.asString()
.ifPresentOrElse(method -> builder.config(method, mc),
() -> builder.defaultConfig(mc));
});
return builder.build();
}
代码示例来源:origin: oracle/helidon
/**
* Update fields from configuration.
*
* @param config Configuration
* @return updated builder instance
*/
public Builder config(Config config) {
config.get("name").asString().ifPresent(this::name);
config.get("default").asBoolean().ifPresent(this::isDefault);
config.get("authentication").asList(FlaggedProvider::create)
.ifPresent(this.authenticators::addAll);
config.get("authorization").asList(FlaggedProvider::create)
.ifPresent(this.authorizers::addAll);
config.get("outbound").asNodeList()
.ifPresent(configs -> configs.forEach(outConfig -> addOutboundProvider(outConfig.get("name")
.asString()
.get())));
return this;
}
代码示例来源:origin: oracle/helidon
@Override
public ZipkinTracerBuilder config(Config config) {
config.get("service").asString().ifPresent(this::serviceName);
config.get("protocol").asString().ifPresent(this::collectorProtocol);
config.get("host").asString().ifPresent(this::collectorHost);
config.get("port").asInt().ifPresent(this::collectorPort);
config.get("path").asString().ifPresent(this::collectorPath);
config.get("api-version").asString().ifPresent(this::configApiVersion);
config.get("enabled").asBoolean().ifPresent(this::enabled);
config.get("tags").detach()
.asMap()
.orElseGet(CollectionsHelper::mapOf)
.forEach(this::addTracerTag);
config.get("boolean-tags")
.asNodeList()
.ifPresent(nodes -> {
nodes.forEach(node -> {
this.addTracerTag(node.key().name(), node.asBoolean().get());
});
});
config.get("int-tags")
.asNodeList()
.ifPresent(nodes -> {
nodes.forEach(node -> {
this.addTracerTag(node.key().name(), node.asInt().get());
});
});
return this;
}
代码示例来源:origin: oracle/helidon
for (Config socketConfig : socketsConfig.asNodeList().orElse(CollectionsHelper.listOf())) {
String socketName = socketConfig.name();
sockets.put(socketName, configureSocket(socketConfig, SocketConfiguration.builder()).build());
代码示例来源:origin: io.helidon.config/helidon-config
private Stream<Config> traverseSubNodes(Config config, Predicate<Config> predicate) {
if (config.type().isLeaf()) {
return Stream.of(config);
} else {
return config.asNodeList()
.map(list -> list.stream()
.filter(predicate)
.map(node -> traverseSubNodes(node, predicate))
.reduce(Stream.of(config), Stream::concat))
.orElseThrow(MissingValueException.createSupplier(key()));
}
}
代码示例来源:origin: io.helidon.security/helidon-security-integration-webserver
private SecurityHandler(Builder builder) {
// must copy values to be safely immutable
this.rolesAllowed = builder.rolesAllowed.flatMap(strings -> {
Set<String> newRoles = new HashSet<>(strings);
return Optional.of(newRoles);
});
// must copy values to be safely immutable
this.customObjects = builder.customObjects.flatMap(store -> {
ClassToInstanceStore<Object> ctis = new ClassToInstanceStore<>();
ctis.putAll(store);
return Optional.of(ctis);
});
config = builder.config;
explicitAuthenticator = builder.explicitAuthenticator;
explicitAuthorizer = builder.explicitAuthorizer;
authenticate = builder.authenticate;
authenticationOptional = builder.authenticationOptional;
audited = builder.audited;
auditEventType = builder.auditEventType;
auditMessageFormat = builder.auditMessageFormat;
authorize = builder.authorize;
combined = builder.combined;
queryParamHandlers.addAll(builder.queryParamHandlers);
config.ifPresent(conf -> conf.asNodeList().forEach(node -> configMap.put(node.name(), node)));
}
代码示例来源:origin: io.helidon.config/helidon-config
static <T> ConfigValue<List<T>> createList(Config config,
Function<Config, ConfigValue<T>> getValue,
Function<Config, ConfigValue<List<T>>> getListValue) {
Supplier<Optional<List<T>>> valueSupplier = () -> {
try {
return config.asNodeList()
.map(list -> list.stream()
.map(theConfig -> getValue.apply(theConfig).get())
.collect(Collectors.toList())
);
} catch (MissingValueException | ConfigMappingException ex) {
throw new ConfigMappingException(config.key(),
"Error to map complex node item to list. " + ex.getLocalizedMessage(),
ex);
}
};
return new GenericConfigValueImpl<>(config, valueSupplier, getListValue);
}
代码示例来源:origin: io.helidon.config/helidon-config
.asNodeList()
.orElse(CollectionsHelper.listOf())
.stream()
代码示例来源:origin: io.helidon.microprofile.jwt/helidon-microprofile-jwt-auth
@Override
public void init(Config config) {
config.get(PROVIDER_NAME + ".auth-method-mapping")
.asNodeList()
.ifPresent(nl -> {
nl.forEach(conf -> {
conf.get("key").asString().ifPresent(key -> {
if (LOGIN_CONFIG_METHOD.equals(key)) {
authenticator = conf.get("provider")
.asString()
.orElse(authenticator);
}
});
});
});
}
内容来源于网络,如有侵权,请联系作者删除!