本文整理汇总了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;
}
示例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));
}
}
示例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;
}
示例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);
}
示例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");
}
}
示例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());
}
}
示例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);
}
示例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;
}