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


Java Route.blockingHandler方法代码示例

本文整理汇总了Java中io.vertx.ext.web.Route.blockingHandler方法的典型用法代码示例。如果您正苦于以下问题:Java Route.blockingHandler方法的具体用法?Java Route.blockingHandler怎么用?Java Route.blockingHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.ext.web.Route的用法示例。


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

示例1: checkSecurity

import io.vertx.ext.web.Route; //导入方法依赖的package包/类
private static void checkSecurity(Router router, final RouteDefinition definition) {

		Route route;
		if (definition.pathIsRegEx()) {
			route = router.routeWithRegex(definition.getMethod(), definition.getRoutePath());
		} else {
			route = router.route(definition.getMethod(), definition.getRoutePath());
		}

		route.order(definition.getOrder()); // same order as following handler

		Handler<RoutingContext> securityHandler = getSecurityHandler(definition);
		if (definition.isBlocking()) {
			route.blockingHandler(securityHandler);
		} else {
			route.handler(securityHandler);
		}
	}
 
开发者ID:zandero,项目名称:rest.vertx,代码行数:19,代码来源:RestRouter.java

示例2: setHandler

import io.vertx.ext.web.Route; //导入方法依赖的package包/类
/**
 * Sets the handler.
 *
 * @param router the router
 * @param data   the data
 */
protected void setHandler(Router router, HandlerData data) {

  // Create auth handler if is setted
  if (data.authHandler() != null) {

    Route authRoute = createRoute(router, data);
    authRoute.handler(data.authHandler());
  }

  // Create route handler
  Route hdRegRoute = createRoute(router, data);
  Route route = createRoute(router, data);

  hdRegRoute.order(Integer.MIN_VALUE).handler(ctx -> {
    ctx.put(HANDLER_DATA, data);
    ctx.next();
  });

  if (HandlerType.HANDLER.equals(data.handlerType())) {

    route.handler(prepareHandler(data));
  } else if (HandlerType.FAILURE_HANDLER.equals(data.handlerType())) {

    route.failureHandler(prepareHandler(data));
  } else if (HandlerType.BLOCKING_HANDLER.equals(data.handlerType())) {

    route.blockingHandler(prepareHandler(data), false);
  } else if (HandlerType.SOCKETJS_HANDLER.equals(data.handlerType())) {

    route.handler(prepareSockJsHandler(data));
  }
}
 
开发者ID:jspare-projects,项目名称:vertx-jspare,代码行数:39,代码来源:HandlerWrapper.java

示例3: setHandler

import io.vertx.ext.web.Route; //导入方法依赖的package包/类
/**
 * Sets the handler.
 *
 * @param data the data
 * @param route the route
 */
protected static void setHandler(HandlerData data, Route route) {

	if (HandlerType.HANDLER.equals(data.handlerType())) {

		route.handler(prepareHandler(data));
	} else if (HandlerType.FAILURE_HANDLER.equals(data.handlerType())) {

		route.failureHandler(prepareHandler(data));
	} else if (HandlerType.BLOCKING_HANDLER.equals(data.handlerType())) {

		route.blockingHandler(prepareHandler(data), false);
	}
}
 
开发者ID:jspare-projects,项目名称:jspare-4vertx,代码行数:20,代码来源:HandlerWrapper.java

示例4: defineInitialisationRoute

import io.vertx.ext.web.Route; //导入方法依赖的package包/类
private void defineInitialisationRoute() {
    Route route = router.route(HttpMethod.GET, "/_init").produces(APPLICATION_JSON);
    route.blockingHandler(routingContext -> {

        logInfo("Initialising Java SDK modules... (" + new Date().toString() + ")");
        sdk = APIMappingGenerator.getSDK();
        logDebug(JsonObject.mapFrom(sdk).encodePrettily());
        JsonObject emptyResponse = new JsonObject();
        setResponse(routingContext).end(emptyResponse.encode());
    });
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:12,代码来源:TestServer.java

示例5: defineModuleMethodTestRoute

import io.vertx.ext.web.Route; //导入方法依赖的package包/类
@SuppressWarnings("boxing")
private void defineModuleMethodTestRoute() {
    Route route = router.route(HttpMethod.GET, "/:" + PARAM_MODULE + "/:" + PARAM_METHOD + "*")
            .produces(APPLICATION_JSON);
    route.blockingHandler(routingContext -> {
        if (sdk == null) {
            sendError(setResponse(routingContext), null, "Modules have not been initialised");
            return;
        }

        HttpServerRequest request = routingContext.request();
        String module = request.getParam(PARAM_MODULE);
        String method = request.getParam(PARAM_METHOD);
        Map<String, Object> params = retrieveQueryParameters(request);
        logInfo("TEST http://localhost:" + String.valueOf(port) + request.uri() + " AT " + new Date().toString());
        APICaller caller = new APICaller(sdk, config);
        APIMethodResult result = null;
        try {
            logInfo("CALLING " + String.valueOf(method) + " ON " + String.valueOf(module) + " USING "
                    + String.valueOf(toString(params)));
            result = caller.callAPI(ApiUtils.convertSnakeToCamel(module, true),
                    ApiUtils.convertSnakeToCamel(method, false), params);
            if (!result.wasExceptionRaised()) {
                String resultJson = Serializer.convertResultToJson(result.getResult());
                logDebug("RESULT " + String.valueOf(resultJson));
                setResponse(routingContext).end(resultJson);
            } else {
                logDebug("RESULT error happened: " + result.getMetadata());
                if (result.getMetadata() == null) {
                    sendError(setResponse(routingContext), null,
                            (result.getException().getMessage() == null)
                                    ? "Exception of type " + result.getException() + " was raised"
                                    : result.getException().getMessage());
                } else {
                    sendError(setResponse(routingContext), result.getMetadata().getStatusCode(),
                            "An error occurred during call. Call metadata: " + result.getMetadata().toString());
                }
            }

        } catch (UnknownAPIException | APICallException e) {
            sendError(setResponse(routingContext), null,
                    (e.getMessage() == null) ? "Exception of type " + e + " was raised" : e.getMessage());
        }
    });
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:46,代码来源:TestServer.java


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