Package br.com.caelum.vraptor.controller

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


    verify(invalidInputHandler).deny(invalidInputException);
  }

  @Test
  public void shouldUseControllerMethodFoundWithNextInterceptor() throws Exception {
    final ControllerMethod method = mock(ControllerMethod.class);
    when(translator.translate(webRequest)).thenReturn(method);
    observer.handle(requestStarted);
    verify(interceptorStack).start();
  }
View Full Code Here


    verify(interceptorStack).start();
  }
 
  @Test
  public void shouldFireTheControllerWasFound() throws Exception {
    final ControllerMethod method = mock(ControllerMethod.class);
    when(translator.translate(webRequest)).thenReturn(method);
    observer.handle(requestStarted);
    verify(controllerFoundEvent).fire(any(ControllerFound.class));
  }
View Full Code Here

    verify(controllerFoundEvent).fire(any(ControllerFound.class));
  }
 
  @Test
  public void shouldFireTheRequestSuceeded() throws Exception {
    final ControllerMethod method = mock(ControllerMethod.class);
    when(translator.translate(webRequest)).thenReturn(method);
    observer.handle(requestStarted);
    verify(requestSucceededEvent).fire(any(RequestSucceded.class));
  }
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());

    if(request.getContentType() == null) {
      logger.warn("Request does not have Content-Type and parameters will be not deserialized");
      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

  }

  public void handle(@Observes RequestStarted event, CDIRequestFactories factories) {
    try {
      factories.setRequest(event);
      ControllerMethod method = translator.translate(event.getRequest());
      controllerFoundEvent.fire(new ControllerFound(method));
      interceptorStack.start();
      endRequestEvent.fire(new RequestSucceded(event.getRequest(), event.getResponse()));
    } catch (ControllerNotFoundException e) {
      controllerNotFoundHandler.couldntFind(event.getChain(), event.getRequest(), event.getResponse());
View Full Code Here

    this.methodReady = methodReady;
  }

  public void execute(@Observes InterceptorsExecuted event) {
    try {
      ControllerMethod method = event.getControllerMethod();
      methodReady.fire(new MethodReady(method));
      Method reflectionMethod = method .getMethod();
      Object[] parameters = methodInfo.getParametersValues();

      log.debug("Invoking {}", reflectionMethod);
      Object instance = event.getControllerInstance();
      Object result = new Mirror().on(instance).invoke().method(reflectionMethod).withArgs(parameters);
View Full Code Here

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

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

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

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

      for (ConstraintViolation<Object> v : violations) {
        BeanValidatorContext ctx = new BeanValidatorContext(v);
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.