当前位置: 首页>>代码示例>>Java>>正文


Java Option类代码示例

本文整理汇总了Java中org.xnio.Option的典型用法代码示例。如果您正苦于以下问题:Java Option类的具体用法?Java Option怎么用?Java Option使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Option类属于org.xnio包,在下文中一共展示了Option类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveOption

import org.xnio.Option; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public OptionMap.Builder resolveOption(final ExpressionResolver context, final ModelNode model, OptionMap.Builder builder) throws OperationFailedException {
    ModelNode value = resolveModelAttribute(context, model);
    if (value.isDefined()) {
        if (getType() == ModelType.INT) {
            builder.set((Option<Integer>) option, value.asInt());
        } else if (getType() == ModelType.LONG) {
            builder.set(option, value.asLong());
        } else if (getType() == ModelType.BOOLEAN) {
            builder.set(option, value.asBoolean());
        } else if (optionType.isEnum()) {
            builder.set(option, option.parseValue(value.asString(), option.getClass().getClassLoader()));
        }else if (option.getClass().getSimpleName().equals("SequenceOption")) {
            builder.setSequence(option, value.asString().split("\\s*,\\s*"));
        } else if (getType() == ModelType.STRING) {
            builder.set(option, value.asString());
        } else {
            throw new OperationFailedException("Don't know how to handle: " + option + " with value: " + value);
        }
    }
    return builder;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:OptionAttributeDefinition.java

示例2: setUp

import org.xnio.Option; //导入依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void setUp() {
  sut = new Application();
  builder = mock(Undertow.Builder.class);
  when(builder.setServerOption(any(Option.class), any())).thenReturn(builder);
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:8,代码来源:ApplicationTest.java

示例3: testCustomize

import org.xnio.Option; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testCustomize() {
  sut.customize(builder);
  verify(builder, times(2)).setServerOption(any(Option.class), any());
  verify(builder, times(1)).addHttpListener(0, "0.0.0.0");
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:8,代码来源:ApplicationTest.java

示例4: setOption

import org.xnio.Option; //导入依赖的package包/类
@Override
public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException {
    T ret = super.setOption(option, value);
    if (option == Options.READ_TIMEOUT) {
        readTimeout = (Integer) value;
        if (handle != null) {
            handle.remove();
            if (readTimeout > 0) {
                getReadThread().executeAfter(timeoutCommand, readTimeout, TimeUnit.MILLISECONDS);
            }
        }
    }
    return ret;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:ReadTimeoutStreamSourceChannel.java

示例5: setOption

import org.xnio.Option; //导入依赖的package包/类
@Override
public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException {
    T ret = super.setOption(option, value);
    if (option == Options.WRITE_TIMEOUT) {
        writeTimeout = (Integer) value;
        if (handle != null) {
            handle.remove();
            if(writeTimeout > 0) {
                getWriteThread().executeAfter(timeoutCommand, writeTimeout, TimeUnit.MILLISECONDS);
            }
        }
    }
    return ret;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:WriteTimeoutStreamSinkChannel.java

示例6: getOption

import org.xnio.Option; //导入依赖的package包/类
@Override
public <T> T getOption(final Option<T> option) throws IOException {
    if (isFinished()) {
        throw UndertowMessages.MESSAGES.channelIsClosed();
    }
    return delegate.getOption(option);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:DetachableStreamSinkChannel.java

示例7: setOption

import org.xnio.Option; //导入依赖的package包/类
@Override
public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException {
    if (isFinished()) {
        throw UndertowMessages.MESSAGES.channelIsClosed();
    }
    return delegate.setOption(option, value);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:DetachableStreamSinkChannel.java

示例8: setOption

import org.xnio.Option; //导入依赖的package包/类
public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException {

        if (isFinished()) {
            throw UndertowMessages.MESSAGES.channelIsClosed();
        }
        return delegate.setOption(option, value);
    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:DetachableStreamSourceChannel.java

示例9: toOption

import org.xnio.Option; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> Option<T> toOption(String name, Logger logger) {
    Option<T> option = null;
    try {
        option = Option.class.cast(UndertowOptions.class.getField(name).get(null));
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
        logger.error("Exception while accessing field: [{}]", name, ex);
    }
    return option;
}
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:11,代码来源:ServerOptions.java

示例10: createOptionAttribute

import org.xnio.Option; //导入依赖的package包/类
private static OptionAttributeDefinition createOptionAttribute(String name, Option<?> option, ModelNode defaultValue) {
    OptionAttributeDefinition.Builder builder = OptionAttributeDefinition.builder(name, option)
            .setAllowExpression(true)
            .setAttributeGroup(ENDPOINT)
            .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES);
    if (defaultValue != null) {
        builder = builder.setDefaultValue(defaultValue);
    }
    return builder.build();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:11,代码来源:RemotingSubsystemRootResource.java

示例11: addOptions

import org.xnio.Option; //导入依赖的package包/类
private static void addOptions(OperationContext context, ModelNode properties, OptionMap.Builder builder) throws OperationFailedException {
    final ClassLoader loader = WildFlySecurityManager.getClassLoaderPrivileged(ConnectorUtils.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));
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:ConnectorUtils.java

示例12: addOption

import org.xnio.Option; //导入依赖的package包/类
public Builder addOption(Option<?> option, String name, ModelNode defaultValue, boolean allowExpression, boolean allowNull) {
    attributes.add(OptionAttributeDefinition.builder(name, option)
            .setDefaultValue(defaultValue)
            .setAllowExpression(allowExpression)
            .setRequired(!allowNull)
            .build()
    );
    return this;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:OptionList.java

示例13: getTypeName

import org.xnio.Option; //导入依赖的package包/类
/**
 *
 * @return - returns Option type as String
 * Currently, only Options in UndertowOptions are supported
 */
private String getTypeName(String parameter) {
    try {
        Field field = UndertowOptions.class.getDeclaredField(parameter);
        if (Option.class.getName().equals(field.getType().getTypeName())) {
            Object value = field.get(null);
            Field optionField = value.getClass().getDeclaredField("type");
            optionField.setAccessible(true);
            return optionField.get(value).toString();
        }
    } catch (Exception e) {
        log.debug("getting Option type for parameter {} failed with {}", parameter, e);
    }
    return null;
}
 
开发者ID:decebals,项目名称:pippo,代码行数:20,代码来源:UndertowSettings.java

示例14: addUndertowOption

import org.xnio.Option; //导入依赖的package包/类
private <T> void addUndertowOption(Undertow.Builder builder, Option<T> option, T value, String prefix) {
    switch (prefix) {
        case UNDERTOW_SERVER_PREFIX:
            builder.setServerOption(option, value);
            break;
        case UNDERTOW_SOCKET_PREFIX:
            builder.setSocketOption(option, value);
            break;
        case UNDERTOW_WORKER_PREFIX:
            builder.setWorkerOption(option, value);
            break;
        default:
            break;
    }
}
 
开发者ID:decebals,项目名称:pippo,代码行数:16,代码来源:UndertowSettings.java

示例15: setOption

import org.xnio.Option; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private static Consumer<Map.Entry<String, ConfigValue>> setOption(final Config config,
    final String level,
    final BiConsumer<Option, Object> setter) {
  return entry -> {
    String name = entry.getKey();
    Object value = entry.getValue().unwrapped();
    Option option = findOption(name, UndertowOptions.class, Options.class);
    if (option != null) {
      // parse option to adjust correct type
      Object parsedValue = value.toString();
      try {
        parsedValue = option.parseValue(value.toString(), null);
      } catch (NumberFormatException ex) {
        // try bytes
        try {
          parsedValue = option.parseValue(config.getBytes(level + "." + name).toString(), null);
        } catch (ConfigException.BadValue badvalue) {
          // try duration
          parsedValue = option.parseValue(
              config.getDuration(level + "." + name, TimeUnit.MILLISECONDS) + "", null);
        }
      }
      log.debug("{}.{}({})", level, option.getName(), parsedValue);
      setter.accept(option, parsedValue);
    } else {
      log.error("Unknown option: 'undertow.{}.{} = {}'", level, name, value);
    }
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:31,代码来源:UndertowServer.java


注:本文中的org.xnio.Option类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。