當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。