Package br.com.caelum.vraptor.controller

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


  }

  @Override
  public void is(Class<?> type, Method method) {
    addParametersInfo(method);
    ControllerMethod controllerMethod = DefaultControllerMethod.instanceFor(type, method);
    Parameter[] parameterNames = nameProvider.parametersFor(method);
    this.strategy = new FixedMethodStrategy(originalUri, controllerMethod, this.supportedMethods, builder.build(), priority, parameterNames);

    logger.info(String.format("%-50s%s -> %10s", originalUri,
        this.supportedMethods.isEmpty() ? "[ALL]" : this.supportedMethods,
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

  public boolean containsLoadAnnotation(ControllerMethod method) {
    return any(asList(method.getMethod().getParameterAnnotations()), hasAnnotation(Load.class));
  }

  public void load(@Observes ControllerFound event) {
    ControllerMethod method = event.getMethod();

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

      final Parameter[] parameters = provider.parametersFor(method.getMethod());
      final Class<?>[] types = method.getMethod().getParameterTypes();
      final Object[] args = flash.consumeParameters(method);

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

    }
    return routesMatchingURI;
  }

  public void cacheRoute(Route r) {
    ControllerMethod controllerMethod = r.getControllerMethod();
    BeanClass controller = controllerMethod.getController();
    Invocation invocation = new Invocation(controller.getType(), controllerMethod.getMethod());
    cache.write(invocation, r);
  }
View Full Code Here

  }

  @Override
  public void is(Class<?> type, Method method) {
    addParametersInfo(method);
    ControllerMethod controllerMethod = DefaultControllerMethod.instanceFor(type, method);
    String[] parameterNames = nameProvider.parameterNamesFor(method);
    this.strategy = new FixedMethodStrategy(originalUri, controllerMethod, this.supportedMethods, builder.build(), priority, parameterNames);

    logger.info(String.format("%-50s%s -> %10s", originalUri,
        this.supportedMethods.isEmpty() ? "[ALL]" : this.supportedMethods,
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

  }

  @Override
  public void is(Class<?> type, Method method) {
    addParametersInfo(method);
    ControllerMethod controllerMethod = DefaultControllerMethod.instanceFor(type, method);
    Parameter[] parameterNames = nameProvider.parametersFor(method);
    this.strategy = new FixedMethodStrategy(originalUri, controllerMethod, this.supportedMethods, builder.build(), priority, parameterNames);

    logger.info(String.format("%-50s%s -> %10s", originalUri,
        this.supportedMethods.isEmpty() ? "[ALL]" : this.supportedMethods, method));
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 {}", 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 | 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 | MethodNotAllowedException e) {
      result.use(page()).redirectTo(referer);
    }
  }
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.