@Override public Method readValue() throws IOException { return Method.valueOf(readToken()); }
@Override protected Method getRestletMethod(Annotation annotation, Annotation methodAnnotation) { // try to get the method from the Annotation name itself, as JAX-RS // annotations map exactly to this Method restletMethod = Method.valueOf(annotation.annotationType() .getSimpleName()); if (restletMethod == null) { super.getRestletMethod(annotation, methodAnnotation); } return restletMethod; } }
/** * Returns an instance of {@link Method} according to the given annotations. * * @param annotation * Java annotation. * @param methodAnnotation * Annotation that corresponds to a Restlet method. * @return An instance of {@link Method} according to the given annotations. */ protected Method getRestletMethod(Annotation annotation, Annotation methodAnnotation) { return (methodAnnotation == null) ? null : Method.valueOf(((org.restlet.engine.connector.Method) methodAnnotation) .value()); }
/** * Returns the HTTP method related to the given java method. * * @param javaMethod * @return */ static org.restlet.data.Method getHttpMethod(Method javaMethod) { for (final Annotation annotation : javaMethod.getAnnotations()) { final Class<? extends Annotation> annoType = annotation .annotationType(); final HttpMethod httpMethodAnnot = annoType .getAnnotation(HttpMethod.class); if (httpMethodAnnot != null) { // Annotation of Annotation of the method is the HTTP-Method final String httpMethodName = httpMethodAnnot.value(); return org.restlet.data.Method.valueOf(httpMethodName); // NICE check if another designator is available: reject or warn } } return null; }
@Override public void setHttpMethod(String name) { getRequest().setMethod(Method.valueOf(name)); }
/** * Updates the set of methods with the ones allowed by this resource * instance. * * @param allowedMethods * The set to update. */ private void updateAllowedMethods(Set<Method> allowedMethods) { for (final java.lang.reflect.Method orig_classMethod : getClass() .getMethods()) { java.lang.reflect.Method classMethod; try { classMethod = getAncestorMethod(orig_classMethod); if (classMethod.getName().startsWith("allow") && (classMethod.getParameterTypes().length == 0)) { if ((Boolean) invoke(classMethod)) { final Method allowedMethod = Method.valueOf(classMethod .getName().substring(5)); allowedMethods.add(allowedMethod); } } } catch (NoSuchMethodException e) { getLogger().log(Level.FINE, "Unable to find a public version of this method.", e); } } }
/** * Updates the request method based on specific header. * * @param request * The request to update. */ @SuppressWarnings("unchecked") private void processHeaders(Request request) { final TunnelService tunnelService = getTunnelService(); if (tunnelService.isMethodTunnel()) { // get the headers Series<Header> extraHeaders = (Series<Header>) request .getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS); if (extraHeaders != null) { // look for the new value of the method final String newMethodValue = extraHeaders.getFirstValue( getTunnelService().getMethodHeader(), true); if (newMethodValue != null && newMethodValue.trim().length() > 0) { // set the current method to the new method request.setMethod(Method.valueOf(newMethodValue)); } } } }
@Override public Method getAccessControlRequestMethod() { Method result = super.getAccessControlRequestMethod(); if (!accessControlRequestMethodAdded) { String header = getHttpCall().getRequestHeaders().getFirstValue( HeaderConstants.HEADER_ACCESS_CONTROL_REQUEST_METHOD, true); if (header != null) { result = Method.valueOf(header); super.setAccessControlRequestMethod(result); } accessControlRequestMethodAdded = true; } return result; }
this.currentMethod.setName(Method.valueOf(attrs .getValue("name")));
setMethod(Method.valueOf(httpCall.getMethod()));
.getMethodParameter()); Method tunnelledMethod = Method.valueOf(methodName);