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(); }
/** * 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; }
/** * 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; }
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(); }
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; }
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; }
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()); } }
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(); }
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(); }
/** * 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; }
/** * 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; }
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(); }
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(); } }
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)); } }
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; } }
Option option = Option.fromString(key, cl); value = option.parseValue(value.toString(), cl); LOG.trace("Parsed option {}={}", option.getName(), value);
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);