public SocketOptionsConfig toConfig() { return new SocketOptionsConfig(connectTimeout != null ? connectTimeout : 0, soTimeout != null ? soTimeout : 0, keepAlive != null ? keepAlive : false, sendBufferSize != null ? sendBufferSize : 0, receiveBufferSize != null ? receiveBufferSize : 0); } }
@Override public String getName() { return config.getName(); }
public static void notNull(final Object xbean, final String name, final Object value) { if (value == null) { throw new ConfigurationException("Element \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } }
public InputConfig toConfig() { if (isTemplate()) { throw new ConfigurationException("Tried to use abstract bean \"" + getName() + "\""); } validate(); return createConfig(); }
@Override public SharedResource getSharedResource(final String name) { final SharedResource result = sharedResources.get(name); if (result == null) { throw new ConfigurationException("Shared resource \"" + name + "\" not found"); } return result; }
@Override public Sampler newSampler(final SamplerConfig config) { for (final LocalObjectFactory factory : objectFactories) { try { if (factory.supportsSampler(config)) { return factory.newSampler(config); } } catch (final RuntimeException e) { throw new ConfigurationException("Failed to create sampler \"" + config.getName() + "\"", e); } } throw new ConfigurationException("Unsupported sampler: " + config); }
private void applyPostProcessing(XBean bean) { try { for (final XBeanPostProcessor postProcessor : xbeanPostProcessors) { postProcessor.postProcessAfterLoad(bean); } } catch (IllegalAccessException|InvocationTargetException|NoSuchMethodException e) { throw new ConfigurationException("Failed to execute post processors", e); } }
@Override protected SharedResourceConfig createConfig() { final int coreSize = getSize(); final int maxSize = getMaxSize() != null ? getMaxSize() : -1; final int keepAliveTime = getKeepAliveTime() != null ? getKeepAliveTime() : -1; return new ThreadPoolConfig(getName(), isIgnored(), coreSize, maxSize, keepAliveTime); }
public HttpConnectionPoolConfig toConfig() { return new HttpConnectionPoolConfig( getMaxPerRoute() != null ? getMaxPerRoute() : 0, getMaxTotal() != null ? getMaxTotal() : 0, getTimeToLive() != null ? getTimeToLive() : 0 ); } }
protected RequestConfig.Builder setupDefaultRequestConfig() { final RequestConfig.Builder result = RequestConfig.custom(); if (config.getSocketOptions() != null) { return result.setConnectTimeout(config.getSocketOptions().getConnectTimeout()); } else { return result; } }
public static void greaterThanZero(final Object xbean, final String name, final Integer value) { if (value == null) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } if (value < 1) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid number greater than 0"); } }
@Override public MetricsWriter newWriterForOutput(final OutputConfig config) { for (final LocalObjectFactory factory : objectFactories) { if (factory.supportsOutput(config)) { return factory.newWriterForOutput(config); } } throw new ConfigurationException("Unsupported output: " + config); }
@Override public Sampler newSampler(final SamplerConfig config) { for (final LocalObjectFactory factory : objectFactories) { try { if (factory.supportsSampler(config)) { return factory.newSampler(config); } } catch (final RuntimeException e) { throw new ConfigurationException("Failed to create sampler \"" + config.getName() + "\"", e); } } throw new ConfigurationException("Unsupported sampler: " + config); }
protected RequestConfig.Builder setupDefaultRequestConfig() { final RequestConfig.Builder result = RequestConfig.custom(); if (config.getSocketOptions() != null) { return result.setConnectTimeout(config.getSocketOptions().getConnectTimeout()); } else { return result; } }
public SocketOptionsConfig toConfig() { return new SocketOptionsConfig(connectTimeout != null ? connectTimeout : 0, soTimeout != null ? soTimeout : 0, keepAlive != null ? keepAlive : false, sendBufferSize != null ? sendBufferSize : 0, receiveBufferSize != null ? receiveBufferSize : 0); } }
@Override public String getName() { return config.getName(); }
public static void validPort(final Object xbean, final String name, final Integer value) { if (value == null) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } if (value < 1 || value > 65535) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid port in range [1,65535]"); } }
@Override public ValueTransformer newValueTransformer(final ValueTransformerConfig config) { for (final LocalObjectFactory factory : objectFactories) { if (factory.supportsValueTransformer(config)) { return factory.newValueTransformer(config); } } throw new ConfigurationException("Unsupported value transformer: " + config); }
public static void notNegative(final Object xbean, final String name, final Integer value) { if (value == null) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " is mandatory"); } if (value < 0) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid number greater than or equal to 0"); } }
public static void notNegativeOptional(final Object xbean, final String name, final Integer value) { if (value != null) { if (value < 0) { throw new ConfigurationException("Attribute \"" + name + "\" of " + determineBeanName(xbean) + " with value " + value + " is not a valid number greater than or equal to 0"); } } }