• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Series类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: handle

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
/**
 * Handles HTTP 3xx/4xx/5xx statuses
 */
public static ApplicationRuntimeException handle(Application app, String url, RestClientException ex) {

	// HTTP 5xx
	if(ex instanceof HttpServerErrorException) {
		HttpServerErrorException serverEx = ((HttpServerErrorException)ex);
		return new ApplicationRuntimeException(app, String.format("A server error happened while calling %s (HTTP %s)", url, serverEx.getRawStatusCode()));
	}
	// HTTP 4xx
	else if(ex instanceof HttpClientErrorException) {
		HttpClientErrorException clientEx = ((HttpClientErrorException)ex);
		return new ApplicationRuntimeException(app, String.format("Bad request on endpoint %s (HTTP %s)", url, clientEx.getRawStatusCode()));
	}
	// HTTP 3xx
	else if(ex instanceof HttpRedirectErrorException) {

		HttpRedirectErrorException redirectEx = ((HttpRedirectErrorException)ex);

		if(redirectEx.getStatusCode().series() == Series.REDIRECTION) {
			return new ApplicationRuntimeException(app, String.format("Endpoint %s is available but security might be enabled (HTTP %s)", url, redirectEx.getRawStatusCode() ));
		}
	}

	return handle(app, ex);
}
 
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:28,代码来源:RestTemplateErrorHandler.java


