Package br.com.caelum.vraptor.controller

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


    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


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

  public void validate(@Observes ReadyToExecuteMethod 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

  }

  public void deserializes(@Observes ReadyToExecuteMethod 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

  public boolean containsParameters(ControllerMethod method) {
    return method.getMethod().getParameterTypes().length > 0;
  }

  public void instantiate(@Observes StackStarting event) {
    ControllerMethod controllerMethod = event.getControllerMethod();
    if (containsParameters(controllerMethod)) {
      fixIndexedParameters(request);
      addHeaderParametersToAttribute(controllerMethod);

      Object[] values = getParametersFor(controllerMethod);
View Full Code Here

  }

  public void deserializes(@Observes ReadyToExecuteMethod 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

    this.stackStartingEvent = stackStartingEvent;
  }

  public void handle(@Observes NewRequest event, MethodInfo methodInfo, RequestInfo requestInfo) {
    try {
      ControllerMethod method = translator.translate(requestInfo);
      methodInfo.setControllerMethod(method);
      controllerMethodEvent.fire(new ControllerMethodDiscovered(method));
      stackStartingEvent.fire(new StackStarting(method));
      interceptorStack.start();
    } catch (ControllerNotFoundException e) {
View Full Code Here

  }

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

      log.debug("Invoking {}", Stringnifier.simpleNameFor(reflectionMethod));
      Object instance = event.getControllerInstance();
      Object result = methodExecutor.invoke(reflectionMethod, instance , parameters);
View Full Code Here

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

  public void validate(@Observes ReadyToExecuteMethod 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

    return any(asList(method.getMethod().getParameterAnnotations()), hasAnnotation(Load.class));
  }

  public void load(@Observes MethodReady event){

    ControllerMethod method = event.getControllerMethod();

    if (!containsLoadAnnotation(method)) return;

    Annotation[][] annotations = method.getMethod().getParameterAnnotations();

    Parameter[] parameters = provider.parametersFor(method.getMethod());
    Class<?>[] types = method.getMethod().getParameterTypes();

    Object[] args = flash.consumeParameters(method);

    for (int i = 0; i < parameters.length; i++) {
      if (hasLoadAnnotation(annotations[i])) {
View Full Code Here

  public String getControllerAndMethodName() {
    Field resourceMethodField = new Mirror().on(FixedMethodStrategy.class).reflect().field("resourceMethod");
    resourceMethodField.setAccessible(true);
    try {
      ControllerMethod resourceMethod = (ControllerMethod) resourceMethodField.get(route);
      return resourceMethod.getMethod().toString();
    } catch (Exception e) {
      return "Unknown: " + e.getMessage();
    }
  }
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.