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


Java ContainerRequestContext.getMethod方法代码示例

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


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

示例1: alwaysAccept

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
public boolean alwaysAccept(ContainerRequestContext requestContext) {
    String aboslutePath = requestContext.getUriInfo().getAbsolutePath().toString();
    String requestMethod = requestContext.getMethod();

    AppTokenRequired methodAnnotation = resourceInfo.getResourceMethod() != null
            ? resourceInfo.getResourceMethod().getAnnotation(AppTokenRequired.class)
            : null;
    AppTokenRequired classAnnotation = resourceInfo.getResourceClass() != null
            ? resourceInfo.getResourceClass().getAnnotation(AppTokenRequired.class)
            : null;
    boolean annotationFasttrack = ! configuration.requireAppTokenByDefault;
    if (methodAnnotation != null) {
        annotationFasttrack = ! methodAnnotation.value();
    } else if (classAnnotation != null) {
        annotationFasttrack = ! classAnnotation.value();
    }

    return aboslutePath.contains("swagger") ||
            "OPTIONS".equals(requestMethod) ||
            configuration.fasttrackFilter.test(requestContext) ||
            annotationFasttrack;
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:23,代码来源:ApplicationTokenFilter.java

示例2: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
	logger.info("getHeaders : " + requestContext.getHeaders());
	logger.info("getDate : " + requestContext.getDate());
	logger.info("getLanguage : " + requestContext.getLanguage());
	logger.info("getEntityStream : " + requestContext.getEntityStream());
	logger.info("getLength : " + requestContext.getLength());
	logger.info("getMediaType : " + requestContext.getMediaType());
	logger.info("getMethod : " + requestContext.getMethod());
	logger.info("getPropertyNames : " + requestContext.getPropertyNames());
	logger.info("getRequest : " + requestContext.getRequest());
	logger.info("getSecurityContext : " + requestContext.getSecurityContext());
	logger.info("getUriInfo : " + requestContext.getUriInfo());
	calledMethod = requestContext.getMethod();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:16,代码来源:RegisterOperation.java

示例3: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
public void filter(ContainerRequestContext requestContext,
		ContainerResponseContext responseContext) throws IOException {
	String method = requestContext.getMethod();

	logger.debug("Requesting " + method + " for path " + requestContext.getUriInfo().getPath());
	Object entity = responseContext.getEntity();
	if (entity != null) {
		logger.debug("Response " + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(entity));
	}

}
 
开发者ID:jiumao-org,项目名称:wechat-mall,代码行数:12,代码来源:LoggingResponseFilter.java

示例4: validate

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
/**
 * Validates a request by building {@link SimpleRequest}. Result contains validated request
 * parameters. It would also set default values for missing parameters
 *
 * @param apiOperation api operation model to be validated
 * @return a map of (validated) parameters
 * @throws WebApplicationException in case validation fails
 */
RequestParameters validate(@NonNull ApiOperation apiOperation, @NonNull Swagger swagger,
    @NonNull ContainerRequestContext requestContext) {
  String strMethod = requestContext.getMethod();
  Method method = Method.valueOf(strMethod.toUpperCase());
  Builder builder = new SimpleRequest.Builder(method, requestContext.getUriInfo().getPath());

  requestContext.getHeaders().forEach(builder::withHeader);
  requestContext.getUriInfo().getPathParameters().forEach(builder::withQueryParam);
  requestContext.getUriInfo().getQueryParameters().forEach(builder::withQueryParam);

  RequestParameters requestParameters =
      RequestParameterExtractor.extract(apiOperation, swagger, requestContext);

  String body = requestParameters.getRawBody();
  builder.withBody(body);

  /*
   * NB: Swagger API 2 does not have an option for case insensitivity for enums; for example, you
   * may expect validation to fail for 'POint' (if the enum is defined as 'Point')
   */
  ValidationReport report = requestValidator.validateRequest(builder.build(), apiOperation);

  if (report.hasErrors()) {
    LOG.error("Request parameter validation failed");
    throw createException(report);
  }

  // at this point all parameters are (considered) valid
  LOG.debug("Request parameters validated");

  return requestParameters;
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:41,代码来源:ApiRequestValidator.java

示例5: allwaysAccept

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
public boolean allwaysAccept(ContainerRequestContext requestContext) {
    String aboslutePath = requestContext.getUriInfo().getAbsolutePath().toString();
    String requestMethod = requestContext.getMethod();

    return aboslutePath.contains("swagger") ||
            "OPTIONS".equals(requestMethod);
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:8,代码来源:AppNameFilter.java

示例6: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    String aboslutePath = requestContext.getUriInfo().getAbsolutePath().toString();
    String requestMethod = requestContext.getMethod();

    if (aboslutePath.contains("swagger.json") || "OPTIONS".equals(requestMethod)) {
        return;
    }

    if (requireUserToken() && securityContext.getUserPrincipal() == null) {
        throw new NotAuthorizedException("UsertokenId required");
    }
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:14,代码来源:UserTokenBlockingFilter.java

示例7: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    String url = requestContext.getUriInfo().getRequestUri().getPath();
    String method = requestContext.getMethod();

    if (! isAccessGranted(url, method)) {
        logRejectedRequest(url, method);

        throw new WebApplicationException(Response.status(Response.Status.FORBIDDEN)
            .entity(new ErrorMessage("Access denied for " + url + " due to invalid permissions")).build());
    }
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:13,代码来源:PermissionFilter.java

示例8: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
	String calledMethod = requestContext.getMethod();
	requestContext.setProperty("calledMethod", calledMethod);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:6,代码来源:RegisterCall.java

示例9: getUri

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
private String getUri(ContainerRequestContext request) {
    String queryParamString = request.getUriInfo().getRequestUri().getQuery();

    String query = Strings.isNullOrEmpty(queryParamString) ? "" : "?" + queryParamString;
    return request.getMethod() + " " + request.getUriInfo().getPath() + query;
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:7,代码来源:ServerLogFilter.java


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