本文整理了Java中org.kaazing.gateway.util.Utils.parseTimeInterval()
方法的一些代码示例,展示了Utils.parseTimeInterval()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.parseTimeInterval()
方法的具体详情如下:
包路径:org.kaazing.gateway.util.Utils
类名称:Utils
方法名:parseTimeInterval
暂无
代码示例来源:origin: kaazing/gateway
static int getHttpKeepaliveTimeout(String httpKeepaliveTimeoutValue) {
int httpKeepaliveTimeout = DEFAULT_HTTP_KEEPALIVE_TIMEOUT;
if (httpKeepaliveTimeoutValue != null) {
long val = Utils.parseTimeInterval(httpKeepaliveTimeoutValue, SECONDS);
if (val > 0) {
httpKeepaliveTimeout = (int) val;
}
}
return httpKeepaliveTimeout;
}
代码示例来源:origin: kaazing/gateway
static long getWsInactivityTimeout(String value) {
long wsInactivityTimeout = DEFAULT_WS_INACTIVITY_TIMEOUT_MILLIS;
if (value != null) {
long val = Utils.parseTimeInterval(value, MILLISECONDS);
if (val > 0) {
wsInactivityTimeout = val;
}
}
return wsInactivityTimeout;
}
代码示例来源:origin: kaazing/gateway
public static long parseTimeInterval(String timeIntervalValue, TimeUnit outputUnit) {
return parseTimeInterval(timeIntervalValue, outputUnit, 0);
}
代码示例来源:origin: kaazing/gateway
/**
* @param timeIntervalValue - The value to be parsed
* @param outputUnit - The value will be converted to this unit
* @param defaultValue - The default value in seconds
* @return
*/
public static long parseTimeInterval(String timeIntervalValue, TimeUnit outputUnit, long defaultValue) {
return parseTimeInterval(timeIntervalValue, outputUnit, String.valueOf(defaultValue) + "seconds");
}
代码示例来源:origin: kaazing/gateway
private String resolveTimeIntervalValue(String value) {
final long l = Utils.parseTimeInterval(value, TimeUnit.SECONDS, 0);
if (l == 0) {
return null;
}
return String.valueOf(l);
}
代码示例来源:origin: kaazing/gateway
private Long readOption(Map<String, ?> options, final String key) {
final String timeIntervalValue = (String) options.get(key);
if (timeIntervalValue == null) {
return null;
} else {
try {
return Utils.parseTimeInterval(timeIntervalValue, TimeUnit.SECONDS);
} catch (NumberFormatException e) {
LOGGER.error("[TimeoutLoginModule] Cannot determine the value for {}", key, e);
throw e;
}
}
}
代码示例来源:origin: kaazing/gateway
/** Adds a directive with the associated value to the directives map, after parsing the value from the configuration file
* @param directiveName
* @param directiveValue
*/
private void parseDirectiveWithValue(String directiveName, String directiveValue) {
Directive directive;
if (directiveName.equals(Directive.MAX_AGE.getName())) {
if (directiveValue.startsWith(M_PLUS_STRING)) {
directiveValue = directiveValue.replace(M_PLUS_STRING, EMPTY_STRING_VALUE);
directive = Directive.MAX_AGE_MPLUS;
} else {
directive = Directive.MAX_AGE;
}
} else {
directive = Directive.get(directiveName);
}
long value = Utils.parseTimeInterval(directiveValue, TimeUnit.SECONDS, 0);
directives.put(directive, Long.toString(value));
}
代码示例来源:origin: kaazing/gateway
private long getCloseTimeout(Properties configuration) {
String timeoutConfig = WS_CLOSE_TIMEOUT.getProperty(configuration);
// The Utils.parseTimeInterval() method Does The Right Thing(tm) if
// there is no property value configured for the given property name;
// that's why we provide a default string parameter.
long timeout = Utils.parseTimeInterval(timeoutConfig, TimeUnit.MILLISECONDS);
if (timeout <= 0) {
throw new IllegalArgumentException(format("%s property value \"%s\" is invalid, must be positive",
WS_CLOSE_TIMEOUT.getPropertyName(), timeout));
}
if (logger.isTraceEnabled()) {
logger.trace(format("Using %s property of %d milliseconds for CLOSE frame timeouts",
WS_CLOSE_TIMEOUT.getPropertyName(), timeout));
}
return timeout;
}
代码示例来源:origin: kaazing/gateway
outputUnit = outputUnit == null ? TimeUnit.SECONDS : outputUnit;
if (timeIntervalValue == null) {
return parseTimeInterval(defaultValue, outputUnit, 0);
return parseTimeInterval(String.valueOf(timeIntervalValue), TimeUnit.SECONDS, 0);
代码示例来源:origin: kaazing/gateway
transportSession = new TransportSession(this, processor);
transportSession.setHandler(transportHandler);
closeTimeout = Utils.parseTimeInterval(WS_CLOSE_TIMEOUT.getProperty(configuration), TimeUnit.MILLISECONDS);
代码示例来源:origin: org.kaazing/gateway.service.turn.rest
@Override
public void init(ServiceContext serviceContext) throws Exception {
this.serviceContext = serviceContext;
EarlyAccessFeatures.TURN_REST_SERVICE.assertEnabled(getConfiguration(), serviceContext.getLogger());
ServiceProperties properties = serviceContext.getProperties();
String urls = properties.get("url");
TurnRestCredentialsGenerator credentialGeneratorInstance = setUpCredentialsGenerator(properties);
long ttl = Utils.parseTimeInterval(properties.get("credentials.ttl"), TimeUnit.SECONDS, DEFAULT_CREDENTIALS_TTL);
handler = new TurnRestServiceHandler(Long.toString(ttl), credentialGeneratorInstance, urls);
}
代码示例来源:origin: kaazing/gateway
@Override
public void init(ServiceContext serviceContext) throws Exception {
this.serviceContext = serviceContext;
EarlyAccessFeatures.TURN_REST_SERVICE.assertEnabled(getConfiguration(), serviceContext.getLogger());
ServiceProperties properties = serviceContext.getProperties();
String urls = properties.get("url");
TurnRestCredentialsGenerator credentialGeneratorInstance = setUpCredentialsGenerator(properties);
long ttl = Utils.parseTimeInterval(properties.get("credentials.ttl"), TimeUnit.SECONDS, DEFAULT_CREDENTIALS_TTL);
handler = new TurnRestServiceHandler(Long.toString(ttl), credentialGeneratorInstance, urls);
}
内容来源于网络,如有侵权,请联系作者删除!