示例2: handleError

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
@Override
public void handleError(ClientHttpResponse response) throws IOException {
    HttpStatus statusCode = response.getStatusCode();
    if (statusCode.series() == Series.SERVER_ERROR) {
        handleServerErrors(statusCode);
    } else if (statusCode.series() == Series.CLIENT_ERROR) {
        handleClientErrors(response);
    }

    // if not otherwise handled, do default handling and wrap with UncategorizedApiException
    try {
        super.handleError(response);
    } catch (Exception e) {
        throw new UncategorizedApiException(TWITTER, "Error consuming Twitter REST API", e);
    }
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:17,代码来源:TwitterErrorHandler.java


示例3: getRestGrid

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
private Component getRestGrid(Collection<MetricsRest> metrics, Series httpSerie) {

		List<MetricsRest> metricsItems = metrics.stream()
													.filter(m -> m.valid() && m.getStatus().series() == httpSerie)
													.collect(Collectors.toList());

		if(metricsItems.isEmpty()) {
			return new Label("No requests");
		} else {
			Grid<MetricsRest> gridCache = new Grid<>(MetricsRest.class);
			gridCache.removeAllColumns();
			gridCache.addColumn(MetricsRest::getName).setCaption("Path").setExpandRatio(1);
			gridCache.addColumn(m -> m.getStatus() + " " + m.getStatus().getReasonPhrase()).setCaption("HTTP Status");
			gridCache.addColumn(MetricsRest::getValue).setCaption("Hits");
			gridCache.addColumn(MetricsRest::getLastResponseTime).setCaption("Last Response Time (ms)");

			gridCache.setItems(metricsItems);
			if(metricsItems.size() < 10) {
				gridCache.setHeightByRows(metricsItems.size());
			}
			gridCache.setWidth(100, Unit.PERCENTAGE);

			return gridCache;
		}
	}
 
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:26,代码来源:MetricsPage.java


示例4: doFilter

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
		throws IOException, ServletException
{
	HttpServletRequest request = (HttpServletRequest) servletRequest;
	HttpServletResponse response = (HttpServletResponse) servletResponse;

	chain.doFilter(request, response);

	if (HttpStatus.Series.valueOf(response.getStatus()) == Series.SUCCESSFUL)
	{
		return;
	}

	logger.warn("Status {} returned from {}", response.getStatus(), GlobalExceptionMapping.buildRequestInfo(request));
}
 
开发者ID:yonadev,项目名称:yona-server,代码行数:17,代码来源:ErrorLoggingFilter.java


示例5: getFinalStatus

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
private String getFinalStatus(HttpServletRequest request, String path, int status) {
	Object bestMatchingPattern = request
			.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
	if (bestMatchingPattern != null) {
		return fixSpecialCharacters(bestMatchingPattern.toString());
	}
	Series series = getSeries(status);
	if (Series.CLIENT_ERROR.equals(series) || Series.SERVER_ERROR.equals(series)
			|| Series.REDIRECTION.equals(series)) {
		return UNKNOWN_PATH_SUFFIX;
	}
	return path;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:MetricsFilter.java


示例6: getSeries

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
private Series getSeries(int status) {
	try {
		return HttpStatus.valueOf(status).series();
	}
	catch (Exception ex) {
		return null;
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:MetricsFilter.java


示例7: getFinalStatus

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
private String getFinalStatus(HttpServletRequest request, String path, int status) {
	Object bestMatchingPattern = request
			.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
	if (bestMatchingPattern != null) {
		return fixSpecialCharacters(bestMatchingPattern.toString());
	}
	Series series = getSeries(status);
	if (Series.CLIENT_ERROR.equals(series) || Series.REDIRECTION.equals(series)) {
		return UNKNOWN_PATH_SUFFIX;
	}
	return path;
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:13,代码来源:MetricsFilter.java


示例8: getSeries

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
private Series getSeries(int status) {
	try {
		return HttpStatus.valueOf(status).series();
	}
	catch (Exception ex) {
		return null;
	}

}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:10,代码来源:MetricsFilter.java


示例9: hasError

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
public boolean hasError(ClientHttpResponse response) throws IOException {
  HttpStatus statusCode = response.getStatusCode();
  if(statusCode == HttpStatus.NOT_FOUND) {
    return false;
  }
  
  return statusCode.series() == Series.CLIENT_ERROR || 
         statusCode.series() == Series.SERVER_ERROR;
}
 
开发者ID:liuxianqiang,项目名称:spring-in-action,代码行数:10,代码来源:CustomErrorHandler.java


示例10: enter

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
@Override
public void enter(ViewChangeEvent event) {
	pageHelper.setErrorHandler(this);

	this.removeAllComponents();

	// Get application
	int appId = Integer.parseInt(event.getParameters());
	Application app = pageHelper.getApp(appId);

	// Get metrics
	Health health = healthService.getHealth(app);
	Optional<Map<String, Number>> metrics = metricsService.getAllMetrics(app);

	if(!metrics.isPresent()) {
		throw new ApplicationRuntimeException(app, "No metrics found");
	}

	Collection<MetricsCache> metricsCaches = metricsService.getMetricsCaches(metrics.get()).get();
	List<MetricsRest> metricsRest = metricsService.getMetricsRest(metrics.get()).get();
	Collection<MetricsDatasource> metricsDb = metricsService.getMetricsDatasources(metrics.get()).get();
	MetricsSystem metricsSystem = metricsService.getSystemMetrics(metrics.get()).get();

	// Build UI
	this.addComponent(new PageHeader(app, "Metrics"));

	this.addComponent(new Label("<h3>Health</h3>", ContentMode.HTML));
	this.addComponent(getHealth(health));

	this.addComponent(new Label("<h3>System metrics</h3>", ContentMode.HTML));
	this.addComponent(getSystemPanel(metricsSystem));

	if(!metricsRest.isEmpty()) {
		this.addComponent(new Label("<h3>Rest Controllers metrics : HTTP 2xx</h3>", ContentMode.HTML));
		this.addComponent(getRestGrid(metricsRest, Series.SUCCESSFUL));

		this.addComponent(new Label("<h3>Rest Controllers metrics : HTTP 3xx</h3>", ContentMode.HTML));
		this.addComponent(getRestGrid(metricsRest, Series.REDIRECTION));

		this.addComponent(new Label("<h3>Rest Controllers metrics : HTTP 4xx</h3>", ContentMode.HTML));
		this.addComponent(getRestGrid(metricsRest, Series.CLIENT_ERROR));

		this.addComponent(new Label("<h3>Rest Controllers metrics : HTTP 5xx</h3>", ContentMode.HTML));
		this.addComponent(getRestGrid(metricsRest, Series.SERVER_ERROR));
	}

	if(!metricsCaches.isEmpty()) {
		this.addComponent(new Label("<h3>Cache metrics</h3>", ContentMode.HTML));
		this.addComponent(getCacheGrid(metricsCaches));
	}

	if(!metricsDb.isEmpty()) {
		this.addComponent(new Label("<h3>Datasource metrics</h3>", ContentMode.HTML));
		this.addComponent(getDatasourceGrid(metricsDb));
	}

	allMetricsGrid = getAllMetricsGrid(metrics.get());

	this.addComponent(new Label("<h3>All metrics</h3>", ContentMode.HTML));
	this.addComponent(allMetricsGrid);
}
 
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:62,代码来源:MetricsPage.java


示例11: shouldExposeTypeOfSeries

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
@Test
public void shouldExposeTypeOfSeries() {
    assertThat(series().getType(), is(TypeToken.of(Series.class)));
}
 
开发者ID:zalando,项目名称:riptide,代码行数:5,代码来源:NavigatorsTest.java


示例12: series

import org.springframework.http.HttpStatus.Series; //导入依赖的package包/类
/**
 * A {@link Navigator} that selects a binding based on the response's status code series
 *
 * @return an HTTP status code series selector
 * @see Series
 */
public static Navigator<Series> series() {
    return SeriesNavigator.INSTANCE;
}
 
开发者ID:zalando,项目名称:riptide,代码行数:10,代码来源:Navigators.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MySqlOutputVisitor类代码示例发布时间:2022-05-23
下一篇:
Java XSLTCDTMManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap