本文整理汇总了Java中org.restlet.Restlet.handle方法的典型用法代码示例。如果您正苦于以下问题:Java Restlet.handle方法的具体用法?Java Restlet.handle怎么用?Java Restlet.handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restlet.Restlet
的用法示例。
在下文中一共展示了Restlet.handle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import org.restlet.Restlet; //导入方法依赖的package包/类
@Override
public void handle(Request request, Response response) {
super.handle(request, response);
if (getFirstInboundFilter() != null) {
getFirstInboundFilter().handle(request, response);
} else {
final Restlet next = this.inboundNext;
if (next != null) {
next.handle(request, response);
} else {
response.setStatus(Status.SERVER_ERROR_INTERNAL);
getHelped()
.getLogger()
.error("The "
+ getHelped().getClass().getName()
+ " class has no Restlet defined to process calls. Maybe it wasn't properly started.");
}
}
}
示例2: serverRedirect
import org.restlet.Restlet; //导入方法依赖的package包/类
/**
* Redirects a given call on the server-side to a next Restlet with a given
* target reference. In the default implementation, the request HTTP
* headers, stored in the request's attributes, are removed before
* dispatching. After dispatching, the response HTTP headers are also
* removed to prevent conflicts with the main call.
*
* @param next
* The next Restlet to forward the call to.
* @param targetRef
* The target reference with URI variables resolved.
* @param request
* The request to handle.
* @param response
* The response to update.
*/
protected void serverRedirect(Restlet next, Reference targetRef,
Request request, Response response) {
if (next == null) {
getLogger().warn(
"No next Restlet provided for server redirection to "
+ targetRef);
} else {
// Save the base URI if it exists as we might need it for
// redirections
Reference resourceRef = request.getResourceRef();
// Reset the protocol and let the dispatcher handle the protocol
request.setProtocol(null);
// Update the request to cleanly go to the target URI
request.setResourceRef(targetRef);
rewrite(request);
next.handle(request, response);
request.setResourceRef(resourceRef);
// Allow for response rewriting and clean the headers
response.setEntity(rewrite(response.getEntity()));
rewrite(response);
// In case of redirection, we may have to rewrite the redirect URI
rewriteLocation(request, response);
}
}
示例3: handle
import org.restlet.Restlet; //导入方法依赖的package包/类
@Override
public void handle(Request request, Response response) {
Method method = request.getMethod();
LOG.debug("MethodRouter ({}) received request method: {}", uriPattern, method);
Restlet target = routes.get(method);
if (target != null) {
target.handle(request, response);
} else {
LOG.debug("MethodRouter ({}) method not allowed: {}", uriPattern, method);
response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
// must include list of allowed methods
response.setAllowedMethods(routes.keySet());
}
}
示例4: doHandle
import org.restlet.Restlet; //导入方法依赖的package包/类
/**
* Effectively handles the call using the selected next {@link Restlet},
* typically the selected {@link Route}. By default, it just invokes the
* next Restlet.
*
* @param next
* The next Restlet to invoke.
* @param request
* The request.
* @param response
* The response.
*/
protected void doHandle(Restlet next, Request request, Response response) {
next.handle(request, response);
}