本文整理匯總了Java中javax.ws.rs.client.ClientRequestContext.abortWith方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientRequestContext.abortWith方法的具體用法?Java ClientRequestContext.abortWith怎麽用?Java ClientRequestContext.abortWith使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.ws.rs.client.ClientRequestContext
的用法示例。
在下文中一共展示了ClientRequestContext.abortWith方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkParams
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
/**
* Check parameters on request Context
* @param requestContext
*/
private void checkParams(ClientRequestContext requestContext){
if (key==null) {
Object keyObject = requestContext.getProperty(JWS_FILTER_KEY);
if (keyObject == null) {
requestContext.abortWith(
Response.status(Response.Status.BAD_REQUEST).entity("Error " + JWS_FILTER_KEY + " param is required")
.build()
);
}else if (keyObject instanceof RSAPrivateKey) {
key = (RSAPrivateKey)keyObject;
}
}
}
示例2: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
String httpMethod = clientRequestContext.getMethod();
if ("MYMETHOD".equals(httpMethod)) {
clientRequestContext.abortWith(Response.ok(httpMethod).build());
}
else {
clientRequestContext.abortWith(Response.status(405).entity(httpMethod).build());
}
}
示例3: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
String query = clientRequestContext.getUri().getQuery();
Cookie cookie = clientRequestContext.getCookies().get("cookie");
String cookieValue = cookie==null?"null":cookie.getValue();
String header = clientRequestContext.getHeaderString("MyHeader");
clientRequestContext.abortWith(Response.ok(query + " " + cookieValue + " " + header).build());
}
示例4: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
logger.info("Client request called");
final String methodName = clientRequestContext.getMethod();
if (methodName.equals("PATCH")) {
clientRequestContext.abortWith(
Response.status(Response.Status.METHOD_NOT_ALLOWED)
.entity("HTTP Patch is NOT supported")
.build());
}
}
示例5: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
ResponseBuilder responseBuilder = serverError();
Response response = responseBuilder.status(BAD_REQUEST).build();
requestContext.abortWith(response);
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:7,代碼來源:BlockChainFilter.java
示例6: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
clientRequestContext.abortWith(Response.ok(clientRequestContext.getMethod() + " " + clientRequestContext.getUri()).build());
}
示例7: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
if (!circuitBreaker.checkState()) {
requestContext.abortWith(Response.status(Response.Status.SERVICE_UNAVAILABLE).entity(String.format("Service %s is currently unavilable.", serviceInterface)).build());
}
}