Package br.com.caelum.vraptor.controller

Examples of br.com.caelum.vraptor.controller.ControllerMethod


  public void forward() throws IllegalStateException {
    String referer = getReferer();

    try {
      ControllerMethod method = router.parse(referer, HttpMethod.GET, request);
      executeMethod(method, result.use(logic()).forwardTo(method.getController().getType()));
    } catch (ControllerNotFoundException e) {
      result.use(page()).forwardTo(referer);
    } catch (MethodNotAllowedException e) {
      result.use(page()).forwardTo(referer);
    }
View Full Code Here


  }

  public void redirect() throws IllegalStateException {
    String referer = getReferer();
    try {
      ControllerMethod method = router.parse(referer, HttpMethod.GET, request);
      executeMethod(method, result.use(logic()).redirectTo(method.getController().getType()));
    } catch (ControllerNotFoundException e) {
      result.use(page()).redirectTo(referer);
    } catch (MethodNotAllowedException e) {
      result.use(page()).redirectTo(referer);
    }
View Full Code Here

  }

  @Override
  public Void execute(Object interceptor) {
    InterceptorStack stack = container.instanceFor(InterceptorStack.class);
    ControllerMethod controllerMethod = container.instanceFor(ControllerMethod.class);
    ControllerInstance controllerInstance = container.instanceFor(ControllerInstance.class);
    stack.next(controllerMethod , controllerInstance.getController());
    return null;
  }
View Full Code Here

    return proxifier.proxify(type, new MethodInvocation<T>() {
      @Override
      public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
        try {
          logger.debug("Executing {}", Stringnifier.simpleNameFor(method));
          ControllerMethod old = methodInfo.getControllerMethod();
          methodInfo.setControllerMethod(DefaultControllerMethod.instanceFor(type, method));
          Object result = method.invoke(container.instanceFor(type), args);
          methodInfo.setControllerMethod(old);

          Type returnType = method.getGenericReturnType();
View Full Code Here

  @Override
  public void forward() throws IllegalStateException {
    String referer = getReferer();

    try {
      ControllerMethod method = router.parse(referer, HttpMethod.GET, request);
      executeMethod(method, result.use(logic()).forwardTo(method.getController().getType()));
    } catch (ControllerNotFoundException e) {
      result.use(page()).forwardTo(referer);
    } catch (MethodNotAllowedException e) {
      result.use(page()).forwardTo(referer);
    }
View Full Code Here

  @Override
  public void redirect() throws IllegalStateException {
    String referer = getReferer();
    try {
      ControllerMethod method = router.parse(referer, HttpMethod.GET, request);
      executeMethod(method, result.use(logic()).redirectTo(method.getController().getType()));
    } catch (ControllerNotFoundException e) {
      result.use(page()).redirectTo(referer);
    } catch (MethodNotAllowedException e) {
      result.use(page()).redirectTo(referer);
    }
View Full Code Here

    String controllerName = info.getRequestedUri();

    logger.debug("trying to access {}", controllerName);

    HttpMethod method = getHttpMethod(request, controllerName);
    ControllerMethod controller = router.parse(controllerName, method, request);

    logger.debug("found controller {}", controller);
    return controller;
  }
View Full Code Here

    return descriptor != null && descriptor.hasConstrainedParameters();
  }

  public void validate(@Observes MethodReady event, ControllerInstance controllerInstance, MethodInfo methodInfo,
      Validator validator) {
    ControllerMethod method = event.getControllerMethod();

    if (hasConstraints(method)) {
      Set<ConstraintViolation<Object>> violations = bvalidator.forExecutables().validateParameters(
          controllerInstance.getController(), method.getMethod(), methodInfo.getParametersValues());

      logger.debug("there are {} constraint violations at method {}.", violations.size(), method);

      for (ConstraintViolation<Object> v : violations) {
        String category = extractCategory(methodInfo.getValuedParameters(), v);
View Full Code Here

  }

  public void deserializes(@Observes InterceptorsReady event, HttpServletRequest request,
      MethodInfo methodInfo, Status status) throws IOException {

    ControllerMethod method = event.getControllerMethod();

    if (!method.containsAnnotation(Consumes.class)) return;

    List<String> supported =  asList(method.getMethod().getAnnotation(Consumes.class).value());

    String contentType = mime(request.getContentType());
    if (!supported.isEmpty() && !supported.contains(contentType)) {
      unsupported("Request with media type [%s]. Expecting one of %s.", status, contentType, supported);
      return;
View Full Code Here

      @Override
      public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
        try {
          logger.debug("Executing {}", method);
          ControllerMethod old = methodInfo.getControllerMethod();
          methodInfo.setControllerMethod(DefaultControllerMethod.instanceFor(type, method));
          Object methodResult = method.invoke(container.instanceFor(type), args);
          methodInfo.setControllerMethod(old);

          Type returnType = method.getGenericReturnType();
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.controller.ControllerMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.