本文整理匯總了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;
}