本文整理了Java中org.xnio.Option.fromString()
方法的一些代码示例,展示了Option.fromString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.fromString()
方法的具体详情如下:
包路径:org.xnio.Option
类名称:Option
方法名:fromString
[英]Get an option from a string name, using the given classloader. If the classloader is null, the bootstrap classloader will be used.
[中]使用给定的类加载器从字符串名称中获取选项。如果类加载器为空,将使用引导类加载器。
代码示例来源:origin: wildfly/wildfly
private OptionMap getOptionMap(final Map<String, ?> environment, final String prefix, final ClassLoader classLoader) {
OptionMap.Builder builder = OptionMap.builder();
builder.set(Options.SASL_POLICY_NOANONYMOUS, false);
for (String name : environment.keySet()) {
if (name.startsWith(prefix)) {
final String optionName = name.substring(prefix.length());
final Option<?> option = Option.fromString(optionName, classLoader);
final Object valueObj = environment.get(name);
if (valueObj != null) builder.parse(option, valueObj.toString(), classLoader);
}
}
return builder.getMap();
}
代码示例来源:origin: wildfly/wildfly
/**
* Add all options from a properties file. Finds all entries which start with a given prefix followed by '.';
* the remainder of the property key (after the prefix) is the option name, and the value is the option value.
*<p>If the prefix does not end with '.' character, a '.' will be appended to it before parsing.
*
* @param props the properties to read
* @param prefix the prefix
* @return this builder
*/
public Builder parseAll(Properties props, String prefix) {
if (! prefix.endsWith(".")) {
prefix = prefix + ".";
}
for (String name : props.stringPropertyNames()) {
if (name.startsWith(prefix)) {
final String optionName = name.substring(prefix.length());
try {
final Option<?> option = Option.fromString(optionName, getClass().getClassLoader());
parse(option, props.getProperty(name));
} catch (IllegalArgumentException e) {
optionParseMsg.invalidOptionInProperty(optionName, name, e);
}
}
}
return this;
}
代码示例来源:origin: wildfly/wildfly
/**
* Add all options from a properties file. Finds all entries which start with a given prefix followed by '.';
* the remainder of the property key (after the prefix) is the option name, and the value is the option value.
* <p>If the prefix does not end with '.' character, a '.' will be appended to it before parsing.
*
* @param props the properties to read
* @param prefix the prefix
* @param optionClassLoader the class loader to use to resolve option names
* @return this builder
*/
public Builder parseAll(Properties props, String prefix, ClassLoader optionClassLoader) {
if (! prefix.endsWith(".")) {
prefix = prefix + ".";
}
for (String name : props.stringPropertyNames()) {
if (name.startsWith(prefix)) {
final String optionName = name.substring(prefix.length());
try {
final Option<?> option = Option.fromString(optionName, optionClassLoader);
parse(option, props.getProperty(name), optionClassLoader);
} catch (IllegalArgumentException e) {
optionParseMsg.invalidOptionInProperty(optionName, name, e);
}
}
}
return this;
}
代码示例来源:origin: wildfly/wildfly
private OptionMap getOptionMapFromProperties(final Properties properties, final ClassLoader classLoader) {
final OptionMap.Builder optionMapBuilder = OptionMap.builder();
if (properties != null) for (final String propertyName : properties.stringPropertyNames()) {
try {
final Option<?> option = Option.fromString(propertyName, classLoader);
optionMapBuilder.parse(option, properties.getProperty(propertyName), classLoader);
} catch (IllegalArgumentException e) {
EjbLogger.DEPLOYMENT_LOGGER.failedToCreateOptionForProperty(propertyName, e.getMessage());
}
}
return optionMapBuilder.getMap();
}
代码示例来源:origin: wildfly/wildfly
private OptionMap createChannelOptionMap(final OperationContext context, final ModelNode channelCreationOptionsNode)
throws OperationFailedException {
final OptionMap optionMap;
if (channelCreationOptionsNode.isDefined()) {
final OptionMap.Builder optionMapBuilder = OptionMap.builder();
final ClassLoader loader = this.getClass().getClassLoader();
for (final Property optionProperty : channelCreationOptionsNode.asPropertyList()) {
final String name = optionProperty.getName();
final ModelNode propValueModel = optionProperty.getValue();
final String type = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_TYPE
.resolveModelAttribute(context, propValueModel).asString();
final String optionClassName = this.getClassNameForChannelOptionType(type);
final String fullyQualifiedOptionName = optionClassName + "." + name;
final Option option = Option.fromString(fullyQualifiedOptionName, loader);
final String value = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE
.resolveModelAttribute(context, propValueModel).asString();
optionMapBuilder.set(option, option.parseValue(value, loader));
}
optionMap = optionMapBuilder.getMap();
} else {
optionMap = OptionMap.EMPTY;
}
return optionMap;
}
代码示例来源:origin: wildfly/wildfly
private OptionMap getChannelCreationOptions(final OperationContext context) throws OperationFailedException {
// read the full model of the current resource
final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
final ModelNode channelCreationOptions = fullModel.get(EJB3SubsystemModel.CHANNEL_CREATION_OPTIONS);
if (channelCreationOptions.isDefined() && channelCreationOptions.asInt() > 0) {
final ClassLoader loader = this.getClass().getClassLoader();
final OptionMap.Builder builder = OptionMap.builder();
for (final Property optionProperty : channelCreationOptions.asPropertyList()) {
final String name = optionProperty.getName();
final ModelNode propValueModel = optionProperty.getValue();
final String type = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_TYPE.resolveModelAttribute(context,propValueModel).asString();
final String optionClassName = this.getClassNameForChannelOptionType(type);
final String fullyQualifiedOptionName = optionClassName + "." + name;
final Option option = Option.fromString(fullyQualifiedOptionName, loader);
final String value = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE.resolveModelAttribute(context, propValueModel).asString();
builder.set(option, option.parseValue(value, loader));
}
return builder.getMap();
}
return OptionMap.EMPTY;
}
代码示例来源:origin: wildfly/wildfly-core
static Option<?> getAndValidateOption(ClassLoader loader, String name) throws OperationFailedException {
if (!name.contains(".")) {
name = "org.xnio.Options." + name;
}
try {
return Option.fromString(name, loader);
} catch (IllegalArgumentException iae) {
throw RemotingLogger.ROOT_LOGGER.invalidOption(iae.getMessage());
}
}
代码示例来源:origin: org.wildfly/wildfly-naming-client
private OptionMap getOptionMap(final Map<String, ?> environment, final String prefix, final ClassLoader classLoader) {
OptionMap.Builder builder = OptionMap.builder();
builder.set(Options.SASL_POLICY_NOANONYMOUS, false);
for (String name : environment.keySet()) {
if (name.startsWith(prefix)) {
final String optionName = name.substring(prefix.length());
final Option<?> option = Option.fromString(optionName, classLoader);
final Object valueObj = environment.get(name);
if (valueObj != null) builder.parse(option, valueObj.toString(), classLoader);
}
}
return builder.getMap();
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
private OptionMap getOptionMap(final Map<String, ?> environment, final String prefix, final ClassLoader classLoader) {
OptionMap.Builder builder = OptionMap.builder();
builder.set(Options.SASL_POLICY_NOANONYMOUS, false);
for (String name : environment.keySet()) {
if (name.startsWith(prefix)) {
final String optionName = name.substring(prefix.length());
final Option<?> option = Option.fromString(optionName, classLoader);
final Object valueObj = environment.get(name);
if (valueObj != null) builder.parse(option, valueObj.toString(), classLoader);
}
}
return builder.getMap();
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Add all options from a properties file. Finds all entries which start with a given prefix followed by '.';
* the remainder of the property key (after the prefix) is the option name, and the value is the option value.
*<p>If the prefix does not end with '.' character, a '.' will be appended to it before parsing.
*
* @param props the properties to read
* @param prefix the prefix
* @return this builder
*/
public Builder parseAll(Properties props, String prefix) {
if (! prefix.endsWith(".")) {
prefix = prefix + ".";
}
for (String name : props.stringPropertyNames()) {
if (name.startsWith(prefix)) {
final String optionName = name.substring(prefix.length());
try {
final Option<?> option = Option.fromString(optionName, getClass().getClassLoader());
parse(option, props.getProperty(name));
} catch (IllegalArgumentException e) {
optionParseMsg.invalidOptionInProperty(optionName, name, e);
}
}
}
return this;
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Add all options from a properties file. Finds all entries which start with a given prefix followed by '.';
* the remainder of the property key (after the prefix) is the option name, and the value is the option value.
* <p>If the prefix does not end with '.' character, a '.' will be appended to it before parsing.
*
* @param props the properties to read
* @param prefix the prefix
* @param optionClassLoader the class loader to use to resolve option names
* @return this builder
*/
public Builder parseAll(Properties props, String prefix, ClassLoader optionClassLoader) {
if (! prefix.endsWith(".")) {
prefix = prefix + ".";
}
for (String name : props.stringPropertyNames()) {
if (name.startsWith(prefix)) {
final String optionName = name.substring(prefix.length());
try {
final Option<?> option = Option.fromString(optionName, optionClassLoader);
parse(option, props.getProperty(name), optionClassLoader);
} catch (IllegalArgumentException e) {
optionParseMsg.invalidOptionInProperty(optionName, name, e);
}
}
}
return this;
}
代码示例来源:origin: org.jboss.as/jboss-as-ejb3
protected static OptionMap getOptionMapFromProperties(final Properties properties, final ClassLoader classLoader) {
final OptionMap.Builder optionMapBuilder = OptionMap.builder();
for (final String propertyName : properties.stringPropertyNames()) {
try {
final Option<?> option = Option.fromString(propertyName, classLoader);
optionMapBuilder.parse(option, properties.getProperty(propertyName), classLoader);
} catch (IllegalArgumentException e) {
EjbLogger.EJB3_LOGGER.failedToCreateOptionForProperty(propertyName, e.getMessage());
}
}
return optionMapBuilder.getMap();
}
代码示例来源:origin: org.jboss.as/jboss-as-ejb3
private static OptionMap getOptionMapFromProperties(final Properties properties, final ClassLoader classLoader) {
final OptionMap.Builder optionMapBuilder = OptionMap.builder();
for (final String propertyName : properties.stringPropertyNames()) {
try {
final Option<?> option = Option.fromString(propertyName, classLoader);
optionMapBuilder.parse(option, properties.getProperty(propertyName), classLoader);
} catch (IllegalArgumentException e) {
EjbLogger.EJB3_LOGGER.failedToCreateOptionForProperty(propertyName, e.getMessage());
}
}
return optionMapBuilder.getMap();
}
}
代码示例来源:origin: org.jboss.as/jboss-as-remoting
private static void addOptions(OperationContext context, ModelNode properties, OptionMap.Builder builder) throws OperationFailedException {
final ClassLoader loader = SecurityActions.getClassLoader(ConnectorResource.class);
for (Property property : properties.asPropertyList()) {
String name = property.getName();
if (!name.contains(".")) {
name = "org.xnio.Options." + name;
}
final Option option = Option.fromString(name, loader);
String value = PropertyResource.VALUE.resolveModelAttribute(context, property.getValue()).asString();
builder.set(option, option.parseValue(value, loader));
}
}
代码示例来源:origin: org.jboss.as/jboss-as-ejb3
private OptionMap getChannelCreationOptions(final OperationContext context) throws OperationFailedException {
// read the full model of the current resource
final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
final ModelNode channelCreationOptions = fullModel.get(EJB3SubsystemModel.CHANNEL_CREATION_OPTIONS);
if (channelCreationOptions.isDefined() && channelCreationOptions.asInt() > 0) {
final ClassLoader loader = this.getClass().getClassLoader();
final OptionMap.Builder builder = OptionMap.builder();
for (final Property optionProperty : channelCreationOptions.asPropertyList()) {
final String name = optionProperty.getName();
final ModelNode propValueModel = optionProperty.getValue();
final String type = ChannelCreationOptionResource.CHANNEL_CREATION_OPTION_TYPE.resolveModelAttribute(context,propValueModel).asString();
final String optionClassName = this.getClassNameForChannelOptionType(type);
final String fullyQualifiedOptionName = optionClassName + "." + name;
final Option option = Option.fromString(fullyQualifiedOptionName, loader);
final String value = ChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE.resolveModelAttribute(context, propValueModel).asString();
builder.set(option, option.parseValue(value, loader));
}
return builder.getMap();
} else {
return OptionMap.EMPTY;
}
}
代码示例来源:origin: org.apache.camel/camel-undertow
Option option = Option.fromString(key, cl);
value = option.parseValue(value.toString(), cl);
LOG.trace("Parsed option {}={}", option.getName(), value);
代码示例来源:origin: wildfly/wildfly-core
Option<?> optionMechanismNames = Option.fromString("org.xnio.Options."+ Options.SASL_MECHANISMS.getName(), loader);
String[] mechanismNames = null;
if(connectorPropertiesOptionMap.contains(optionMechanismNames)) {
Option<?> optionPolicyNonanonymous = Option.fromString("org.xnio.Options."+ Options.SASL_POLICY_NOANONYMOUS.getName(), loader);
内容来源于网络,如有侵权,请联系作者删除!